From: Seung-Woo Kim Date: Tue, 27 Feb 2024 07:24:12 +0000 (+0900) Subject: kdbus: use u64 capability for v6.3 or later version X-Git-Tag: accepted/tizen/unified/20240306.011949~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e59920a88bb1fd382975611cd1366ab8f86ea562;p=platform%2Fkernel%2Flinux-tizen-modules-source.git kdbus: use u64 capability for v6.3 or later version Since the commit f122a08b197d ("capability: just use a 'u64' instead of a 'u32[2]' array") of v6.3, not anymore u32[2] array capability. Use u64 capability for v6.3 or later kernel version. Change-Id: Ibb1dbdeafade0489c6c546ff1cace78e76add2bd Signed-off-by: Seung-Woo Kim --- diff --git a/kernel/kdbus/metadata.c b/kernel/kdbus/metadata.c index 1b12bba..30471cb 100644 --- a/kernel/kdbus/metadata.c +++ b/kernel/kdbus/metadata.c @@ -131,9 +131,13 @@ struct kdbus_meta_conn { /* fixed size equivalent of "kdbus_caps" */ struct kdbus_meta_caps { u32 last_cap; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) + kernel_cap_t cap_sets[4]; +#else struct { u32 caps[_KERNEL_CAPABILITY_U32S]; } set[4]; +#endif }; /** @@ -765,6 +769,28 @@ static void kdbus_meta_export_caps(struct kdbus_meta_caps *out, out->last_cap = CAP_LAST_CAP; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) + if (parent) { + out->cap_sets[0] = cred->cap_inheritable; + out->cap_sets[1] = cred->cap_permitted; + out->cap_sets[2] = cred->cap_effective; + out->cap_sets[3] = cred->cap_bset; + } else if (owner) { + out->cap_sets[0] = CAP_EMPTY_SET; + out->cap_sets[1] = CAP_FULL_SET; + out->cap_sets[2] = CAP_FULL_SET; + out->cap_sets[3] = CAP_FULL_SET; + } else { + out->cap_sets[0] = CAP_EMPTY_SET; + out->cap_sets[1] = CAP_EMPTY_SET; + out->cap_sets[2] = CAP_EMPTY_SET; + out->cap_sets[3] = CAP_EMPTY_SET; + } + + /* clear unused bits */ + for (i = 0; i < 4; i++) + out->cap_sets[i].val &= CAP_VALID_MASK; +#else CAP_FOR_EACH_U32(i) { if (parent) { out->set[0].caps[i] = cred->cap_inheritable.cap[i]; @@ -788,6 +814,7 @@ static void kdbus_meta_export_caps(struct kdbus_meta_caps *out, for (i = 0; i < 4; i++) out->set[i].caps[CAP_TO_INDEX(CAP_LAST_CAP)] &= CAP_LAST_U32_VALID_MASK; +#endif } /* This is equivalent to from_kuid_munged(), but maps INVALID_UID to itself */