Commit a135ce44 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull selinux updates from Paul Moore:
 "Nothing too significant, but five SELinux patches for v5.17 that do
  the following:

   - Harden the code through additional use of the struct_size() macro

   - Plug some memory leaks

   - Clean up the code via removal of the security_add_mnt_opt() LSM
     hook and minor tweaks to selinux_add_opt()

   - Rename security_task_getsecid_subj() to better reflect its actual
     behavior/use - now called security_current_getsecid_subj()"

* tag 'selinux-pr-20220110' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
  selinux: minor tweaks to selinux_add_opt()
  selinux: fix potential memleak in selinux_add_opt()
  security,selinux: remove security_add_mnt_opt()
  selinux: Use struct_size() helper in kmalloc()
  lsm: security_task_getsecid_subj() -> security_current_getsecid_subj()
parents dabd40ec 6cd9d4b9
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -78,8 +78,6 @@ LSM_HOOK(int, 0, sb_set_mnt_opts, struct super_block *sb, void *mnt_opts,
LSM_HOOK(int, 0, sb_clone_mnt_opts, const struct super_block *oldsb,
	 struct super_block *newsb, unsigned long kern_flags,
	 unsigned long *set_kern_flags)
LSM_HOOK(int, 0, sb_add_mnt_opt, const char *option, const char *val,
	 int len, void **mnt_opts)
LSM_HOOK(int, 0, move_mount, const struct path *from_path,
	 const struct path *to_path)
LSM_HOOK(int, 0, dentry_init_security, struct dentry *dentry,
@@ -206,8 +204,7 @@ LSM_HOOK(int, 0, task_fix_setgid, struct cred *new, const struct cred * old,
LSM_HOOK(int, 0, task_setpgid, struct task_struct *p, pid_t pgid)
LSM_HOOK(int, 0, task_getpgid, struct task_struct *p)
LSM_HOOK(int, 0, task_getsid, struct task_struct *p)
LSM_HOOK(void, LSM_RET_VOID, task_getsecid_subj,
	 struct task_struct *p, u32 *secid)
LSM_HOOK(void, LSM_RET_VOID, current_getsecid_subj, u32 *secid)
LSM_HOOK(void, LSM_RET_VOID, task_getsecid_obj,
	 struct task_struct *p, u32 *secid)
LSM_HOOK(int, 0, task_setnice, struct task_struct *p, int nice)
+3 −7
Original line number Diff line number Diff line
@@ -180,8 +180,6 @@
 *	Copy all security options from a given superblock to another
 *	@oldsb old superblock which contain information to clone
 *	@newsb new superblock which needs filled in
 * @sb_add_mnt_opt:
 * 	Add one mount @option to @mnt_opts.
 * @sb_parse_opts_str:
 *	Parse a string of security data filling in the opts structure
 *	@options string containing all mount options known by the LSM
@@ -719,11 +717,9 @@
 *	@p.
 *	@p contains the task_struct for the process.
 *	Return 0 if permission is granted.
 * @task_getsecid_subj:
 *	Retrieve the subjective security identifier of the task_struct in @p
 *	and return it in @secid.  Special care must be taken to ensure that @p
 *	is the either the "current" task, or the caller has exclusive access
 *	to @p.
 * @current_getsecid_subj:
 *	Retrieve the subjective security identifier of the current task and
 *	return it in @secid.
 *	In case of failure, @secid will be set to zero.
 * @task_getsecid_obj:
 *	Retrieve the objective security identifier of the task_struct in @p
+2 −10
Original line number Diff line number Diff line
@@ -313,8 +313,6 @@ int security_sb_clone_mnt_opts(const struct super_block *oldsb,
				struct super_block *newsb,
				unsigned long kern_flags,
				unsigned long *set_kern_flags);
int security_add_mnt_opt(const char *option, const char *val,
				int len, void **mnt_opts);
int security_move_mount(const struct path *from_path, const struct path *to_path);
int security_dentry_init_security(struct dentry *dentry, int mode,
				  const struct qstr *name,
@@ -418,7 +416,7 @@ int security_task_fix_setgid(struct cred *new, const struct cred *old,
int security_task_setpgid(struct task_struct *p, pid_t pgid);
int security_task_getpgid(struct task_struct *p);
int security_task_getsid(struct task_struct *p);
void security_task_getsecid_subj(struct task_struct *p, u32 *secid);
void security_current_getsecid_subj(u32 *secid);
void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
int security_task_setnice(struct task_struct *p, int nice);
int security_task_setioprio(struct task_struct *p, int ioprio);
@@ -711,12 +709,6 @@ static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
	return 0;
}

static inline int security_add_mnt_opt(const char *option, const char *val,
					int len, void **mnt_opts)
{
	return 0;
}

static inline int security_move_mount(const struct path *from_path,
				      const struct path *to_path)
{
@@ -1119,7 +1111,7 @@ static inline int security_task_getsid(struct task_struct *p)
	return 0;
}

static inline void security_task_getsecid_subj(struct task_struct *p, u32 *secid)
static inline void security_current_getsecid_subj(u32 *secid)
{
	*secid = 0;
}
+2 −2
Original line number Diff line number Diff line
@@ -2131,7 +2131,7 @@ int audit_log_task_context(struct audit_buffer *ab)
	int error;
	u32 sid;

	security_task_getsecid_subj(current, &sid);
	security_current_getsecid_subj(&sid);
	if (!sid)
		return 0;

@@ -2352,7 +2352,7 @@ int audit_signal_info(int sig, struct task_struct *t)
			audit_sig_uid = auid;
		else
			audit_sig_uid = uid;
		security_task_getsecid_subj(current, &audit_sig_sid);
		security_current_getsecid_subj(&audit_sig_sid);
	}

	return audit_signal_info_syscall(t);
+1 −2
Original line number Diff line number Diff line
@@ -1368,8 +1368,7 @@ int audit_filter(int msgtype, unsigned int listtype)
			case AUDIT_SUBJ_SEN:
			case AUDIT_SUBJ_CLR:
				if (f->lsm_rule) {
					security_task_getsecid_subj(current,
								    &sid);
					security_current_getsecid_subj(&sid);
					result = security_audit_rule_match(sid,
						   f->type, f->op, f->lsm_rule);
				}
Loading