From: Steve Grubb <sgrubb@redhat.com>
To: Paul Moore <paul@paul-moore.com>,
linux-security-module@vger.kernel.org, selinux@vger.kernel.org,
linux-audit@redhat.com
Subject: Re: security_task_getsecid() and subjective vs objective task creds
Date: Thu, 18 Feb 2021 17:50:51 -0500 [thread overview]
Message-ID: <806848326.0ifERbkFSE@x2> (raw)
In-Reply-To: <5f8a424a-2aab-f11a-0e06-f8f075c644f6@schaufler-ca.com>
On Thursday, February 18, 2021 5:07:52 PM EST Casey Schaufler wrote:
> On 2/18/2021 11:34 AM, Paul Moore wrote:
> > Hi all,
> >
> > When looking into a problem I noticed that audit was recording the
> > wrong subject label for a process. Doing a bit of digging I realized
> > this was caused by the SELinux security_task_getsecid() implementation
> > returning the objective security label (taken from task->real_cred),
> > and not the subjective security label (taken from task->cred).
> >
> > Looking around at the other LSMs which implement this hook, Smack and
> > AppArmor, it appears they both do the same thing: return the objective
> > security ID for the process. Looking quickly at the various non-LSM
> > callers of the security_task_getsecid() hook, it unfortunately looks
> > like all of them expect the subjective security ID to be returned.
> > The only caller I'm not 100% confident in is binder, but from what I
> > can tell it looks like they are expecting the subjective ID too.
> >
> > At least we are consistently wrong :)
>
> We may have come down with a case of helperitis.
>
> > How do we want to fix this? The obvious fix is to change the SELinux,
> > AppArmor, and Smack security_task_getsecid() implementations to return
> > the subjective security ID (->cred), and likely make a note in
> > lsm_hooks.h,
>
> That would be my choice.
>
> > but if someone can see a case where we would need both
> >
> > the subjective and objective security labels speak up and we can
> > introduce a new hook for the subjective label, and likely add a "_obj"
> > to the end of the existing hook to help make it more clear. If
> > neither of those options are acceptable, we could convert all of the
> > existing callers to use something like the line below (assumes
> > current), but that is the least appealing option as far as I'm
> > concerned.
> >
> > security_cred_getsecid(current_cred(), &sid);
> >
> > Opinions?
>
> If the objective cred isn't being used in the access control decision
> it seems pointless to add it to the audit record. If there is a case
> where the task is being treated as an object, signal delivery comes to
> mind, you still want the objective credential. So it seems like care
> may be required to ensure that the correct value (sub vs obj) is
> used.
Yes, ptrace, process_vm_readv, process_vm_writev, pidfd_open,
process_madvise, pidfd_send_signal all seem to operate on a different process
and might be candidates for an OBJ_PID record which is where it would get
recorded.
-Steve
--
Linux-audit mailing list
Linux-audit@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-audit
WARNING: multiple messages have this Message-ID (diff)
From: Steve Grubb <sgrubb@redhat.com>
To: Paul Moore <paul@paul-moore.com>,
linux-security-module@vger.kernel.org, selinux@vger.kernel.org,
linux-audit@redhat.com
Cc: Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: security_task_getsecid() and subjective vs objective task creds
Date: Thu, 18 Feb 2021 17:50:51 -0500 [thread overview]
Message-ID: <806848326.0ifERbkFSE@x2> (raw)
In-Reply-To: <5f8a424a-2aab-f11a-0e06-f8f075c644f6@schaufler-ca.com>
On Thursday, February 18, 2021 5:07:52 PM EST Casey Schaufler wrote:
> On 2/18/2021 11:34 AM, Paul Moore wrote:
> > Hi all,
> >
> > When looking into a problem I noticed that audit was recording the
> > wrong subject label for a process. Doing a bit of digging I realized
> > this was caused by the SELinux security_task_getsecid() implementation
> > returning the objective security label (taken from task->real_cred),
> > and not the subjective security label (taken from task->cred).
> >
> > Looking around at the other LSMs which implement this hook, Smack and
> > AppArmor, it appears they both do the same thing: return the objective
> > security ID for the process. Looking quickly at the various non-LSM
> > callers of the security_task_getsecid() hook, it unfortunately looks
> > like all of them expect the subjective security ID to be returned.
> > The only caller I'm not 100% confident in is binder, but from what I
> > can tell it looks like they are expecting the subjective ID too.
> >
> > At least we are consistently wrong :)
>
> We may have come down with a case of helperitis.
>
> > How do we want to fix this? The obvious fix is to change the SELinux,
> > AppArmor, and Smack security_task_getsecid() implementations to return
> > the subjective security ID (->cred), and likely make a note in
> > lsm_hooks.h,
>
> That would be my choice.
>
> > but if someone can see a case where we would need both
> >
> > the subjective and objective security labels speak up and we can
> > introduce a new hook for the subjective label, and likely add a "_obj"
> > to the end of the existing hook to help make it more clear. If
> > neither of those options are acceptable, we could convert all of the
> > existing callers to use something like the line below (assumes
> > current), but that is the least appealing option as far as I'm
> > concerned.
> >
> > security_cred_getsecid(current_cred(), &sid);
> >
> > Opinions?
>
> If the objective cred isn't being used in the access control decision
> it seems pointless to add it to the audit record. If there is a case
> where the task is being treated as an object, signal delivery comes to
> mind, you still want the objective credential. So it seems like care
> may be required to ensure that the correct value (sub vs obj) is
> used.
Yes, ptrace, process_vm_readv, process_vm_writev, pidfd_open,
process_madvise, pidfd_send_signal all seem to operate on a different process
and might be candidates for an OBJ_PID record which is where it would get
recorded.
-Steve
next prev parent reply other threads:[~2021-02-18 22:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-18 19:34 security_task_getsecid() and subjective vs objective task creds Paul Moore
2021-02-18 19:34 ` Paul Moore
2021-02-18 21:40 ` Casey Schaufler
2021-02-18 21:40 ` Casey Schaufler
2021-02-19 19:17 ` Paul Moore
2021-02-19 19:17 ` Paul Moore
2021-02-18 22:07 ` Casey Schaufler
2021-02-18 22:07 ` Casey Schaufler
2021-02-18 22:50 ` Steve Grubb [this message]
2021-02-18 22:50 ` Steve Grubb
2021-02-20 2:54 ` James Morris
2021-02-20 2:54 ` James Morris
2021-02-20 14:50 ` Paul Moore
2021-02-20 14:50 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=806848326.0ifERbkFSE@x2 \
--to=sgrubb@redhat.com \
--cc=linux-audit@redhat.com \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.