Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1294857imu; Wed, 16 Jan 2019 16:36:22 -0800 (PST) X-Google-Smtp-Source: ALg8bN5oJmddPO8t43rcEdLWV5A/46U+LSQj1T5xq/OnyY4wSDe3Ojg+h3J9ilScVhfJFlpz5Oc2 X-Received: by 2002:a62:140a:: with SMTP id 10mr12566700pfu.157.1547685382434; Wed, 16 Jan 2019 16:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547685382; cv=none; d=google.com; s=arc-20160816; b=UwM/QFT9jRESJ/R8XBTB1NFZ3lg7BGixQDxqFyu3TQJuvprWVc/yAlnVBiAAN6iNHY Z9Ht1UAU0joA6IaOEVVJGk2WEn8Q/H2X+bTJaR3IgfhuEyHlZfS4C2pO73P/pjjWrvSr 0dwahMtlanaeifyaDysw0UCYj+oSqRjOCJhlQICENyffJJA/rljKNiBhxISIoKE8Nz5C LoTDZrrue3UZ3JK5z/+UUpXKQf9abXSCbZ3q56hbfwOdt1N5fCps/L45li4Jfeqwij6t g4SuXP4OLYjZBhvJmStH0weYwyQa+slIbLcYjfN7MDyt/7y1pOYmBj33MKdyV742Jm1e ybfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=fE02b5MeeMjfNEheq4soff6/ocTCSE80EpRdWmQc0/k=; b=v4yH6r3RLqRkZToZVQUnr06JeE2Gk173moSls9MuHAo/sM75rD299ASbUBNLSc9CX0 4BsLwLSPtHqycoovnWWyCJb1MBllPeQNi+QfproY47PcvajqbWDYSD0Pt3roklk99QrJ 40/Cm6y3GquswDlhZrlMurWJT+ei1IH8Ss55f4pOK8RmWn33e0J9aiXKWVxKW9lPk/xc yugr8Q9jsFgyvso6DR6J3U5Ui0N4f4jK2muSbcyeNtKw9KlyzsdMvZUHYs7RKrjclnE8 c10SNnhFvOB2yAEjjNC4k0NXoCjgILbxCAiFUsRNxkPSY1bsWS7ApcvnQ1RO7mlZZ803 n4dQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c31si7610124pgc.465.2019.01.16.16.36.03; Wed, 16 Jan 2019 16:36:22 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732069AbfAPUDV (ORCPT + 99 others); Wed, 16 Jan 2019 15:03:21 -0500 Received: from namei.org ([65.99.196.166]:56360 "EHLO namei.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732035AbfAPUDU (ORCPT ); Wed, 16 Jan 2019 15:03:20 -0500 Received: from localhost (localhost [127.0.0.1]) by namei.org (8.14.4/8.14.4) with ESMTP id x0GK2pdP003316; Wed, 16 Jan 2019 20:02:51 GMT Date: Thu, 17 Jan 2019 07:02:51 +1100 (AEDT) From: James Morris To: Kees Cook cc: Oleg Nesterov , Tetsuo Handa , "Serge E. Hallyn" , LKML , linux-security-module , syzbot , syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] Yama: Check for pid death before checking ancestry In-Reply-To: Message-ID: References: <20190116183109.GA21722@beast> User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 17 Jan 2019, James Morris wrote: > On Wed, 16 Jan 2019, Kees Cook wrote: > > > It's possible that a pid has died before we take the rcu lock, in which > > case we can't walk the ancestry list as it may be detached. Instead, check > > for death first before doing the walk. > > > > Reported-by: syzbot+a9ac39bf55329e206219@syzkaller.appspotmail.com > > Fixes: 2d514487faf1 ("security: Yama LSM") > > Cc: stable@vger.kernel.org > > Suggested-by: Oleg Nesterov > > Signed-off-by: Kees Cook > > --- > > James, can you please send this to Linus in your -fixes tree? > > Done. I mean, queued in that tree. > > > --- > > security/yama/yama_lsm.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c > > index ffda91a4a1aa..02514fe558b4 100644 > > --- a/security/yama/yama_lsm.c > > +++ b/security/yama/yama_lsm.c > > @@ -368,7 +368,9 @@ static int yama_ptrace_access_check(struct task_struct *child, > > break; > > case YAMA_SCOPE_RELATIONAL: > > rcu_read_lock(); > > - if (!task_is_descendant(current, child) && > > + if (!pid_alive(child)) > > + rc = -EPERM; > > + if (!rc && !task_is_descendant(current, child) && > > !ptracer_exception_found(current, child) && > > !ns_capable(__task_cred(child)->user_ns, CAP_SYS_PTRACE)) > > rc = -EPERM; > > > > -- James Morris