Skip to content

Commit 78fb88e

Browse files
committed
Merge tag 'caps-pr-20250327' of git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux
Pull capabilities update from Serge Hallyn: "This contains just one patch that removes a helper function whose last user (smack) stopped using it in 2018" * tag 'caps-pr-20250327' of git://git.kernel.org/pub/scm/linux/kernel/git/sergeh/linux: capability: Remove unused has_capability
2 parents a2d4f47 + 4ae89b1 commit 78fb88e

File tree

3 files changed

+5
-25
lines changed

3 files changed

+5
-25
lines changed

include/linux/capability.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ static inline kernel_cap_t cap_raise_nfsd_set(const kernel_cap_t a,
139139
}
140140

141141
#ifdef CONFIG_MULTIUSER
142-
extern bool has_capability(struct task_struct *t, int cap);
143142
extern bool has_ns_capability(struct task_struct *t,
144143
struct user_namespace *ns, int cap);
145144
extern bool has_capability_noaudit(struct task_struct *t, int cap);
@@ -150,10 +149,6 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
150149
extern bool ns_capable_noaudit(struct user_namespace *ns, int cap);
151150
extern bool ns_capable_setid(struct user_namespace *ns, int cap);
152151
#else
153-
static inline bool has_capability(struct task_struct *t, int cap)
154-
{
155-
return true;
156-
}
157152
static inline bool has_ns_capability(struct task_struct *t,
158153
struct user_namespace *ns, int cap)
159154
{

kernel/capability.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,22 +285,6 @@ bool has_ns_capability(struct task_struct *t,
285285
return (ret == 0);
286286
}
287287

288-
/**
289-
* has_capability - Does a task have a capability in init_user_ns
290-
* @t: The task in question
291-
* @cap: The capability to be tested for
292-
*
293-
* Return true if the specified task has the given superior capability
294-
* currently in effect to the initial user namespace, false if not.
295-
*
296-
* Note that this does not set PF_SUPERPRIV on the task.
297-
*/
298-
bool has_capability(struct task_struct *t, int cap)
299-
{
300-
return has_ns_capability(t, &init_user_ns, cap);
301-
}
302-
EXPORT_SYMBOL(has_capability);
303-
304288
/**
305289
* has_ns_capability_noaudit - Does a task have a capability (unaudited)
306290
* in a specific user ns.

security/commoncap.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ static inline int cap_capable_helper(const struct cred *cred,
115115
* Determine whether the nominated task has the specified capability amongst
116116
* its effective set, returning 0 if it does, -ve if it does not.
117117
*
118-
* NOTE WELL: cap_has_capability() cannot be used like the kernel's capable()
119-
* and has_capability() functions. That is, it has the reverse semantics:
120-
* cap_has_capability() returns 0 when a task has a capability, but the
121-
* kernel's capable() and has_capability() returns 1 for this case.
118+
* NOTE WELL: cap_capable() has reverse semantics to the capable() call
119+
* and friends. That is cap_capable() returns an int 0 when a task has
120+
* a capability, while the kernel's capable(), has_ns_capability(),
121+
* has_ns_capability_noaudit(), and has_capability_noaudit() return a
122+
* bool true (1) for this case.
122123
*/
123124
int cap_capable(const struct cred *cred, struct user_namespace *target_ns,
124125
int cap, unsigned int opts)

0 commit comments

Comments
 (0)