From: Kees Cook <keescook@google.com>
To: Jann Horn <jann@thejh.net>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Casey Schaufler <casey@schaufler-ca.com>,
Oleg Nesterov <oleg@redhat.com>, Ingo Molnar <mingo@redhat.com>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge.hallyn@ubuntu.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andy Lutomirski <luto@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Joe Perches <joe@perches.com>,
Thomas Gleixner <tglx@linutronix.de>,
Michael Kerrisk <mtk.manpages@gmail.com>,
LKML <linux-kernel@vger.kernel.org>,
Linux-MM <linux-mm@kvack.org>,
linux-security-module <linux-security-module@vger.kernel.org>,
Linux API <linux-api@vger.kernel.org>,
"security@kernel.org" <security@kernel.org>,
Willy Tarreau <w@1wt.eu>
Subject: Re: [PATCH 1/2] security: let security modules use PTRACE_MODE_* with bitmasks
Date: Mon, 7 Dec 2015 13:30:53 -0800 [thread overview]
Message-ID: <CAGXu5jKe_b9Kcty2Pv7Y9YnjT2OtSGH_rdREUb09mX=kqNf4rQ@mail.gmail.com> (raw)
In-Reply-To: <1449523512-29200-2-git-send-email-jann@thejh.net>
On Mon, Dec 7, 2015 at 1:25 PM, Jann Horn <jann@thejh.net> wrote:
> It looks like smack and yama weren't aware that the ptrace mode
> can have flags ORed into it - PTRACE_MODE_NOAUDIT until now, but
> only for /proc/$pid/stat, and with the PTRACE_MODE_*CREDS patch,
> all modes have flags ORed into them.
>
> Signed-off-by: Jann Horn <jann@thejh.net>
Acked-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> security/smack/smack_lsm.c | 8 +++-----
> security/yama/yama_lsm.c | 4 ++--
> 2 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index ff81026..7c57c7f 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -398,12 +398,10 @@ static int smk_copy_relabel(struct list_head *nhead, struct list_head *ohead,
> */
> static inline unsigned int smk_ptrace_mode(unsigned int mode)
> {
> - switch (mode) {
> - case PTRACE_MODE_READ:
> - return MAY_READ;
> - case PTRACE_MODE_ATTACH:
> + if (mode & PTRACE_MODE_ATTACH)
> return MAY_READWRITE;
> - }
> + if (mode & PTRACE_MODE_READ)
> + return MAY_READ;
>
> return 0;
> }
> diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
> index d3c19c9..cb6ed10 100644
> --- a/security/yama/yama_lsm.c
> +++ b/security/yama/yama_lsm.c
> @@ -281,7 +281,7 @@ static int yama_ptrace_access_check(struct task_struct *child,
> int rc = 0;
>
> /* require ptrace target be a child of ptracer on attach */
> - if (mode == PTRACE_MODE_ATTACH) {
> + if (mode & PTRACE_MODE_ATTACH) {
> switch (ptrace_scope) {
> case YAMA_SCOPE_DISABLED:
> /* No additional restrictions. */
> @@ -307,7 +307,7 @@ static int yama_ptrace_access_check(struct task_struct *child,
> }
> }
>
> - if (rc) {
> + if (rc && (mode & PTRACE_MODE_NOAUDIT) == 0) {
> printk_ratelimited(KERN_NOTICE
> "ptrace of pid %d was attempted by: %s (pid %d)\n",
> child->pid, current->comm, current->pid);
> --
> 2.1.4
>
--
Kees Cook
Chrome OS & Brillo Security
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2015-12-07 21:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-08 12:08 [PATCH] ptrace: use fsuid, fsgid, effective creds for fs access checks Jann Horn
2015-11-09 20:55 ` Andrew Morton
2015-11-09 21:06 ` Willy Tarreau
2015-11-09 21:12 ` Jann Horn
2015-11-09 21:19 ` Andrew Morton
2015-12-06 2:04 ` Jann Horn
2015-12-07 20:32 ` Kees Cook
2015-12-07 20:38 ` Jann Horn
2015-12-07 21:25 ` Jann Horn
2015-12-07 21:25 ` [PATCH 1/2] security: let security modules use PTRACE_MODE_* with bitmasks Jann Horn
2015-12-07 21:30 ` Kees Cook [this message]
2015-12-07 21:51 ` Casey Schaufler
2015-12-07 21:25 ` [PATCH 2/2] ptrace: use fsuid, fsgid, effective creds for fs access checks Jann Horn
2015-12-07 21:27 ` Kees Cook
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='CAGXu5jKe_b9Kcty2Pv7Y9YnjT2OtSGH_rdREUb09mX=kqNf4rQ@mail.gmail.com' \
--to=keescook@google.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=casey@schaufler-ca.com \
--cc=ebiederm@xmission.com \
--cc=james.l.morris@oracle.com \
--cc=jann@thejh.net \
--cc=joe@perches.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-security-module@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=mtk.manpages@gmail.com \
--cc=oleg@redhat.com \
--cc=security@kernel.org \
--cc=serge.hallyn@ubuntu.com \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=w@1wt.eu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox