ksmbd: fix compile on kernel 5.15.52+
[openwrt/openwrt.git] / package / kernel / ksmbd / patches / 10-fix-build-on-kernel-5.15.52-or-higher.patch
1 From 98bc509f92cccedd7d51d5ebadc424e2d7f5cbb4 Mon Sep 17 00:00:00 2001
2 From: Chukun Pan <amadeus@jmu.edu.cn>
3 Date: Tue, 5 Jul 2022 15:20:10 +0800
4 Subject: [PATCH] ksmbd: fixes build on kernel 5.15.52 or higher
5
6 The 5.15.52 kernel downported two commits "fs: remove unused low-level
7 mapping helpers" and "fs: use low-level mapping helpers", which broken
8 the compilation[1]. This commit fixed it.
9
10 1. https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.15.52
11
12 Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
13 Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
14 ---
15 smbacl.c | 6 ++++--
16 smbacl.h | 6 ++++--
17 2 files changed, 8 insertions(+), 4 deletions(-)
18
19 diff --git a/smbacl.c b/smbacl.c
20 index 275e357..19c682a 100644
21 --- a/smbacl.c
22 +++ b/smbacl.c
23 @@ -281,7 +281,8 @@ static int sid_to_id(struct user_namespace *user_ns,
24 uid_t id;
25
26 id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
27 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
28 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \
29 + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0))
30 uid = mapped_kuid_user(user_ns, &init_user_ns, KUIDT_INIT(id));
31 #else
32 /*
33 @@ -304,7 +305,8 @@ static int sid_to_id(struct user_namespace *user_ns,
34 gid_t id;
35
36 id = le32_to_cpu(psid->sub_auth[psid->num_subauth - 1]);
37 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
38 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \
39 + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0))
40 gid = mapped_kgid_user(user_ns, &init_user_ns, KGIDT_INIT(id));
41 #else
42 /*
43 diff --git a/smbacl.h b/smbacl.h
44 index f2bcdb4..7368bf4 100644
45 --- a/smbacl.h
46 +++ b/smbacl.h
47 @@ -221,7 +221,8 @@ static inline uid_t posix_acl_uid_translate(struct user_namespace *mnt_userns,
48 kuid_t kuid;
49
50 /* If this is an idmapped mount, apply the idmapping. */
51 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
52 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \
53 + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0))
54 kuid = mapped_kuid_fs(mnt_userns, &init_user_ns, pace->e_uid);
55 #else
56 kuid = kuid_into_mnt(mnt_userns, pace->e_uid);
57 @@ -241,7 +242,8 @@ static inline gid_t posix_acl_gid_translate(struct user_namespace *mnt_userns,
58 kgid_t kgid;
59
60 /* If this is an idmapped mount, apply the idmapping. */
61 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0)
62 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 17, 0) || \
63 + (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 52) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0))
64 kgid = mapped_kgid_fs(mnt_userns, &init_user_ns, pace->e_gid);
65 #else
66 kgid = kgid_into_mnt(mnt_userns, pace->e_gid);
67 --
68 2.36.1
69