* Re: [RFC PATCH 1/2] selinux: Don't call avc_compute_av() from RCU path walk [not found] ` <20191120131229.GA21500@willie-the-truck> @ 2019-11-20 15:28 ` Stephen Smalley 2019-11-20 19:07 ` Paul E. McKenney 0 siblings, 1 reply; 3+ messages in thread From: Stephen Smalley @ 2019-11-20 15:28 UTC (permalink / raw) To: Will Deacon; +Cc: selinux, linux-kernel, viro, linuxfs, rcu On 11/20/19 8:12 AM, Will Deacon wrote: > Hi Stephen, > > Thanks for the quick reply. > > On Tue, Nov 19, 2019 at 01:59:40PM -0500, Stephen Smalley wrote: >> On 11/19/19 1:40 PM, Will Deacon wrote: >>> 'avc_compute_av()' can block, so we carefully exit the RCU read-side >>> critical section before calling it in 'avc_has_perm_noaudit()'. >>> Unfortunately, if we're calling from the VFS layer on the RCU path walk >>> via 'selinux_inode_permission()' then we're still actually in an RCU >>> read-side critical section and must not block. >> >> avc_compute_av() should never block AFAIK. The blocking concern was with >> slow_avc_audit(), and even that appears dubious to me. That seems to be more >> about misuse of d_find_alias in dump_common_audit_data() than anything. > > Apologies, I lost track of GFP_ATOMIC when I reading the code and didn't > think it was propagated down to all of the potential allocations and > string functions. Having looked at it again, I can't see where it blocks. > > Might be worth a comment in avc_compute_av(), because the temporary > dropping of rcu_read_lock() looks really dodgy when we could be running > on the RCU path walk path anyway. I don't think that's a problem but I'll defer to the fsdevel and rcu folks. The use of RCU within the SELinux AVC long predates the introduction of RCU path walk, and the rcu_read_lock()/unlock() pairs inside the AVC are not related in any way to RCU path walk. Hopefully they don't break it. The SELinux security server (i.e. security_compute_av() and the rest of security/selinux/ss/*) internally has its own locking for its data structures, primarily the policy rwlock. There was also a patch long ago to convert use of that policy rwlock to RCU but it didn't seem justified at the time. We are interested in revisiting that however. That would introduce its own set of rcu_read_lock/unlock pairs inside of security_compute_av() as well. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1/2] selinux: Don't call avc_compute_av() from RCU path walk 2019-11-20 15:28 ` [RFC PATCH 1/2] selinux: Don't call avc_compute_av() from RCU path walk Stephen Smalley @ 2019-11-20 19:07 ` Paul E. McKenney 2019-11-20 19:13 ` Will Deacon 0 siblings, 1 reply; 3+ messages in thread From: Paul E. McKenney @ 2019-11-20 19:07 UTC (permalink / raw) To: Stephen Smalley; +Cc: Will Deacon, selinux, linux-kernel, viro, linuxfs, rcu On Wed, Nov 20, 2019 at 10:28:31AM -0500, Stephen Smalley wrote: > On 11/20/19 8:12 AM, Will Deacon wrote: > > Hi Stephen, > > > > Thanks for the quick reply. > > > > On Tue, Nov 19, 2019 at 01:59:40PM -0500, Stephen Smalley wrote: > > > On 11/19/19 1:40 PM, Will Deacon wrote: > > > > 'avc_compute_av()' can block, so we carefully exit the RCU read-side > > > > critical section before calling it in 'avc_has_perm_noaudit()'. > > > > Unfortunately, if we're calling from the VFS layer on the RCU path walk > > > > via 'selinux_inode_permission()' then we're still actually in an RCU > > > > read-side critical section and must not block. > > > > > > avc_compute_av() should never block AFAIK. The blocking concern was with > > > slow_avc_audit(), and even that appears dubious to me. That seems to be more > > > about misuse of d_find_alias in dump_common_audit_data() than anything. > > > > Apologies, I lost track of GFP_ATOMIC when I reading the code and didn't > > think it was propagated down to all of the potential allocations and > > string functions. Having looked at it again, I can't see where it blocks. > > > > Might be worth a comment in avc_compute_av(), because the temporary > > dropping of rcu_read_lock() looks really dodgy when we could be running > > on the RCU path walk path anyway. > > I don't think that's a problem but I'll defer to the fsdevel and rcu folks. > The use of RCU within the SELinux AVC long predates the introduction of RCU > path walk, and the rcu_read_lock()/unlock() pairs inside the AVC are not > related in any way to RCU path walk. Hopefully they don't break it. The > SELinux security server (i.e. security_compute_av() and the rest of > security/selinux/ss/*) internally has its own locking for its data > structures, primarily the policy rwlock. There was also a patch long ago to > convert use of that policy rwlock to RCU but it didn't seem justified at the > time. We are interested in revisiting that however. That would introduce > its own set of rcu_read_lock/unlock pairs inside of security_compute_av() as > well. RCU readers nest, so it should be fine. (Famous last words...) Thanx, Paul ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH 1/2] selinux: Don't call avc_compute_av() from RCU path walk 2019-11-20 19:07 ` Paul E. McKenney @ 2019-11-20 19:13 ` Will Deacon 0 siblings, 0 replies; 3+ messages in thread From: Will Deacon @ 2019-11-20 19:13 UTC (permalink / raw) To: Paul E. McKenney Cc: Stephen Smalley, selinux, linux-kernel, viro, linuxfs, rcu On Wed, Nov 20, 2019 at 11:07:43AM -0800, Paul E. McKenney wrote: > On Wed, Nov 20, 2019 at 10:28:31AM -0500, Stephen Smalley wrote: > > On 11/20/19 8:12 AM, Will Deacon wrote: > > > Hi Stephen, > > > > > > Thanks for the quick reply. > > > > > > On Tue, Nov 19, 2019 at 01:59:40PM -0500, Stephen Smalley wrote: > > > > On 11/19/19 1:40 PM, Will Deacon wrote: > > > > > 'avc_compute_av()' can block, so we carefully exit the RCU read-side > > > > > critical section before calling it in 'avc_has_perm_noaudit()'. > > > > > Unfortunately, if we're calling from the VFS layer on the RCU path walk > > > > > via 'selinux_inode_permission()' then we're still actually in an RCU > > > > > read-side critical section and must not block. > > > > > > > > avc_compute_av() should never block AFAIK. The blocking concern was with > > > > slow_avc_audit(), and even that appears dubious to me. That seems to be more > > > > about misuse of d_find_alias in dump_common_audit_data() than anything. > > > > > > Apologies, I lost track of GFP_ATOMIC when I reading the code and didn't > > > think it was propagated down to all of the potential allocations and > > > string functions. Having looked at it again, I can't see where it blocks. > > > > > > Might be worth a comment in avc_compute_av(), because the temporary > > > dropping of rcu_read_lock() looks really dodgy when we could be running > > > on the RCU path walk path anyway. > > > > I don't think that's a problem but I'll defer to the fsdevel and rcu folks. > > The use of RCU within the SELinux AVC long predates the introduction of RCU > > path walk, and the rcu_read_lock()/unlock() pairs inside the AVC are not > > related in any way to RCU path walk. Hopefully they don't break it. The > > SELinux security server (i.e. security_compute_av() and the rest of > > security/selinux/ss/*) internally has its own locking for its data > > structures, primarily the policy rwlock. There was also a patch long ago to > > convert use of that policy rwlock to RCU but it didn't seem justified at the > > time. We are interested in revisiting that however. That would introduce > > its own set of rcu_read_lock/unlock pairs inside of security_compute_av() as > > well. > > RCU readers nest, so it should be fine. (Famous last words...) Agreed. It was blocking that worried me, and it turns out that doesn't happen for this code. Will ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-20 19:13 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20191119184057.14961-1-will@kernel.org> [not found] ` <20191119184057.14961-2-will@kernel.org> [not found] ` <5e51f9a5-ba76-a42d-fc2b-9255f8544859@tycho.nsa.gov> [not found] ` <20191120131229.GA21500@willie-the-truck> 2019-11-20 15:28 ` [RFC PATCH 1/2] selinux: Don't call avc_compute_av() from RCU path walk Stephen Smalley 2019-11-20 19:07 ` Paul E. McKenney 2019-11-20 19:13 ` Will Deacon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).