app-emulation/virtualbox-guest-additions: patches for kernel 6.8

Apply a few upstream patches.

Closes: https://bugs.gentoo.org/926766
Signed-off-by: Viorel Munteanu <ceamac@gentoo.org>
This commit is contained in:
Viorel Munteanu
2024-03-28 20:32:42 +02:00
parent ba83edd600
commit 96629f6291
2 changed files with 537 additions and 0 deletions
@@ -0,0 +1,242 @@
Support for kernel 6.8.x.
https://www.virtualbox.org/changeset/102989/vbox
https://www.virtualbox.org/changeset/102990/vbox
https://www.virtualbox.org/changeset/102992/vbox
https://www.virtualbox.org/changeset/102993/vbox
https://www.virtualbox.org/changeset/102994/vbox
------------------------------------------------------------------------
r102989 | vboxsync | 2024-01-22 19:12:25 +0200 (Lu, 22 ian 2024) | 2 lines
iprt: Add wrapper for strlcpy/strscpy functions, bugref:10584.
--- a/include/iprt/string.h
+++ b/include/iprt/string.h
@@ -245,7 +245,29 @@
# define RT_BCOPY_UNFORTIFIED(a_pDst, a_pSrc, a_cbToCopy) memcpy((a_pDst), (a_pSrc), (a_cbToCopy))
#endif /* !RT_OS_LINUX && !__KERNEL__ */
+/** @def RT_STRSCPY
+ * Copy string and NULL-terminate output buffer.
+ *
+ * This macro should mostly be used in Linux kernel code. This is
+ * the replacement for deprecated strlcpy. It was deprecated since 3.16.60
+ * when strscpy was introduced as an alternative. Finally, strlcpy was
+ * completely removed from kernel code in 6.8.0.
+ *
+ * @param a_pDst Pointer to the destination string buffer.
+ * @param a_pSrc Pointer to the source NULL-terminated string buffer.
+ * @param a_cbToCopy Size of destination buffer..
+ */
+#if defined(RT_OS_LINUX) && defined(__KERNEL__)
+# if (RTLNX_VER_MIN(3,16,60))
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbToCopy) strscpy((a_pDst), (a_pSrc), (a_cbToCopy))
+# else /* < 3.16.60 */
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbToCopy) strlcpy((a_pDst), (a_pSrc), (a_cbToCopy))
+# endif
+#else /* !RT_OS_LINUX && !__KERNEL__ */
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbToCopy) strscpy((a_pDst), (a_pSrc), (a_cbToCopy))
+#endif /* !RT_OS_LINUX && !__KERNEL__ */
+
#ifdef IN_RING3
/**
------------------------------------------------------------------------
------------------------------------------------------------------------
r102990 | vboxsync | 2024-01-22 19:13:50 +0200 (Lu, 22 ian 2024) | 2 lines
Additions: Linux: Introduce initial support for kernel 6.8, bugref:10584.
--- a/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
+++ b/src/VBox/Additions/common/VBoxGuest/VBoxGuest-linux.c
@@ -1410,7 +1410,7 @@
RTLogGroupSettings(pLogger, pszValue);
}
else if (pParam->name[0] != 'd')
- strlcpy(&g_szLogGrp[0], pszValue, sizeof(g_szLogGrp));
+ RT_STRSCPY(&g_szLogGrp[0], pszValue, sizeof(g_szLogGrp));
return 0;
}
@@ -1436,7 +1436,7 @@
RTLogFlags(pLogger, pszValue);
}
else if (pParam->name[0] != 'd')
- strlcpy(&g_szLogFlags[0], pszValue, sizeof(g_szLogFlags));
+ RT_STRSCPY(&g_szLogFlags[0], pszValue, sizeof(g_szLogFlags));
return 0;
}
@@ -1461,7 +1461,7 @@
RTLogDestinations(pLogger, pszValue);
}
else if (pParam->name[0] != 'd')
- strlcpy(&g_szLogDst[0], pszValue, sizeof(g_szLogDst));
+ RT_STRSCPY(&g_szLogDst[0], pszValue, sizeof(g_szLogDst));
return 0;
}
--- a/src/VBox/Additions/linux/drm/vbox_drv.h
+++ b/src/VBox/Additions/linux/drm/vbox_drv.h
@@ -538,9 +538,7 @@
int vbox_irq_init(struct vbox_private *vbox);
void vbox_irq_fini(struct vbox_private *vbox);
void vbox_report_hotplug(struct vbox_private *vbox);
-#if RTLNX_VER_MAX(5,15,0) && !RTLNX_RHEL_MAJ_PREREQ(9,1) && !RTLNX_SUSE_MAJ_PREREQ(15,5)
irqreturn_t vbox_irq_handler(int irq, void *arg);
-#endif
/* vbox_hgsmi.c */
void *hgsmi_buffer_alloc(struct gen_pool *guest_pool, size_t size,
--- a/src/VBox/Additions/linux/sharedfolders/vfsmod.c
+++ b/src/VBox/Additions/linux/sharedfolders/vfsmod.c
@@ -1408,7 +1408,7 @@
switch (opt) {
case Opt_iocharset:
case Opt_nls:
- strlcpy(info->nls_name, param->string, sizeof(info->nls_name));
+ RT_STRSCPY(info->nls_name, param->string, sizeof(info->nls_name));
break;
case Opt_uid:
info->uid = result.uint_32;
@@ -1469,7 +1469,7 @@
printk(KERN_WARNING "vboxsf: cache mode (%u) is out of range, using default instead.\n", result.uint_32);
break;
case Opt_tag:
- strlcpy(info->szTag, param->string, sizeof(info->szTag));
+ RT_STRSCPY(info->szTag, param->string, sizeof(info->szTag));
break;
default:
return invalf(fc, "Invalid mount option: '%s'", param->key);
@@ -1528,7 +1528,7 @@
}
/* fc->source (the shared folder name) is set after vbsf_init_fs_ctx() */
- strlcpy(info->name, fc->source, sizeof(info->name));
+ RT_STRSCPY(info->name, fc->source, sizeof(info->name));
# if RTLNX_VER_MAX(5,3,0)
return vfs_get_super(fc, vfs_get_independent_super, vbsf_read_super_aux);
--- a/src/VBox/Additions/linux/sharedfolders/regops.c
+++ b/src/VBox/Additions/linux/sharedfolders/regops.c
@@ -3505,7 +3505,7 @@
};
/** file_operations::mmap wrapper for logging purposes. */
-extern int vbsf_reg_mmap(struct file *file, struct vm_area_struct *vma)
+static int vbsf_reg_mmap(struct file *file, struct vm_area_struct *vma)
{
int rc;
SFLOGFLOW(("vbsf_reg_mmap: file=%p vma=%p\n", file, vma));
@@ -3786,7 +3786,7 @@
}
# if RTLNX_VER_MIN(5,19,0) || RTLNX_RHEL_RANGE(9,3, 9,99)
-int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
+static int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
unsigned len, struct page **pagep, void **fsdata)
{
vbsf_write_begin_warn(pos, len, 0);
@@ -3793,7 +3793,7 @@
return simple_write_begin(file, mapping, pos, len, pagep, fsdata);
}
# else
-int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
+static int vbsf_write_begin(struct file *file, struct address_space *mapping, loff_t pos,
unsigned len, unsigned flags, struct page **pagep, void **fsdata)
{
vbsf_write_begin_warn(pos, len, flags);
------------------------------------------------------------------------
------------------------------------------------------------------------
r102992 | vboxsync | 2024-01-22 19:33:49 +0200 (Lu, 22 ian 2024) | 5 lines
iprt: Add wrapper for strlcpy/strscpy functions, build fix, bugref:10584.
Ignore return code of strscpy() in RT_STRSCPY macro sinse we have no caller
who is using it. Also rename macro parameter, so it makes more sense.
--- a/include/iprt/string.h
+++ b/include/iprt/string.h
@@ -255,16 +255,16 @@
*
* @param a_pDst Pointer to the destination string buffer.
* @param a_pSrc Pointer to the source NULL-terminated string buffer.
- * @param a_cbToCopy Size of destination buffer..
+ * @param a_cbDst Size of destination buffer.
*/
#if defined(RT_OS_LINUX) && defined(__KERNEL__)
# if (RTLNX_VER_MIN(3,16,60))
-# define RT_STRSCPY(a_pDst, a_pSrc, a_cbToCopy) strscpy((a_pDst), (a_pSrc), (a_cbToCopy))
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) (void)strscpy((a_pDst), (a_pSrc), (a_cbDst))
# else /* < 3.16.60 */
-# define RT_STRSCPY(a_pDst, a_pSrc, a_cbToCopy) strlcpy((a_pDst), (a_pSrc), (a_cbToCopy))
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) strlcpy((a_pDst), (a_pSrc), (a_cbDst))
# endif
#else /* !RT_OS_LINUX && !__KERNEL__ */
-# define RT_STRSCPY(a_pDst, a_pSrc, a_cbToCopy) strscpy((a_pDst), (a_pSrc), (a_cbToCopy))
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) (void)strscpy((a_pDst), (a_pSrc), (a_cbDst))
#endif /* !RT_OS_LINUX && !__KERNEL__ */
------------------------------------------------------------------------
r102993 | vboxsync | 2024-01-22 19:41:44 +0200 (Lu, 22 ian 2024) | 5 lines
Add wrapper for strlcpy/strscpy functions, build fix, bugref:10584.
It seem, strscpy was added around 4.3.0. Older kernels probably
have it as a backport. So, stick to 4.3.0.
--- a/include/iprt/string.h
+++ b/include/iprt/string.h
@@ -258,7 +258,7 @@
* @param a_cbDst Size of destination buffer.
*/
#if defined(RT_OS_LINUX) && defined(__KERNEL__)
-# if (RTLNX_VER_MIN(3,16,60))
+# if (RTLNX_VER_MIN(4,3,0))
# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) (void)strscpy((a_pDst), (a_pSrc), (a_cbDst))
# else /* < 3.16.60 */
# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) strlcpy((a_pDst), (a_pSrc), (a_cbDst))
------------------------------------------------------------------------
r102994 | vboxsync | 2024-01-22 20:06:29 +0200 (Lu, 22 ian 2024) | 6 lines
iprt: Add wrapper for strlcpy/strscpy functions, build fix, bugref:10584.
Another way around to suppress build error when strscpy return status
is not used. Also, turn macro into strlcpy for non-Linux systems,
so for them it will be no change.
--- a/include/iprt/string.h
+++ b/include/iprt/string.h
@@ -259,12 +259,16 @@
*/
#if defined(RT_OS_LINUX) && defined(__KERNEL__)
# if (RTLNX_VER_MIN(4,3,0))
-# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) (void)strscpy((a_pDst), (a_pSrc), (a_cbDst))
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) \
+ { \
+ ssize_t _ret; \
+ _ret = strscpy((a_pDst), (a_pSrc), (a_cbDst)); \
+ }
# else /* < 3.16.60 */
# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) strlcpy((a_pDst), (a_pSrc), (a_cbDst))
# endif
#else /* !RT_OS_LINUX && !__KERNEL__ */
-# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) (void)strscpy((a_pDst), (a_pSrc), (a_cbDst))
+# define RT_STRSCPY(a_pDst, a_pSrc, a_cbDst) strlcpy((a_pDst), (a_pSrc), (a_cbDst))
#endif /* !RT_OS_LINUX && !__KERNEL__ */
------------------------------------------------------------------------
@@ -0,0 +1,295 @@
# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit edo linux-mod-r1 systemd toolchain-funcs udev
MY_PN="VirtualBox"
MY_P="${MY_PN}-${PV}"
DESCRIPTION="VirtualBox kernel modules and user-space tools for Gentoo guests"
HOMEPAGE="https://www.virtualbox.org/"
SRC_URI="https://download.virtualbox.org/virtualbox/${PV}/${MY_P}.tar.bz2
https://gitweb.gentoo.org/proj/virtualbox-patches.git/snapshot/virtualbox-patches-7.0.14.tar.bz2"
S="${WORKDIR}/${MY_PN}-${PV}"
# Reminder: see the LICENSE related comment in app-emulation/virtualbox-additions ebuild
LICENSE="GPL-3 LGPL-2.1+ MIT || ( GPL-3 CDDL )"
SLOT="0/$(ver_cut 1-2)"
KEYWORDS="~amd64 ~x86"
IUSE="+dbus gui"
# automount Error: VBoxServiceAutoMountWorker: Group "vboxsf" does not exist
# TODO: find out what this is, remove comment if obsolete
RDEPEND="
acct-group/vboxguest
acct-group/vboxsf
acct-user/vboxguest
sys-libs/pam
sys-libs/zlib
dbus? ( sys-apps/dbus )
gui? (
x11-apps/xrandr
x11-apps/xrefresh
x11-libs/libX11
x11-libs/libXext
x11-libs/libXmu
x11-libs/libXt
)
"
# some libs here are indirect dependencies, and also needed at compile time.
# keeping them in DEPEND to avoid warnings from qa-vdb.
DEPEND="
${RDEPEND}
gui? (
x11-libs/libICE
x11-libs/libSM
x11-libs/libXau
x11-libs/libXdmcp
x11-base/xorg-proto
)
"
BDEPEND="
>=dev-lang/yasm-0.6.2
>=dev-build/kbuild-0.1.9998.3127
sys-devel/bin86
sys-power/iasl
"
PDEPEND="
gui? ( x11-drivers/xf86-video-vboxvideo )
"
PATCHES=(
"${FILESDIR}"/${PN}-7.0.8-fix-gcc13.patch
"${FILESDIR}"/${PN}-7.0.14-kernel-6.8.patch
)
DOCS=() # Don't install the default README file during einstalldocs
VBOX_MOD_SRC_DIR="out/linux.${ARCH}/release/bin/additions/src"
CONFIG_CHECK="DRM_TTM"
src_prepare() {
eapply "${PATCHES[@]}"
# Remove shipped binaries (kBuild,yasm), see bug #232775
rm -r kBuild/bin tools || die
# Provide kernel sources
pushd src/VBox/Additions &>/dev/null || die
ebegin "Extracting guest kernel module sources"
kmk GuestDrivers-src vboxguest-src vboxsf-src vboxvideo-src &>/dev/null
eend $? || die
popd &>/dev/null || die
# PaX fixes (see bug #298988)
eapply -d "${VBOX_MOD_SRC_DIR}" -- "${FILESDIR}"/vboxguest-6.1.36-log-use-c99.patch
# Disable things unused or splitted into separate ebuilds
cp "${FILESDIR}/${PN}-5-localconfig" LocalConfig.kmk || die
if ! use gui; then
echo "VBOX_WITH_X11_ADDITIONS :=" >> LocalConfig.kmk || die
fi
# Remove pointless GCC version check
sed -e '/ check_gcc$/d' -i configure || die
# Respect LDFLAGS (bug #759100)
sed -i -e '/TEMPLATE_VBoxR3Exe_LDFLAGS.linux[ ]*=/ s/$/ $(CCLDFLAGS)/' Config.kmk || die
eapply "${WORKDIR}/virtualbox-patches-7.0.14/patches"
eapply_user
}
src_configure() {
tc-export AR CC CXX LD RANLIB
# Build the user-space tools, warnings are harmless
local myconf=(
--with-gcc="$(tc-getCC)"
--with-g++="$(tc-getCXX)"
--nofatal
--disable-xpcom
--disable-sdl-ttf
--disable-pulse
--disable-alsa
$(usev !dbus --disable-dbus)
--target-arch=${ARCH}
--with-linux="${KV_OUT_DIR}"
--build-headless
)
# bug #843437
# Respect LDFLAGS (bug #759100)
# Cannot use LDFLAGS here because they also get passed to $(LD)
cat >> LocalConfig.kmk <<-EOF || die
CFLAGS=${CFLAGS}
CXXFLAGS=${CXXFLAGS}
CCLDFLAGS=${LDFLAGS}
EOF
edo ./configure "${myconf[@]}"
}
src_compile() {
source ./env.sh || die
# Force kBuild to respect C[XX]FLAGS and MAKEOPTS (bug #178529)
MAKEJOBS=$(grep -Eo '(\-j|\-\-jobs)(=?|[[:space:]]*)[[:digit:]]+' <<< ${MAKEOPTS})
MAKELOAD=$(grep -Eo '(\-l|\-\-load-average)(=?|[[:space:]]*)[[:digit:]]+' <<< ${MAKEOPTS})
MAKEOPTS="${MAKEJOBS} ${MAKELOAD}"
local myemakeargs=(
VBOX_BUILD_PUBLISHER=_Gentoo
VBOX_ONLY_ADDITIONS=1
KBUILD_VERBOSE=2
AS="$(tc-getCC)"
CC="$(tc-getCC)"
CXX="$(tc-getCXX)"
LD="$(tc-getCC)"
TOOL_GCC3_CC="$(tc-getCC)"
TOOL_GCC3_CXX="$(tc-getCXX)"
TOOL_GCC3_LD="$(tc-getCC)"
TOOL_GCC3_AS="$(tc-getCC)"
TOOL_GCC3_AR="$(tc-getAR)"
TOOL_GCC3_OBJCOPY="$(tc-getOBJCOPY)"
#TOOL_GCC3_LD_SYSMOD="$(tc-getCC)"
TOOL_GXX3_CC="$(tc-getCC)"
TOOL_GXX3_CXX="$(tc-getCXX)"
TOOL_GXX3_LD="$(tc-getCXX)"
TOOL_GXX3_AS="$(tc-getCXX)"
TOOL_GXX3_AR="$(tc-getAR)"
TOOL_GXX3_OBJCOPY="$(tc-getOBJCOPY)"
#TOOL_GXX3_LD_SYSMOD="$(tc-getCXX)"
TOOL_GCC3_CFLAGS="${CFLAGS}"
TOOL_GCC3_CXXFLAGS="${CXXFLAGS}"
VBOX_GCC_OPT="${CXXFLAGS}"
VBOX_NM="$(tc-getNM)"
TOOL_YASM_AS=yasm
)
MAKE="kmk" emake "${myemakeargs[@]}"
# Now creating the kernel modules. We must do this _after_
# we compiled the user-space tools as we need two of the
# automatically generated header files. (>=3.2.0)
# Move this here for bug 836037
local modargs=( KERN_DIR="${KV_OUT_DIR}" KERN_VER="${KV_FULL}" )
local modlist=( vboxguest vboxsf )
use gui && modlist+=( vboxvideo )
modlist=( "${modlist[@]/%/=misc:${VBOX_MOD_SRC_DIR}}" )
linux-mod-r1_src_compile
}
src_install() {
linux-mod-r1_src_install
insinto /etc/modprobe.d # 485996
newins - vboxsf.conf <<-EOF
# modprobe.d configuration file for VBOXSF
# Internal Aliases - Do not edit
# ------------------------------
alias fs-vboxsf vboxsf
EOF
cd out/linux.${ARCH}/release/bin/additions || die
insinto /sbin
newins mount.vboxsf mount.vboxsf
fperms 4755 /sbin/mount.vboxsf
if use dbus; then
newinitd "${FILESDIR}"/${PN}-8.initd-r1 ${PN}
else
newinitd <(sed 's/ dbus\>//' "${FILESDIR}"/${PN}-8.initd-r1) ${PN}
fi
insinto /usr/sbin/
newins VBoxService vboxguest-service
fperms 0755 /usr/sbin/vboxguest-service
insinto /usr/bin
doins VBoxControl
fperms 0755 /usr/bin/VBoxControl
# VBoxClient user service and xrandr wrapper
if use gui ; then
doins VBoxClient
fperms 0755 /usr/bin/VBoxClient
doins VBoxDRMClient
fperms 4755 /usr/bin/VBoxDRMClient
pushd "${S}"/src/VBox/Additions/x11/Installer &>/dev/null || die
newins 98vboxadd-xclient VBoxClient-all
fperms 0755 /usr/bin/VBoxClient-all
popd &>/dev/null || die
fi
# udev rule for vboxdrv
local udev_rules_dir="/lib/udev/rules.d"
dodir ${udev_rules_dir}
echo 'KERNEL=="vboxguest", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
>> "${ED}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
|| die
echo 'KERNEL=="vboxuser", OWNER="vboxguest", GROUP="vboxguest", MODE="0660"' \
>> "${ED}/${udev_rules_dir}/60-virtualbox-guest-additions.rules" \
|| die
# VBoxClient autostart file
insinto /etc/xdg/autostart
doins "${FILESDIR}"/vboxclient.desktop
# sample xorg.conf
dodoc "${FILESDIR}"/xorg.conf.vbox
docompress -x "${ED}"/usr/share/doc/${PF}/xorg.conf.vbox
systemd_dounit "${FILESDIR}/${PN}.service"
}
pkg_postinst() {
linux-mod-r1_pkg_postinst
udev_reload
if ! use gui ; then
elog "use flag gui is off, enable it to install the"
elog "X Window System video driver."
fi
elog ""
elog "Please add users to the \"vboxguest\" group so they can"
elog "benefit from seamless mode, auto-resize and clipboard."
elog ""
elog "The vboxsf group has been added to make automount services work."
elog "These services are part of the shared folders support."
elog ""
elog "Please add:"
elog "/etc/init.d/${PN}"
elog "to the default runlevel in order to start"
elog "needed services."
elog "To use the VirtualBox X driver, use the following"
elog "file as your /etc/X11/xorg.conf:"
elog " /usr/share/doc/${PF}/xorg.conf.vbox"
elog ""
elog "An autostart .desktop file has been installed to start"
elog "VBoxClient in desktop sessions."
elog ""
elog "You can mount shared folders with:"
elog " mount -t vboxsf <shared_folder_name> <mount_point>"
elog ""
elog "Warning:"
elog "this ebuild is only needed if you are running gentoo"
elog "inside a VirtualBox Virtual Machine, you don't need"
elog "it to run VirtualBox itself."
elog ""
}
pkg_postrm() {
udev_reload
}