Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6550159ybi; Wed, 29 May 2019 09:23:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1k8FV64+fPa09oLHT5rpzWL7jrqVVDRQg+bd1W+NsZcNGfDjJLhII7ZOXLG5eNpeK8z7i X-Received: by 2002:a65:5241:: with SMTP id q1mr42709757pgp.298.1559146999707; Wed, 29 May 2019 09:23:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559146999; cv=none; d=google.com; s=arc-20160816; b=tSumSZA+DkddOAT51/ZmHp61Ow1VrtDnFw3zEPELgr7DEGnWxJ9zdUOhUvIWTYyp/J V4q0I+mME8EiauBpCZ2RkhzU0SIXudzTNHdVqanETQXUxbqPCGwkTbrOjcvkv9S0Beww uUplTIwAzLur/g3kOcUY/7OlwcQ4v+d7FBJgMPm6f3J0U6bT4ynWYlLflHjieoraOtSZ r9/wePWVPSGmTL9h8mbp9rXgY8+8uBSSy8yyVRdpgRx2GIT9R3dBaa7f091xPnvXEUdE 7FWUhhtuyTUThO9bFPkNj+8X0e9jpP++F9J9c0ZSRrX0uPZQOMlpzhn2wZ6hOuw6x+ad /V0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=s3+FkzwezV81ms173Tv7h1gxaHBwGQKO1V8dQp6yLhc=; b=CmWUKD/iBakF1fMXUV2fBtjt3zoA6xNMNIeM2alldAAus5L4gMD2bGaLp79PN8Eapm NkA7vK1hSDf50hpMLteGB52f6ZToxLMk80OAllhzNsXRNI4cdQp63ktJ6qcReCSaLO5z r+78m0I+du262XEfxFJFrXZ5nZfsfoqDkdHlmc/1Crel+Ra9D7ssLJXnxaVt3V4inok1 0SybMLdnXges+3niO/FXgL7B81h0SUXaXZLbhXE1WnjntyGzbQNG2yxd5w0ILiPd5XYb VsCGeEzScbxLHU+Ug/rvEBNX2QmTKk06VpSQwFyKBi7iSc4fPK9TFIuRTlxBDyXvq5A1 rxtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bg10si57856plb.28.2019.05.29.09.23.04; Wed, 29 May 2019 09:23:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727135AbfE2QV2 (ORCPT + 99 others); Wed, 29 May 2019 12:21:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45181 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbfE2QV2 (ORCPT ); Wed, 29 May 2019 12:21:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E565F30B97AA; Wed, 29 May 2019 16:21:22 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.43.17.159]) by smtp.corp.redhat.com (Postfix) with SMTP id 971C11001F5D; Wed, 29 May 2019 16:21:21 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 29 May 2019 18:21:22 +0200 (CEST) Date: Wed, 29 May 2019 18:21:20 +0200 From: Oleg Nesterov To: Jann Horn Cc: "Eric W . Biederman" , Andrew Morton , Kees Cook , David Howells , linux-kernel@vger.kernel.org Subject: Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access() Message-ID: <20190529162120.GB27659@redhat.com> References: <20190529113157.227380-1-jannh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190529113157.227380-1-jannh@google.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 29 May 2019 16:21:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.