From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from goalie.tycho.ncsc.mil (goalie.infosec.tycho.ncsc.mil [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id w8R1s6i2010250 for ; Wed, 26 Sep 2018 21:54:06 -0400 Received: by mail-io1-f67.google.com with SMTP id q4-v6so757916iob.8 for ; Wed, 26 Sep 2018 18:54:01 -0700 (PDT) MIME-Version: 1.0 References: <20180926203446.2004-1-casey.schaufler@intel.com> <20180926203446.2004-4-casey.schaufler@intel.com> In-Reply-To: <20180926203446.2004-4-casey.schaufler@intel.com> From: Stephen Smalley Date: Wed, 26 Sep 2018 21:53:47 -0400 Message-ID: To: "Schaufler, Casey" Cc: kernel-hardening@lists.openwall.com, Linux Kernel , linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, dave.hansen@intel.com, deneen.t.dock@intel.com, kristen@linux.intel.com, arjan@linux.intel.com Content-Type: multipart/alternative; boundary="000000000000d6d6de0576d09cc2" Subject: Re: [PATCH v5 3/5] SELinux: Prepare for PTRACE_MODE_SCHED List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: --000000000000d6d6de0576d09cc2 Content-Type: text/plain; charset="UTF-8" On Wed, Sep 26, 2018, 4:35 PM Casey Schaufler wrote: > From: Casey Schaufler > > A ptrace access check with mode PTRACE_MODE_SCHED gets called > from process switching code. This precludes the use of audit or avc, > as the locking is incompatible. The only available check that > can be made without using avc is a comparison of the secids. > This is not very satisfactory as it will indicate possible > vulnerabilies much too aggressively. > We already have a flag to disable audit. What locking conflict is presented by the avc, which uses rcu? > Signed-off-by: Casey Schaufler > --- > security/selinux/hooks.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index ad9a9b8e9979..160239791007 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -2267,6 +2267,8 @@ static int selinux_ptrace_access_check(struct > task_struct *child, > u32 sid = current_sid(); > u32 csid = task_sid(child); > > + if (mode & PTRACE_MODE_SCHED) > + return sid == csid ? 0 : -EACCES; > if (mode & PTRACE_MODE_READ) > return avc_has_perm(&selinux_state, > sid, csid, SECCLASS_FILE, FILE__READ, > NULL); > -- > 2.17.1 > > --000000000000d6d6de0576d09cc2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, = Sep 26, 2018, 4:35 PM Casey Schaufler <casey.schaufler@intel.com> wrote:
From: Casey Schaufler <casey@schaufler-ca.com&= gt;

A ptrace access check with mode PTRACE_MODE_SCHED gets called
from process switching code. This precludes the use of audit or avc,
as the locking is incompatible. The only available check that
can be made without using avc is a comparison of the secids.
This is not very satisfactory as it will indicate possible
vulnerabilies much too aggressively.

We already have a flag to disable aud= it. What locking conflict is presented by the avc, which uses rcu?=C2=A0


Signed-off-by: Casey Schaufler <casey.schaufler@intel.com>=
---
=C2=A0security/selinux/hooks.c | 2 ++
=C2=A01 file changed, 2 insertions(+)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index ad9a9b8e9979..160239791007 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2267,6 +2267,8 @@ static int selinux_ptrace_access_check(struct task_st= ruct *child,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 u32 sid =3D current_sid();
=C2=A0 =C2=A0 =C2=A0 =C2=A0 u32 csid =3D task_sid(child);

+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (mode & PTRACE_MODE_SCHED)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return sid =3D=3D c= sid ? 0 : -EACCES;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (mode & PTRACE_MODE_READ)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return avc_has_perm= (&selinux_state,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sid, csid, SECCLASS_FI= LE, FILE__READ, NULL);
--
2.17.1

--000000000000d6d6de0576d09cc2--