Skip to content

Commit 8e4672d

Browse files
KhadijaKamranpcmoore
authored andcommitted
lsm: constify the 'file' parameter in security_binder_transfer_file()
SELinux registers the implementation for the "binder_transfer_file" hook. Looking at the function implementation we observe that the parameter "file" is not changing. Mark the "file" parameter of LSM hook security_binder_transfer_file() as "const" since it will not be changing in the LSM hook. Signed-off-by: Khadija Kamran <kamrankhadijadj@gmail.com> [PM: subject line whitespace fix] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 6672efb commit 8e4672d

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ LSM_HOOK(int, 0, binder_transaction, const struct cred *from,
3232
LSM_HOOK(int, 0, binder_transfer_binder, const struct cred *from,
3333
const struct cred *to)
3434
LSM_HOOK(int, 0, binder_transfer_file, const struct cred *from,
35-
const struct cred *to, struct file *file)
35+
const struct cred *to, const struct file *file)
3636
LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
3737
unsigned int mode)
3838
LSM_HOOK(int, 0, ptrace_traceme, struct task_struct *parent)

include/linux/security.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ int security_binder_transaction(const struct cred *from,
269269
int security_binder_transfer_binder(const struct cred *from,
270270
const struct cred *to);
271271
int security_binder_transfer_file(const struct cred *from,
272-
const struct cred *to, struct file *file);
272+
const struct cred *to, const struct file *file);
273273
int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
274274
int security_ptrace_traceme(struct task_struct *parent);
275275
int security_capget(const struct task_struct *target,
@@ -538,7 +538,7 @@ static inline int security_binder_transfer_binder(const struct cred *from,
538538

539539
static inline int security_binder_transfer_file(const struct cred *from,
540540
const struct cred *to,
541-
struct file *file)
541+
const struct file *file)
542542
{
543543
return 0;
544544
}

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ int security_binder_transfer_binder(const struct cred *from,
841841
* Return: Returns 0 if permission is granted.
842842
*/
843843
int security_binder_transfer_file(const struct cred *from,
844-
const struct cred *to, struct file *file)
844+
const struct cred *to, const struct file *file)
845845
{
846846
return call_int_hook(binder_transfer_file, 0, from, to, file);
847847
}

security/selinux/hooks.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,7 +1691,7 @@ static inline int file_path_has_perm(const struct cred *cred,
16911691
}
16921692

16931693
#ifdef CONFIG_BPF_SYSCALL
1694-
static int bpf_fd_pass(struct file *file, u32 sid);
1694+
static int bpf_fd_pass(const struct file *file, u32 sid);
16951695
#endif
16961696

16971697
/* Check whether a task can use an open file descriptor to
@@ -1952,7 +1952,7 @@ static inline u32 file_mask_to_av(int mode, int mask)
19521952
}
19531953

19541954
/* Convert a Linux file to an access vector. */
1955-
static inline u32 file_to_av(struct file *file)
1955+
static inline u32 file_to_av(const struct file *file)
19561956
{
19571957
u32 av = 0;
19581958

@@ -2027,7 +2027,7 @@ static int selinux_binder_transfer_binder(const struct cred *from,
20272027

20282028
static int selinux_binder_transfer_file(const struct cred *from,
20292029
const struct cred *to,
2030-
struct file *file)
2030+
const struct file *file)
20312031
{
20322032
u32 sid = cred_sid(to);
20332033
struct file_security_struct *fsec = selinux_file(file);
@@ -6718,7 +6718,7 @@ static u32 bpf_map_fmode_to_av(fmode_t fmode)
67186718
* access the bpf object and that's why we have to add this additional check in
67196719
* selinux_file_receive and selinux_binder_transfer_files.
67206720
*/
6721-
static int bpf_fd_pass(struct file *file, u32 sid)
6721+
static int bpf_fd_pass(const struct file *file, u32 sid)
67226722
{
67236723
struct bpf_security_struct *bpfsec;
67246724
struct bpf_prog *prog;

0 commit comments

Comments
 (0)