Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1397638ybv; Thu, 6 Feb 2020 03:22:54 -0800 (PST) X-Google-Smtp-Source: APXvYqz+wHOdCDrKDWjFhl7tkUjxL7ItOW7n9afDgYUxVFGgAvxF7abDfYjt8bgU1yAoX5oOSQsf X-Received: by 2002:aca:3857:: with SMTP id f84mr6200877oia.150.1580988174629; Thu, 06 Feb 2020 03:22:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580988174; cv=none; d=google.com; s=arc-20160816; b=qn1nUYBc9s0D7AgU5zgPJblSxfgn29ufaZYxObjigydXEsro0/QNlmXzpTu2XacBz/ wPr2uAPNj3Wk6DdmwZ5EiU5RDcx5MCoMDKrZvk0ShibXgkB0gpynYGN71gjW6i+qc0j1 fUaiRF/XxtQKGjzUizieUvt3ezBp4CWlLo6lj9vRfyBBczFZrUKhAJvSrfUzgyCcP9mA 7Ki9vNqAS/+qv5VO+amXcWJQjs5vO37+D50sUA6CRqIa2tdB5Phq0En4Y2rEjhtPq18T yB/Sz/0/IEUp7pFG2JEba14y6w+SWNIF2Suw9dJNtScPXY/xPt9eLxL8Negk0N4iZI6X MOkg== 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:date:from:dkim-signature; bh=B8bvNpykVDgQC9hk3603Rl2GIFzoG6wwUdwHDUabs1k=; b=EQZByQayrSU8ERDS9ZGajMGeYEn2EVFLkDx3pFm+2POepoAfdXa5H8cgQfd+kr6cy0 C8xqyApvyZREpl3yOWVGsBAU+xtSKHxiOuerReNBLgven8IO/jBqV4uLdpE/WugoOHYk EQo2AXjPBNY0qraXErCRM/1vrKtRlhfEzzNm0X0qyYFM360pqyAIaJaPkSawO8Uwursb SWWxrm26Hnvo04dTUg8dz0N+bA9aJP4McXfT1P5Gc/DLd7NpWlna2+8u4vzPPR2LXhVX BdkJRP4Iz+w/kGfwUzPfCdzxjDTYRtl0E48NuzUrcRm9A81sCxbVxBdG/rgpvlxUpJsP oKrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O7G9Vc2A; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f14si1704936otf.178.2020.02.06.03.22.42; Thu, 06 Feb 2020 03:22:54 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O7G9Vc2A; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727501AbgBFLH1 (ORCPT + 99 others); Thu, 6 Feb 2020 06:07:27 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35122 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727478AbgBFLH1 (ORCPT ); Thu, 6 Feb 2020 06:07:27 -0500 Received: by mail-pf1-f193.google.com with SMTP id y73so2970259pfg.2 for ; Thu, 06 Feb 2020 03:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=B8bvNpykVDgQC9hk3603Rl2GIFzoG6wwUdwHDUabs1k=; b=O7G9Vc2AuE7mWt1YBeW9+Ncjcl07/rGGQN4eDuXaG/UUfLFuxP67P/JA+D+N76FpW3 xmMRSR/LhBebqdf6QRe8A0SeF3nIYkxiQqEekdjDPArG7ziwyIeiA5IoibNZrhxP4U2l 9lr/87MlY0pDwN7xQ9BYGahOhhJLdYRua93qFY8i1S8Ys1MIW5v6fIuw6fE01GtRztld XnSAQyEzMPlVl05jaW/a9RiELZgQw/N3jXa0G+JEIWQrXUvAT6ZdH7+5jmHPdYcaq/z8 +LleDSauaxtYE9cmn0D7JE3m8fpEEzUCcNOrJ6fmhQCyF0NTUNPLP954mm8i7rRobQOZ kAqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=B8bvNpykVDgQC9hk3603Rl2GIFzoG6wwUdwHDUabs1k=; b=O/ZlJD35HQC/05NatRCS9ZECtkn0l8LYRBZYF6AQEL77zuWyGXbC1czAVjSxHdyNc0 MVNPv13SE6zpcW/+nKGMPewXq7PDSIgLQ1GeQvZeugoekYy09DfvSiJ1jSl7a+U64Q30 An/IdSQadlXaFKmiJgi2dGAQFOy5zgThEzQNgAOgVKvvIK+UtXWfNY9liiNpFFDLqCMT AyVxBnNRWPt7TBMAYweFKm7kwZYZTesGRtJNLlgTsmydjooThOrAAy8tvSztrUdFcgbu IwiSPbnE3+p5Qg37y1sMJywq72MJ7+Tgxi+WycH40psrZDCdL/YyI1KuR3p9ITNjvg8c 1FbA== X-Gm-Message-State: APjAAAU9CdF4uY9iBlB+5H7pH9dFDgr3aJ5U+g5gFeJ8/bi4bD93JQvh PRsoAn7eJP2Dixqu1HfkXLG1IwU= X-Received: by 2002:a17:902:9b93:: with SMTP id y19mr3063945plp.89.1580986859115; Thu, 06 Feb 2020 03:00:59 -0800 (PST) Received: from madhuparna-HP-Notebook ([218.248.46.83]) by smtp.gmail.com with ESMTPSA id y75sm3068441pfb.116.2020.02.06.03.00.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2020 03:00:58 -0800 (PST) From: Madhuparna Bhowmik X-Google-Original-From: Madhuparna Bhowmik Date: Thu, 6 Feb 2020 16:30:51 +0530 To: "Eric W. Biederman" Cc: madhuparnabhowmik10@gmail.com, ebiederm@xmission.com, oleg@redhat.com, christian.brauner@ubuntu.com, guro@fb.com, tj@kernel.org, linux-kernel@vger.kernel.org, paulmck@kernel.org, joel@joelfernandes.org, linux-kernel-mentees@lists.linuxfoundation.org, frextrite@gmail.com Subject: Re: [PATCH] signal.c: Fix sparse warnings Message-ID: <20200206110051.GA4531@madhuparna-HP-Notebook> References: <20200205172437.10113-1-madhuparnabhowmik10@gmail.com> <87wo90myhj.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87wo90myhj.fsf@x220.int.ebiederm.org> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 05, 2020 at 04:59:52PM -0600, Eric W. Biederman wrote: > madhuparnabhowmik10@gmail.com writes: > > > From: Madhuparna Bhowmik > > > > This patch fixes the following two sparse warnings caused due to > > accessing RCU protected pointer tsk->parent without rcu primitives. > > > > kernel/signal.c:1948:65: warning: incorrect type in argument 1 (different address spaces) > > kernel/signal.c:1948:65: expected struct task_struct *tsk > > kernel/signal.c:1948:65: got struct task_struct [noderef] *parent > > kernel/signal.c:1949:40: warning: incorrect type in argument 1 (different address spaces) > > kernel/signal.c:1949:40: expected void const volatile *p > > kernel/signal.c:1949:40: got struct cred const [noderef] *[noderef] * > > kernel/signal.c:1949:40: warning: incorrect type in argument 1 (different address spaces) > > kernel/signal.c:1949:40: expected void const volatile *p > > kernel/signal.c:1949:40: got struct cred const [noderef] *[noderef] * > > > > Signed-off-by: Madhuparna Bhowmik > > --- > > kernel/signal.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/kernel/signal.c b/kernel/signal.c > > index 9ad8dea93dbb..8227058ea8c4 100644 > > --- a/kernel/signal.c > > +++ b/kernel/signal.c > > @@ -1945,8 +1945,8 @@ bool do_notify_parent(struct task_struct *tsk, int sig) > > * correct to rely on this > > */ > > rcu_read_lock(); > > - info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(tsk->parent)); > > - info.si_uid = from_kuid_munged(task_cred_xxx(tsk->parent, user_ns), > > + info.si_pid = task_pid_nr_ns(tsk, task_active_pid_ns(rcu_dereference(tsk->parent))); > > + info.si_uid = from_kuid_munged(task_cred_xxx(rcu_dereference(tsk->parent), user_ns), > > task_uid(tsk)); > > rcu_read_unlock(); > > > Still wrong because that access fundamentally depends upon the > task_list_lock no the rcu_read_lock. Things need to be consistent for > longer than the rcu_read_lock is held. > Okay, then how about something like rcu_dereference_protected(tsk->parent, lockdep_is_held(&tasklist_lock))? Let me know if this looks fine to you. Thank you, Madhuparna > This patch makes sparse happy and confuses programmers who are trying to > read the code. > > > Eric