mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
To: "Eric W. Biederman" <ebiederm@gmail.com>
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
Date: Thu, 6 Feb 2020 16:30:51 +0530	[thread overview]
Message-ID: <20200206110051.GA4531@madhuparna-HP-Notebook> (raw)
In-Reply-To: <87wo90myhj.fsf@x220.int.ebiederm.org>

On Wed, Feb 05, 2020 at 04:59:52PM -0600, Eric W. Biederman wrote:
> madhuparnabhowmik10@gmail.com writes:
> 
> > From: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> >
> > 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] <asn:4> *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] <asn:4> *[noderef] <asn:4> *
> > 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] <asn:4> *[noderef] <asn:4> *
> >
> > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
> > ---
> >  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

  reply	other threads:[~2020-02-06 11:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 17:24 madhuparnabhowmik10
2020-02-05 22:59 ` Eric W. Biederman
2020-02-06 11:00   ` Madhuparna Bhowmik [this message]
2020-02-06 20:25     ` Joel Fernandes
2020-02-07 15:04       ` Madhuparna Bhowmik
  -- strict thread matches above, loose matches on Subject: below --
2020-02-05 16:23 madhuparnabhowmik10
2020-02-05 16:51 ` Amol Grover
2020-02-05 17:09   ` Madhuparna Bhowmik

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=20200206110051.GA4531@madhuparna-HP-Notebook \
    --to=madhuparnabhowmik10@gmail.com \
    --cc=christian.brauner@ubuntu.com \
    --cc=ebiederm@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=frextrite@gmail.com \
    --cc=guro@fb.com \
    --cc=joel@joelfernandes.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=tj@kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®