mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: torvalds@osdl.org, akpm@linux-foundation.org,
	keyrings@linux-nfs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KEYS: Fix an RCU warning
Date: Wed, 07 Apr 2010 16:49:12 +0200	[thread overview]
Message-ID: <1270651752.8141.6.camel@edumazet-laptop> (raw)
In-Reply-To: <20100407141409.15200.53705.stgit@warthog.procyon.org.uk>

Le mercredi 07 avril 2010 à 15:14 +0100, David Howells a écrit :
> Fix the following RCU warning:

> 
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
> 
>  security/keys/request_key.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/request_key.c b/security/keys/request_key.c
> index 03fe63e..544e932 100644
> --- a/security/keys/request_key.c
> +++ b/security/keys/request_key.c
> @@ -112,10 +112,13 @@ static int call_sbin_request_key(struct key_construction *cons,
>  	if (cred->tgcred->process_keyring)
>  		prkey = cred->tgcred->process_keyring->serial;
>  
> -	if (cred->tgcred->session_keyring)
> +	if (cred->tgcred->session_keyring) {
> +		rcu_read_lock();
>  		sskey = rcu_dereference(cred->tgcred->session_keyring)->serial;
> -	else
> +		rcu_read_unlock();
> +	} else {
>  		sskey = cred->user->session_keyring->serial;
> +	}
>  
>  	sprintf(keyring_str[2], "%d", sskey);
>  

This fix is really wrong David.



You should instead do :

rcu_read_lock();
skeyring = rcu_dereference(cred->tgcred->session_keyring);
if (skeyring)
	sskey = sskeyring->serial;
else
	sskey = cred->user->session_keyring->serial;
rcu_read_unlock();




  reply	other threads:[~2010-04-07 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 14:14 David Howells
2010-04-07 14:49 ` Eric Dumazet [this message]
2010-04-20 10:25 David Howells
2010-04-20 12:46 ` Eric Dumazet
2010-04-21 20:11   ` Paul E. McKenney

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=1270651752.8141.6.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=keyrings@linux-nfs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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®