hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/kernel/capability.c
....@@ -93,9 +93,7 @@
9393 break;
9494 case _LINUX_CAPABILITY_VERSION_2:
9595 warn_deprecated_v2();
96
- /*
97
- * fall through - v3 is otherwise equivalent to v2.
98
- */
96
+ fallthrough; /* v3 is otherwise equivalent to v2 */
9997 case _LINUX_CAPABILITY_VERSION_3:
10098 *tocopy = _LINUX_CAPABILITY_U32S_3;
10199 break;
....@@ -418,6 +416,25 @@
418416 EXPORT_SYMBOL(ns_capable_noaudit);
419417
420418 /**
419
+ * ns_capable_setid - Determine if the current task has a superior capability
420
+ * in effect, while signalling that this check is being done from within a
421
+ * setid or setgroups syscall.
422
+ * @ns: The usernamespace we want the capability in
423
+ * @cap: The capability to be tested for
424
+ *
425
+ * Return true if the current task has the given superior capability currently
426
+ * available for use, false if not.
427
+ *
428
+ * This sets PF_SUPERPRIV on the task if the capability is available on the
429
+ * assumption that it's about to be used.
430
+ */
431
+bool ns_capable_setid(struct user_namespace *ns, int cap)
432
+{
433
+ return ns_capable_common(ns, cap, CAP_OPT_INSETID);
434
+}
435
+EXPORT_SYMBOL(ns_capable_setid);
436
+
437
+/**
421438 * capable - Determine if the current task has a superior capability in effect
422439 * @cap: The capability to be tested for
423440 *