LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Jann Horn <jannh@google.com>
Cc: "Eric W . Biederman" <ebiederm@xmission.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <keescook@chromium.org>,
	David Howells <dhowells@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access()
Date: Wed, 29 May 2019 18:21:20 +0200	[thread overview]
Message-ID: <20190529162120.GB27659@redhat.com> (raw)
In-Reply-To: <20190529113157.227380-1-jannh@google.com>

On 05/29, Jann Horn wrote:
>
> (I have no clue whatsoever what the relevant tree for this is, but I
> guess Oleg is the relevant maintainer?)

we usually route ptrace changes via -mm tree, plus I lost my account on korg.

> --- a/kernel/ptrace.c
> +++ b/kernel/ptrace.c
> @@ -324,6 +324,16 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode)
>  	return -EPERM;
>  ok:
>  	rcu_read_unlock();
> +	/*
> +	 * If a task drops privileges and becomes nondumpable (through a syscall
> +	 * like setresuid()) while we are trying to access it, we must ensure
> +	 * that the dumpability is read after the credentials; otherwise,
> +	 * we may be able to attach to a task that we shouldn't be able to
> +	 * attach to (as if the task had dropped privileges without becoming
> +	 * nondumpable).
> +	 * Pairs with a write barrier in commit_creds().
> +	 */
> +	smp_rmb();

(I am wondering if smp_acquire__after_ctrl_dep() could be used instead, just to
 make this code look more confusing)

>  	mm = task->mm;

while at it, could you also change this into mm = READ_ONCE(task->mm) ?

Oleg.


  parent reply	other threads:[~2019-05-29 16:21 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29 11:31 Jann Horn
2019-05-29 15:59 ` Eric W. Biederman
2019-05-29 16:01   ` Jann Horn
2019-05-29 16:21 ` Oleg Nesterov [this message]
2019-05-29 17:38   ` Jann Horn
2019-05-30  1:41     ` Eric W. Biederman
2019-05-31 15:04       ` Jann Horn
2019-05-30 10:34     ` Andrea Parri
2019-05-31  9:08       ` Peter Zijlstra
2019-05-30 12:05     ` Oleg Nesterov
2019-05-31  9:12       ` Peter Zijlstra
2019-05-31  9:55         ` Oleg Nesterov
2019-05-29 21:02   ` Jann Horn
2019-05-29 18:55 ` Kees Cook
2019-05-30 12:34 ` Oleg Nesterov
2019-05-31 11:56   ` Jann Horn
2019-05-31 13:35     ` Oleg Nesterov
2019-05-31 19:37       ` Jann Horn

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=20190529162120.GB27659@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=jannh@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access()' \
    /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

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).