Skip to content

Commit acd3d28

Browse files
committed
Merge tag 'fixes-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security layer fixes from James Morris: "Miscellaneous minor fixes" * tag 'fixes-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: security: commoncap: clean up kernel-doc comments security: commoncap: fix -Wstringop-overread warning
2 parents 1e9599d + 049ae60 commit acd3d28

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

security/commoncap.c

+34-18
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static void warn_setuid_and_fcaps_mixed(const char *fname)
5050
/**
5151
* cap_capable - Determine whether a task has a particular effective capability
5252
* @cred: The credentials to use
53-
* @ns: The user namespace in which we need the capability
53+
* @targ_ns: The user namespace in which we need the capability
5454
* @cap: The capability to check for
5555
* @opts: Bitmask of options defined in include/linux/security.h
5656
*
@@ -289,7 +289,7 @@ int cap_capset(struct cred *new,
289289
* affects the security markings on that inode, and if it is, should
290290
* inode_killpriv() be invoked or the change rejected.
291291
*
292-
* Returns 1 if security.capability has a value, meaning inode_killpriv()
292+
* Return: 1 if security.capability has a value, meaning inode_killpriv()
293293
* is required, 0 otherwise, meaning inode_killpriv() is not required.
294294
*/
295295
int cap_inode_need_killpriv(struct dentry *dentry)
@@ -315,7 +315,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
315315
* permissions. On non-idmapped mounts or if permission checking is to be
316316
* performed on the raw inode simply passs init_user_ns.
317317
*
318-
* Returns 0 if successful, -ve on error.
318+
* Return: 0 if successful, -ve on error.
319319
*/
320320
int cap_inode_killpriv(struct user_namespace *mnt_userns, struct dentry *dentry)
321321
{
@@ -400,7 +400,7 @@ int cap_inode_getsecurity(struct user_namespace *mnt_userns,
400400
&tmpbuf, size, GFP_NOFS);
401401
dput(dentry);
402402

403-
if (ret < 0)
403+
if (ret < 0 || !tmpbuf)
404404
return ret;
405405

406406
fs_ns = inode->i_sb->s_user_ns;
@@ -532,7 +532,7 @@ static bool validheader(size_t size, const struct vfs_cap_data *cap)
532532
* permissions. On non-idmapped mounts or if permission checking is to be
533533
* performed on the raw inode simply passs init_user_ns.
534534
*
535-
* If all is ok, we return the new size, on error return < 0.
535+
* Return: On success, return the new size; on error, return < 0.
536536
*/
537537
int cap_convert_nscap(struct user_namespace *mnt_userns, struct dentry *dentry,
538538
const void **ivalue, size_t size)
@@ -881,7 +881,9 @@ static inline bool nonroot_raised_pE(struct cred *new, const struct cred *old,
881881
*
882882
* Set up the proposed credentials for a new execution context being
883883
* constructed by execve(). The proposed creds in @bprm->cred is altered,
884-
* which won't take effect immediately. Returns 0 if successful, -ve on error.
884+
* which won't take effect immediately.
885+
*
886+
* Return: 0 if successful, -ve on error.
885887
*/
886888
int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file)
887889
{
@@ -1117,7 +1119,9 @@ static inline void cap_emulate_setxuid(struct cred *new, const struct cred *old)
11171119
* @flags: Indications of what has changed
11181120
*
11191121
* Fix up the results of setuid() call before the credential changes are
1120-
* actually applied, returning 0 to grant the changes, -ve to deny them.
1122+
* actually applied.
1123+
*
1124+
* Return: 0 to grant the changes, -ve to deny them.
11211125
*/
11221126
int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags)
11231127
{
@@ -1187,33 +1191,39 @@ static int cap_safe_nice(struct task_struct *p)
11871191
* @p: The task to affect
11881192
*
11891193
* Detemine if the requested scheduler policy change is permitted for the
1190-
* specified task, returning 0 if permission is granted, -ve if denied.
1194+
* specified task.
1195+
*
1196+
* Return: 0 if permission is granted, -ve if denied.
11911197
*/
11921198
int cap_task_setscheduler(struct task_struct *p)
11931199
{
11941200
return cap_safe_nice(p);
11951201
}
11961202

11971203
/**
1198-
* cap_task_ioprio - Detemine if I/O priority change is permitted
1204+
* cap_task_setioprio - Detemine if I/O priority change is permitted
11991205
* @p: The task to affect
12001206
* @ioprio: The I/O priority to set
12011207
*
12021208
* Detemine if the requested I/O priority change is permitted for the specified
1203-
* task, returning 0 if permission is granted, -ve if denied.
1209+
* task.
1210+
*
1211+
* Return: 0 if permission is granted, -ve if denied.
12041212
*/
12051213
int cap_task_setioprio(struct task_struct *p, int ioprio)
12061214
{
12071215
return cap_safe_nice(p);
12081216
}
12091217

12101218
/**
1211-
* cap_task_ioprio - Detemine if task priority change is permitted
1219+
* cap_task_setnice - Detemine if task priority change is permitted
12121220
* @p: The task to affect
12131221
* @nice: The nice value to set
12141222
*
12151223
* Detemine if the requested task priority change is permitted for the
1216-
* specified task, returning 0 if permission is granted, -ve if denied.
1224+
* specified task.
1225+
*
1226+
* Return: 0 if permission is granted, -ve if denied.
12171227
*/
12181228
int cap_task_setnice(struct task_struct *p, int nice)
12191229
{
@@ -1243,12 +1253,15 @@ static int cap_prctl_drop(unsigned long cap)
12431253
/**
12441254
* cap_task_prctl - Implement process control functions for this security module
12451255
* @option: The process control function requested
1246-
* @arg2, @arg3, @arg4, @arg5: The argument data for this function
1256+
* @arg2: The argument data for this function
1257+
* @arg3: The argument data for this function
1258+
* @arg4: The argument data for this function
1259+
* @arg5: The argument data for this function
12471260
*
12481261
* Allow process control functions (sys_prctl()) to alter capabilities; may
12491262
* also deny access to other functions not otherwise implemented here.
12501263
*
1251-
* Returns 0 or +ve on success, -ENOSYS if this function is not implemented
1264+
* Return: 0 or +ve on success, -ENOSYS if this function is not implemented
12521265
* here, other -ve on error. If -ENOSYS is returned, sys_prctl() and other LSM
12531266
* modules will consider performing the function.
12541267
*/
@@ -1383,7 +1396,9 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
13831396
* @pages: The size of the mapping
13841397
*
13851398
* Determine whether the allocation of a new virtual mapping by the current
1386-
* task is permitted, returning 1 if permission is granted, 0 if not.
1399+
* task is permitted.
1400+
*
1401+
* Return: 1 if permission is granted, 0 if not.
13871402
*/
13881403
int cap_vm_enough_memory(struct mm_struct *mm, long pages)
13891404
{
@@ -1396,14 +1411,15 @@ int cap_vm_enough_memory(struct mm_struct *mm, long pages)
13961411
return cap_sys_admin;
13971412
}
13981413

1399-
/*
1414+
/**
14001415
* cap_mmap_addr - check if able to map given addr
14011416
* @addr: address attempting to be mapped
14021417
*
14031418
* If the process is attempting to map memory below dac_mmap_min_addr they need
14041419
* CAP_SYS_RAWIO. The other parameters to this function are unused by the
1405-
* capability security module. Returns 0 if this mapping should be allowed
1406-
* -EPERM if not.
1420+
* capability security module.
1421+
*
1422+
* Return: 0 if this mapping should be allowed or -EPERM if not.
14071423
*/
14081424
int cap_mmap_addr(unsigned long addr)
14091425
{

0 commit comments

Comments
 (0)