From patchwork Tue Jul 15 10:28:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 4552791 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 148779F1D6 for ; Tue, 15 Jul 2014 10:29:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2AD8D20123 for ; Tue, 15 Jul 2014 10:29:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29D4120122 for ; Tue, 15 Jul 2014 10:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758189AbaGOK3D (ORCPT ); Tue, 15 Jul 2014 06:29:03 -0400 Received: from mail-qc0-f181.google.com ([209.85.216.181]:36343 "EHLO mail-qc0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758158AbaGOK3D (ORCPT ); Tue, 15 Jul 2014 06:29:03 -0400 Received: by mail-qc0-f181.google.com with SMTP id w7so1798487qcr.26 for ; Tue, 15 Jul 2014 03:29:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=NknZbtDioqybU3zUGFlHer9pbxjOSwB0Q/uten5n5dg=; b=R4RqzhJxeZmlJOsaKkzdYKLVg5cKgPxmm3KyfsXGqGiwfAM+ZS6nI0yDs6anKE2amY 8Hb3z69E23IhwmkJEBA/cJhO4FJHStdnWCq5S7r638giHsaSeyrn1BoFQ2YJGSuU7FV1 iaq6EowId23mF2zBtmkpGYeSnqd9C/uW9EjjPwWaexW8VyIAubilvz42emEYo6EkuAv9 eNQpGYNsbq2ntvDiZuWdB4ghvwuEy+YQGNSNrFTDEIkOkseuDt5/D2Uuc3TZHe2LAiIA ym0+KuaJL4xgXndSyiKUHhVMHmdRWQBElkACoUF2VZH7CadLelIzBOF5ul2iiQiu2GmR dU0g== X-Gm-Message-State: ALoCoQnsHfGzY8d0dH3Cpccf8YLs3Htz9U15tf83aJM/cNQRvdjtiDVaA3vcPPexqZQb9gVYOi66 X-Received: by 10.140.95.241 with SMTP id i104mr31830064qge.6.1405420141172; Tue, 15 Jul 2014 03:29:01 -0700 (PDT) Received: from tlielax.poochiereds.net ([2001:470:8:d63:3a60:77ff:fe93:a95d]) by mx.google.com with ESMTPSA id w2sm5304340qab.17.2014.07.15.03.28.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Jul 2014 03:29:00 -0700 (PDT) From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH] nfsd: silence sparse warning about accessing credentials Date: Tue, 15 Jul 2014 06:28:54 -0400 Message-Id: <1405420134-3736-1-git-send-email-jlayton@primarydata.com> X-Mailer: git-send-email 1.9.3 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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] *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. Signed-off-by: Jeff Layton Reviewed-by: Christoph Hellwig --- 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 *