Skip to content

Commit 25cc71d

Browse files
KhadijaKamranpcmoore
authored andcommitted
lsm: constify 'sb' parameter in security_quotactl()
SELinux registers the implementation for the "quotactl" hook. Looking at the function implementation we observe that the parameter "sb" is not changing. Mark the "sb" parameter of LSM hook security_quotactl() as "const" since it will not be changing in the LSM hook. Signed-off-by: Khadija Kamran <kamrankhadijadj@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 0bb80ec commit 25cc71d

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ LSM_HOOK(int, 0, capset, struct cred *new, const struct cred *old,
4343
const kernel_cap_t *permitted)
4444
LSM_HOOK(int, 0, capable, const struct cred *cred, struct user_namespace *ns,
4545
int cap, unsigned int opts)
46-
LSM_HOOK(int, 0, quotactl, int cmds, int type, int id, struct super_block *sb)
46+
LSM_HOOK(int, 0, quotactl, int cmds, int type, int id, const struct super_block *sb)
4747
LSM_HOOK(int, 0, quota_on, struct dentry *dentry)
4848
LSM_HOOK(int, 0, syslog, int type)
4949
LSM_HOOK(int, 0, settime, const struct timespec64 *ts,

include/linux/security.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ int security_capable(const struct cred *cred,
284284
struct user_namespace *ns,
285285
int cap,
286286
unsigned int opts);
287-
int security_quotactl(int cmds, int type, int id, struct super_block *sb);
287+
int security_quotactl(int cmds, int type, int id, const struct super_block *sb);
288288
int security_quota_on(struct dentry *dentry);
289289
int security_syslog(int type);
290290
int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
@@ -581,7 +581,7 @@ static inline int security_capable(const struct cred *cred,
581581
}
582582

583583
static inline int security_quotactl(int cmds, int type, int id,
584-
struct super_block *sb)
584+
const struct super_block *sb)
585585
{
586586
return 0;
587587
}

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ int security_capable(const struct cred *cred,
957957
*
958958
* Return: Returns 0 if permission is granted.
959959
*/
960-
int security_quotactl(int cmds, int type, int id, struct super_block *sb)
960+
int security_quotactl(int cmds, int type, int id, const struct super_block *sb)
961961
{
962962
return call_int_hook(quotactl, 0, cmds, type, id, sb);
963963
}

security/selinux/hooks.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ static inline int may_rename(struct inode *old_dir,
19371937

19381938
/* Check whether a task can perform a filesystem operation. */
19391939
static int superblock_has_perm(const struct cred *cred,
1940-
struct super_block *sb,
1940+
const struct super_block *sb,
19411941
u32 perms,
19421942
struct common_audit_data *ad)
19431943
{
@@ -2139,7 +2139,7 @@ static int selinux_capable(const struct cred *cred, struct user_namespace *ns,
21392139
return cred_has_capability(cred, cap, opts, ns == &init_user_ns);
21402140
}
21412141

2142-
static int selinux_quotactl(int cmds, int type, int id, struct super_block *sb)
2142+
static int selinux_quotactl(int cmds, int type, int id, const struct super_block *sb)
21432143
{
21442144
const struct cred *cred = current_cred();
21452145
int rc = 0;

0 commit comments

Comments
 (0)