Skip to content

Commit 5c36498

Browse files
committed
Merge tag 'lsm-pr-20240923' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm
Pull LSM fixes from Paul Moore: - Add a missing security_mmap_file() check to the remap_file_pages() syscall - Properly reference the SELinux and Smack LSM blobs in the security_watch_key() LSM hook - Fix a random IPE selftest crash caused by a missing list terminator in the test * tag 'lsm-pr-20240923' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm: ipe: Add missing terminator to list of unit tests selinux,smack: properly reference the LSM blob in security_watch_key() mm: call the security_mmap_file() LSM hook in remap_file_pages()
2 parents abf2050 + f89722f commit 5c36498

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

mm/mmap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,8 +1689,12 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
16891689
flags |= MAP_LOCKED;
16901690

16911691
file = get_file(vma->vm_file);
1692+
ret = security_mmap_file(vma->vm_file, prot, flags);
1693+
if (ret)
1694+
goto out_fput;
16921695
ret = do_mmap(vma->vm_file, start, size,
16931696
prot, flags, 0, pgoff, &populate, NULL);
1697+
out_fput:
16941698
fput(file);
16951699
out:
16961700
mmap_write_unlock(mm);

security/ipe/policy_tests.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ static void ipe_parser_widestring_test(struct kunit *test)
286286
static struct kunit_case ipe_parser_test_cases[] = {
287287
KUNIT_CASE_PARAM(ipe_parser_unsigned_test, ipe_policies_gen_params),
288288
KUNIT_CASE(ipe_parser_widestring_test),
289+
{ }
289290
};
290291

291292
static struct kunit_suite ipe_parser_test_suite = {

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6735,7 +6735,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
67356735
#ifdef CONFIG_KEY_NOTIFICATIONS
67366736
static int selinux_watch_key(struct key *key)
67376737
{
6738-
struct key_security_struct *ksec = key->security;
6738+
struct key_security_struct *ksec = selinux_key(key);
67396739
u32 sid = current_sid();
67406740

67416741
return avc_has_perm(sid, ksec->sid, SECCLASS_KEY, KEY__VIEW, NULL);

security/smack/smack_lsm.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,16 +4629,9 @@ static int smack_watch_key(struct key *key)
46294629
{
46304630
struct smk_audit_info ad;
46314631
struct smack_known *tkp = smk_of_current();
4632+
struct smack_known **blob = smack_key(key);
46324633
int rc;
46334634

4634-
if (key == NULL)
4635-
return -EINVAL;
4636-
/*
4637-
* If the key hasn't been initialized give it access so that
4638-
* it may do so.
4639-
*/
4640-
if (key->security == NULL)
4641-
return 0;
46424635
/*
46434636
* This should not occur
46444637
*/
@@ -4653,8 +4646,8 @@ static int smack_watch_key(struct key *key)
46534646
ad.a.u.key_struct.key = key->serial;
46544647
ad.a.u.key_struct.key_desc = key->description;
46554648
#endif
4656-
rc = smk_access(tkp, key->security, MAY_READ, &ad);
4657-
rc = smk_bu_note("key watch", tkp, key->security, MAY_READ, rc);
4649+
rc = smk_access(tkp, *blob, MAY_READ, &ad);
4650+
rc = smk_bu_note("key watch", tkp, *blob, MAY_READ, rc);
46584651
return rc;
46594652
}
46604653
#endif /* CONFIG_KEY_NOTIFICATIONS */

0 commit comments

Comments
 (0)