public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@primarydata.com>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfsd: silence sparse warning about accessing credentials
Date: Thu, 17 Jul 2014 16:16:50 -0400	[thread overview]
Message-ID: <20140717201649.GF30442@fieldses.org> (raw)
In-Reply-To: <1405443576-28348-1-git-send-email-jlayton@primarydata.com>

On Tue, Jul 15, 2014 at 12:59:36PM -0400, Jeff Layton wrote:
> sparse says:
> 
>     fs/nfsd/auth.c:31:38: warning: incorrect type in argument 1 (different address spaces)
>     fs/nfsd/auth.c:31:38:    expected struct cred const *cred
>     fs/nfsd/auth.c:31:38:    got struct cred const [noderef] <asn:4>*real_cred
> 
> Add a new accessor for the ->real_cred and use that to fetch the
> pointer. Accessing current->real_cred directly is actually quite safe
> since we know that they can't go away so this is mostly a cosmetic fixup
> to silence sparse.

Thanks, applying, absent any objections.

--b.

> 
> Signed-off-by: Jeff Layton <jlayton@primarydata.com>
> ---
>  fs/nfsd/auth.c       | 2 +-
>  include/linux/cred.h | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c
> index 72f44823adbb..9d46a0bdd9f9 100644
> --- a/fs/nfsd/auth.c
> +++ b/fs/nfsd/auth.c
> @@ -28,7 +28,7 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
>  	validate_process_creds();
>  
>  	/* discard any old override before preparing the new set */
> -	revert_creds(get_cred(current->real_cred));
> +	revert_creds(get_cred(current_real_cred()));
>  	new = prepare_creds();
>  	if (!new)
>  		return -ENOMEM;
> diff --git a/include/linux/cred.h b/include/linux/cred.h
> index f61d6c8f5ef3..b2d0820837c4 100644
> --- a/include/linux/cred.h
> +++ b/include/linux/cred.h
> @@ -259,6 +259,15 @@ static inline void put_cred(const struct cred *_cred)
>  	rcu_dereference_protected(current->cred, 1)
>  
>  /**
> + * current_real_cred - Access the current task's objective credentials
> + *
> + * Access the objective credentials of the current task.  RCU-safe,
> + * since nobody else can modify it.
> + */
> +#define current_real_cred() \
> +	rcu_dereference_protected(current->real_cred, 1)
> +
> +/**
>   * __task_cred - Access a task's objective credentials
>   * @task: The task to query
>   *
> -- 
> 1.9.3
> 

      reply	other threads:[~2014-07-17 20:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 16:59 [PATCH] nfsd: silence sparse warning about accessing credentials Jeff Layton
2014-07-17 20:16 ` J. Bruce Fields [this message]

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=20140717201649.GF30442@fieldses.org \
    --to=bfields@fieldses.org \
    --cc=jlayton@primarydata.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.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