From a78577fbd0ffe52d67a118232bc88a12f39b0917 Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Tue, 21 Jun 2022 23:15:30 +0800 Subject: [PATCH] ksmbd: fixes build on kernel 5.15.52+ Fixes: #9691, #9695 --- package/kernel/ksmbd/Makefile | 3 -- .../patches/02-fixes-mapping-helpers.patch | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 package/kernel/ksmbd/patches/02-fixes-mapping-helpers.patch diff --git a/package/kernel/ksmbd/Makefile b/package/kernel/ksmbd/Makefile index 0f7964455..f1a762d7b 100644 --- a/package/kernel/ksmbd/Makefile +++ b/package/kernel/ksmbd/Makefile @@ -14,9 +14,6 @@ PKG_LICENSE_FILES:=COPYING include $(INCLUDE_DIR)/kernel.mk include $(INCLUDE_DIR)/package.mk -TAR_OPTIONS+= --strip-components 1 -TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS) - define KernelPackage/fs-ksmbd SUBMENU:=Filesystems TITLE:=SMB kernel server support diff --git a/package/kernel/ksmbd/patches/02-fixes-mapping-helpers.patch b/package/kernel/ksmbd/patches/02-fixes-mapping-helpers.patch new file mode 100644 index 000000000..7c4df3162 --- /dev/null +++ b/package/kernel/ksmbd/patches/02-fixes-mapping-helpers.patch @@ -0,0 +1,44 @@ +--- a/smbacl.c ++++ b/smbacl.c +@@ -281,7 +281,8 @@ static int sid_to_id(struct user_namespace *user_ns, + uid_t id; + + id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]); +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \ ++ (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) + uid = mapped_kuid_user(user_ns, &init_user_ns, KUIDT_INIT(id)); + #else + /* +@@ -304,7 +305,8 @@ static int sid_to_id(struct user_namespace *user_ns, + gid_t id; + + id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]); +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \ ++ (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) + gid = mapped_kgid_user(user_ns, &init_user_ns, KGIDT_INIT(id)); + #else + /* +--- a/smbacl.h ++++ b/smbacl.h +@@ -221,7 +221,8 @@ static inline uid_t posix_acl_uid_translate(struct user_namespace *mnt_userns, + kuid_t kuid; + + /* If this is an idmapped mount, apply the idmapping. */ +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \ ++ (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) + kuid = mapped_kuid_fs(mnt_userns, &init_user_ns, pace->e_uid); + #else + kuid = kuid_into_mnt(mnt_userns, pace->e_uid); +@@ -241,7 +242,8 @@ static inline gid_t posix_acl_gid_translate(struct user_namespace *mnt_userns, + kgid_t kgid; + + /* If this is an idmapped mount, apply the idmapping. */ +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \ ++ (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)) + kgid = mapped_kgid_fs(mnt_userns, &init_user_ns, pace->e_gid); + #else + kgid = kgid_into_mnt(mnt_userns, pace->e_gid);