nfs: Don't assume we have a security structure
Subsystems (2)
PATCH 1/1 nfs: Don't assume we have a security structure
If the i_security field isn't set then security_dentry_init_security() won't initialize some of the values used by the security label. This causes my client to hit a BUG_ON() while encoding a label of size -2128927414.
I hit this bug while testing on a client without SELinux installed.
--- fs/nfs/nfs4proc.c | 3 +++ 1 file changed, 3 insertions(+)
fs/nfs/nfs4proc.c +3 -0
@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,if (nfs_server_capable (dir,NFS_CAP_SECURITY_LABEL ) ==0 )return NULL ; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )
Signature · 1 line
1.9.0
Could it be bad to do this when selinux is enabled? Could you do something based on selinux_is_enabled()?
-dros
Quoted 33 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,if (nfs_server_capable (dir,NFS_CAP_SECURITY_LABEL ) ==0 )return NULL ; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )Signature · 6 lines
1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +0
-0
fs/nfs/nfs4proc.c nfs4_label_init_security(struct inode *dir, struct dentry *dentry, · line 113
Quoted 9 lines
fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,if (nfs_server_capable (dir,NFS_CAP_SECURITY_LABEL ) ==0 )return NULL ; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )
Hi Anna,
This looks like a check that needs to be done by selinux_dentry_init_security() itself. The dir->i_security field is not something that NFS knows about. David, what needs to happen there when dentry->d_parent->i_security (a.k.a. dsec) is NULL?
_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
Quoted 32 lines · Trond Myklebust
Quoted 17 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c nfs4_label_init_security(struct inode *dir, struct dentry *dentry, · line 113
Quoted 9 lines
fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,if (nfs_server_capable (dir,NFS_CAP_SECURITY_LABEL ) ==0 )return NULL ; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )Hi Anna,
Quoted 3 lines
This looks like a check that needs to be done by
selinux_dentry_init_security()itself. Thedir->i_securityfield is not something that NFS knows about. David, what needs to happen there whendentry->d_parent->i_security(a.k.a. dsec) is NULL?
Oh, wait. I missed the bit about ‘without SELinux installed’. So the problem here is that you have a NFS client that does not have SELinux set up, but running against a server that is advertising NFSv4.2 with labeled NFS. Is that correct?
It looks to me as if cap_dentry_init_security() will indeed trigger this behaviour since it returns ‘0’ without doing anything to the label. As far as I can see, the right thing to do there is to return -EOPNOTSUPP, no?
_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
Quoted 34 lines · Trond Myklebust
Quoted 32 lines · Trond Myklebust
Quoted 17 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c nfs4_label_init_security(struct inode *dir, struct dentry *dentry, · line 113
Quoted 9 lines
fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry,if (nfs_server_capable (dir,NFS_CAP_SECURITY_LABEL ) ==0 )return NULL ; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )Hi Anna,
Quoted 7 lines
Quoted 3 lines
This looks like a check that needs to be done by
selinux_dentry_init_security()itself. Thedir->i_securityfield is not something that NFS knows about. David, what needs to happen there whendentry->d_parent->i_security(a.k.a. dsec) is NULL?Oh, wait. I missed the bit about ‘without SELinux installed’. So the problem here is that you have a NFS client that does not have SELinux set up, but running against a server that is advertising NFSv4.2 with labeled NFS. Is that correct?
It looks to me as if
cap_dentry_init_security()will indeed trigger this behaviour since it returns ‘0’ without doing anything to the label. As far as I can see, the right thing to do there is to return-EOPNOTSUPP, no?
I feel like Jeff Layton was looking at the same thing, and came to the same conclusion...
Jeff?
-Eric
Quoted 55 lines · On Tue, 11 Mar 2014 20:38:18 -0400 Eric Paris <[email protected]> wrote:
Quoted 49 lines · Trond Myklebust
Quoted 34 lines · Trond Myklebust
Quoted 18 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c nfs4_label_init_security(struct inode *dir, · line 113
Quoted 9 lines
fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry, if (nfs_server_capable(dir, NFS_CAP_SECURITY_LABEL) == 0) return NULL; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )Hi Anna,
Quoted 6 lines
This looks like a check that needs to be done by
selinux_dentry_init_security()itself. Thedir->i_securityfield is not something that NFS knows about. David, what needs to happen there whendentry->d_parent->i_security(a.k.a. dsec) is NULL?Oh, wait. I missed the bit about ‘without SELinux installed’. So the problem here is that you have a NFS client that does not have SELinux set up, but running against a server that is advertising NFSv4.2 with labeled NFS. Is that correct?
Quoted 4 lines
It looks to me as if
cap_dentry_init_security()will indeed trigger this behaviour since it returns ‘0’ without doing anything to the label. As far as I can see, the right thing to do there is to return-EOPNOTSUPP, no?
Quoted 5 lines
I feel like Jeff Layton was looking at the same thing, and came to the same conclusion...
Jeff?
I posted a patch for this last week and James has merged it:
[PATCH] security: have cap_dentry_init_security return error
I didn't note it in the patch description but it fixes 4.2 when SELinux is compiled in but disabled.
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 64 lines · Jeffrey Layton
Quoted 55 lines · On Tue, 11 Mar 2014 20:38:18 -0400 Eric Paris <[email protected]> wrote:
Quoted 49 lines · Trond Myklebust
Quoted 34 lines · Trond Myklebust
Quoted 18 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c nfs4_label_init_security(struct inode *dir, · line 113
Quoted 9 lines
fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry, if (nfs_server_capable(dir, NFS_CAP_SECURITY_LABEL) == 0) return NULL; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )Hi Anna,
Quoted 6 lines
This looks like a check that needs to be done by
selinux_dentry_init_security()itself. Thedir->i_securityfield is not something that NFS knows about. David, what needs to happen there whendentry->d_parent->i_security(a.k.a. dsec) is NULL?Oh, wait. I missed the bit about ‘without SELinux installed’. So the problem here is that you have a NFS client that does not have SELinux set up, but running against a server that is advertising NFSv4.2 with labeled NFS. Is that correct?
Quoted 4 lines
It looks to me as if
cap_dentry_init_security()will indeed trigger this behaviour since it returns ‘0’ without doing anything to the label. As far as I can see, the right thing to do there is to return-EOPNOTSUPP, no?Quoted 5 lines
I feel like Jeff Layton was looking at the same thing, and came to the same conclusion...
Jeff?
Quoted 6 lines
I posted a patch for this last week and James has merged it:
[PATCH] security: have
cap_dentry_init_securityreturn errorI didn't note it in the patch description but it fixes 4.2 when SELinux is compiled in but disabled.
Thanks! Then I expect no further action is needed on our part, and that the fix will come through the security tree?
_________________________________
Trond Myklebust
Linux NFS client maintainer, PrimaryData
[email protected]
Quoted 67 lines · On Wed, 12 Mar 2014 05:21:13 -0400 Trond Myklebust…
Quoted 64 lines · Jeffrey Layton
Quoted 60 lines · On Tue, 11 Mar 2014 20:38:18 -0400 Eric Paris <[email protected]> wrote:
Quoted 49 lines · Trond Myklebust
Quoted 34 lines · Trond Myklebust
Quoted 18 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c nfs4_label_init_security(struct inode *dir, · line 113
Quoted 9 lines
fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry, if (nfs_server_capable(dir, NFS_CAP_SECURITY_LABEL) == 0) return NULL; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )Hi Anna,
Quoted 6 lines
This looks like a check that needs to be done by
selinux_dentry_init_security()itself. Thedir->i_securityfield is not something that NFS knows about. David, what needs to happen there whendentry->d_parent->i_security(a.k.a. dsec) is NULL?Oh, wait. I missed the bit about ‘without SELinux installed’. So the problem here is that you have a NFS client that does not have SELinux set up, but running against a server that is advertising NFSv4.2 with labeled NFS. Is that correct?
Quoted 4 lines
It looks to me as if
cap_dentry_init_security()will indeed trigger this behaviour since it returns ‘0’ without doing anything to the label. As far as I can see, the right thing to do there is to return-EOPNOTSUPP, no?I feel like Jeff Layton was looking at the same thing, and came to the same conclusion...
Jeff?
Quoted 9 lines
Quoted 6 lines
I posted a patch for this last week and James has merged it:
[PATCH] security: have
cap_dentry_init_securityreturn errorI didn't note it in the patch description but it fixes 4.2 when SELinux is compiled in but disabled.
Thanks! Then I expect no further action is needed on our part, and that the fix will come through the security tree?
FWIW, this is the bug that was causing the NFS server to spew messages like this to the ring buffer when Anna was testing against my server at Connectathon:
[ 243.479524] SELinux: Context \xffffffdf is not valid (left unmapped).
We may want to do a follow-on patch to clean up the struct nfs4_label initializers since they're not really needed. But that should probably wait until James merges this up to Linus.
Signature · 1 line
Jeff Layton <[email protected]>
I just tried Jeff's patch and it does fix my problem. I wish I had remembered it earlier in the day yesterday!
Quoted 82 lines · Jeff Layton
Quoted 61 lines · On Wed, 12 Mar 2014 05:21:13 -0400 Trond Myklebust…
Quoted 59 lines · Jeffrey Layton
Quoted 56 lines · On Tue, 11 Mar 2014 20:38:18 -0400 Eric Paris <[email protected]> wrote:
Quoted 46 lines · Trond Myklebust
Quoted 32 lines · Trond Myklebust
Quoted 18 lines · Anna Schumaker
If the
i_securityfield isn't set thensecurity_dentry_init_security()won't initialize some of the values used by the security label. This causes my client to hit aBUG_ON()while encoding a label of size -2128927414.I hit this bug while testing on a client without SELinux installed.
Signed-off-by Anna Schumaker <[email protected]>---
fs/nfs/nfs4proc.c| 3 +++1 file changed, 3 insertions(+)fs/nfs/nfs4proc.c +0
-0fs/nfs/nfs4proc.c nfs4_label_init_security(struct inode *dir, · line 113
Quoted 9 lines
fs/nfs/nfs4proc.c +3
-0@@ -105,6 +105,9 @@ nfs4_label_init_security(struct inode *dir, struct dentry *dentry, if (nfs_server_capable(dir, NFS_CAP_SECURITY_LABEL) == 0) return NULL; +if (!dir->i_security) +return NULL ; + err =security_dentry_init_security (dentry, sattr->ia_mode, &dentry->d_name, (void **)&label->label, &label->len);if (err ==0 )Hi Anna,
Quoted 6 lines
This looks like a check that needs to be done by
selinux_dentry_init_security()itself. Thedir->i_securityfield is not something that NFS knows about. David, what needs to happen there whendentry->d_parent->i_security(a.k.a. dsec) is NULL?Oh, wait. I missed the bit about ‘without SELinux installed’. So the problem here is that you have a NFS client that does not have SELinux set up, but running against a server that is advertising NFSv4.2 with labeled NFS. Is that correct?
Quoted 4 lines
It looks to me as if
cap_dentry_init_security()will indeed trigger this behaviour since it returns ‘0’ without doing anything to the label. As far as I can see, the right thing to do there is to return-EOPNOTSUPP, no?I feel like Jeff Layton was looking at the same thing, and came to the same conclusion...
Jeff?
Quoted 8 lines
Quoted 6 lines
I posted a patch for this last week and James has merged it:
[PATCH] security: have
cap_dentry_init_securityreturn errorI didn't note it in the patch description but it fixes 4.2 when SELinux is compiled in but disabled.
Thanks! Then I expect no further action is needed on our part, and that the fix will come through the security tree?
FWIW, this is the bug that was causing the NFS server to spew messages like this to the ring buffer when Anna was testing against my server at Connectathon:
[ 243.479524] SELinux: Context \xffffffdf is not valid (left unmapped).We may want to do a follow-on patch to clean up the struct
nfs4_labelinitializers since they're not really needed. But that should probably wait until James merges this up to Linus.