Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6836970ybi; Wed, 29 May 2019 14:08:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrk5vL10XVI/jahyFdE3gvfqUo0HYAI/bSnJfUUltw89OC4t5hPzi4RJrBoSVfoq6oSPIU X-Received: by 2002:a17:902:404:: with SMTP id 4mr51251631ple.204.1559164080928; Wed, 29 May 2019 14:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559164080; cv=none; d=google.com; s=arc-20160816; b=eVkkL34mg5igf61OYagJYgqAcwbTaC5vPfdE5MTn3dv2QvkH331PgbnU4u0Wu5Pz/u l9yLk+Rsw7fow0/Mmnbbx9IWQjNO0949PjKRdFpg38HFP4QvZm6afc4Cl8ChOVhZIZfs c2X6jTI06pl87yy60wQlYvGJa8BTUym9WC+QcAreNy4l6ZoweRR6wh1BWoJkqAmx6GRH xLCx82LUJvXhsYr9v0GZq6T+YSDAG7Mxlnjt7qftO3Ncu+k+mlp27+VOSDWPytA70Xhs kNqxgmKwx8lFpuTYYDGbqv8IdmpUYBQO7ZUmPqdcX1mCCA4TGe76QXzw7nRBrW9lG6OG deQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=HrCXOU+Fm+D2XlSRN/oeiwuNWs703wLzrQB7UZuJ5ic=; b=Ov/GYJVp18ehT5u/VMVcylZSGLSVMi6aqt+txMT9nueTk+cde1UiUJZlS8kHpU2l0X NJG21rL2vRkHmMQvqLmtyW3vHl/c1HxyXT1l+vLPwMIGCPly9F4/+E+sGDiKbqwxoT3I LjL1Bgj//ksGBb0XhdA48lBd5L12fUyzAeqgb70X9vXk+3M0T2AKypQUa34mzWVMsiX9 KiqFWI0voVeQiVIOmy35teBdq/Uw/DnqDDGYle7dE3edjamCAcpqhOEM2zDoaH02q0Cr VFKozt/B1UzUr0Cp/X5s9F+k1XwY4b5pkSF2gP7fCAPfkS+8BcWTk3BWkWCHmEgSbZCb JXhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KTEDuF6O; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z26si909133pfr.186.2019.05.29.14.07.45; Wed, 29 May 2019 14:08:00 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=KTEDuF6O; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbfE2VDL (ORCPT + 99 others); Wed, 29 May 2019 17:03:11 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:36017 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbfE2VDF (ORCPT ); Wed, 29 May 2019 17:03:05 -0400 Received: by mail-oi1-f194.google.com with SMTP id y124so3273008oiy.3 for ; Wed, 29 May 2019 14:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HrCXOU+Fm+D2XlSRN/oeiwuNWs703wLzrQB7UZuJ5ic=; b=KTEDuF6OHEwEqFAKEWrxlaTwkqrnqj7E9yKJ0O++zOhyyT4Fp5kRm5PM3usoPHtu/3 LjzFFhTrvV6ILOW0jympmFuRwzD0DMCfpI+fHJt4DZ7zrHwddOdVah83xhqgQv57aY92 k+8g4PiKSxk3hYqSjGtff1InjUdNb4ES6hebQmnP5kRDjK1Pqyzs240Jlxqi9S2MxO8m k58BERuICI8nv9UQ2xFzlnbdPf4y9UpfUIQCdonyOYVv0WhCddsh6sxut9+nvdPsSOXM Dz7KaqHhArEBPacWAdSJnzHETpCdV9Va1tCAhrXglXPP20wPYHMQfLZUEVZpFApyFCYR up8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HrCXOU+Fm+D2XlSRN/oeiwuNWs703wLzrQB7UZuJ5ic=; b=FNQC1G2/kEwIHmSgxsjYoFeFuStF+/PWlM/Vyy05iF5VrsUePuBMMfMD6fF6xpb4Fb 3OJvV7mtvW3nqUN2eWpdwiodTaQxxUO1lXuyb1KVy8CkDbO9hIK5sZ3NeBe1K3l1YqCh NRKp/OfZ0Ww+Mrkhowgwry+RYiZaKYdh3FNETIs/tRmDoPn+T8cRTFpmUAwMP4/QVqCb La95uEVPixm0ZeCKGML7REajNzdU0O+n0nFs9CImhS1N3MrlCwkErY4CzV9sQqmmnjE6 JBMx4/QQhpWGJhH/PAnHh7nrRskzrd0qcPPjctYx8mpunqvbM5LM6y+lYzLYg8w8cPRY qziA== X-Gm-Message-State: APjAAAWcPlX+6zenP9OS/2/SDzI5agEOkwmS8xkP5J23n5Brw9Xu2n4a elna2h28EqRkYmtgWjwnlb7koc8dwGMQVzJ3DnOgzQ== X-Received: by 2002:aca:f308:: with SMTP id r8mr193653oih.39.1559163784053; Wed, 29 May 2019 14:03:04 -0700 (PDT) MIME-Version: 1.0 References: <20190529113157.227380-1-jannh@google.com> <20190529162120.GB27659@redhat.com> In-Reply-To: <20190529162120.GB27659@redhat.com> From: Jann Horn Date: Wed, 29 May 2019 23:02:37 +0200 Message-ID: Subject: Re: [PATCH] ptrace: restore smp_rmb() in __ptrace_may_access() To: Oleg Nesterov Cc: "Eric W . Biederman" , Andrew Morton , Kees Cook , David Howells , kernel list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 29, 2019 at 6:21 PM Oleg Nesterov wrote: > On 05/29, Jann Horn wrote: > > --- a/kernel/ptrace.c > > +++ b/kernel/ptrace.c > > @@ -324,6 +324,16 @@ static int __ptrace_may_access(struct task_struct *task, unsigned int mode) [...] > > mm = task->mm; > > while at it, could you also change this into mm = READ_ONCE(task->mm) ? Actually, that shouldn't be necessary. The caller of __ptrace_may_access() holds the task_lock() on the task, and that should prevent concurrent updates of ->mm. If concurrent updates of ->mm *were* possible, we'd probably be in deep trouble here (and by that I mean use-after-free).