]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/security-selinux-fix-security_lsm_native_labels-on-reused-superblock.patch
Linux 4.14.108
[thirdparty/kernel/stable-queue.git] / queue-4.19 / security-selinux-fix-security_lsm_native_labels-on-reused-superblock.patch
1 From 3815a245b50124f0865415dcb606a034e97494d4 Mon Sep 17 00:00:00 2001
2 From: "J. Bruce Fields" <bfields@redhat.com>
3 Date: Tue, 5 Mar 2019 16:17:58 -0500
4 Subject: security/selinux: fix SECURITY_LSM_NATIVE_LABELS on reused superblock
5
6 From: J. Bruce Fields <bfields@redhat.com>
7
8 commit 3815a245b50124f0865415dcb606a034e97494d4 upstream.
9
10 In the case when we're reusing a superblock, selinux_sb_clone_mnt_opts()
11 fails to set set_kern_flags, with the result that
12 nfs_clone_sb_security() incorrectly clears NFS_CAP_SECURITY_LABEL.
13
14 The result is that if you mount the same NFS filesystem twice, NFS
15 security labels are turned off, even if they would work fine if you
16 mounted the filesystem only once.
17
18 ("fixes" may be not exactly the right tag, it may be more like
19 "fixed-other-cases-but-missed-this-one".)
20
21 Cc: Scott Mayhew <smayhew@redhat.com>
22 Cc: stable@vger.kernel.org
23 Fixes: 0b4d3452b8b4 "security/selinux: allow security_sb_clone_mnt_opts..."
24 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
25 Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
26 Signed-off-by: Paul Moore <paul@paul-moore.com>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
28
29 ---
30 security/selinux/hooks.c | 5 ++++-
31 1 file changed, 4 insertions(+), 1 deletion(-)
32
33 --- a/security/selinux/hooks.c
34 +++ b/security/selinux/hooks.c
35 @@ -1034,8 +1034,11 @@ static int selinux_sb_clone_mnt_opts(con
36 BUG_ON(!(oldsbsec->flags & SE_SBINITIALIZED));
37
38 /* if fs is reusing a sb, make sure that the contexts match */
39 - if (newsbsec->flags & SE_SBINITIALIZED)
40 + if (newsbsec->flags & SE_SBINITIALIZED) {
41 + if ((kern_flags & SECURITY_LSM_NATIVE_LABELS) && !set_context)
42 + *set_kern_flags |= SECURITY_LSM_NATIVE_LABELS;
43 return selinux_cmp_sb_context(oldsb, newsb);
44 + }
45
46 mutex_lock(&newsbsec->lock);
47