Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3304986imu; Sun, 11 Nov 2018 12:01:16 -0800 (PST) X-Google-Smtp-Source: AJdET5fqucXZ/erIwz3PuMpgBpiU5NuXDAU28TMPgTX5up3J9IpwyAzPBXIfiQ47CuYBGahiSroW X-Received: by 2002:a17:902:128c:: with SMTP id g12-v6mr13075967pla.143.1541966476726; Sun, 11 Nov 2018 12:01:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966476; cv=none; d=google.com; s=arc-20160816; b=HE21Cc4es5flfDbRClxHbMXoIDJ33xg/O0mXZJiawb3euuts+nnQUQikoyvNTGPf/x vutE/k6FZUkxRm5k/DPUwUgkyKnbm3BejEtjK9Y0gkdRrwYfPQaur5+d3bpdJxN3aLwC pdUKbSoO1HWXAKw+GqHoMYoYJ0K4rBy+tDJZzJo52OGKJkBzg/Cg4u5UVbOJR2felKO5 j1bmiiLhYY3TCV/rBSTQh0UXcK7dRUHlvmDQBSTvTLiKM4ktjboyOvSH7Fyn18BEAN98 0S20aGmDyI7u2OdZeTt6gRygtUizNOrb+p72lAoZo1CM61dQcynaYpJzW6FXaxHtyGvj yJBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=e15rpZPXW4zpGNUj8fB97NKcy8GdGwZ3ZmSOZblnDko=; b=0PMSjZEtTQyxr0yiE0Vzo7d1DaEX6DgQ/NEDGqxX1aNEGCy1NRRvktL0BfAuxFX90c 7ZvI+cPhIQ1wLkf2a1kSjQLsUoYLV76tYf/1UhOycMW7wEbZq8hW9ILfOC7Qcq3tFm0p 28q9gDNSJJgxHQz6MgieUE81YNnYfB1romtPdsTH0muFK5KSO1jaY2KWO7v6vOU2kriF +rC4QyzMznOM49gIp5O5H+pXyWr60OxOwe9IV1dzyZIQ1Im8B3k9qopUHrnVAPprQF9x sTWH5rNT3jxUXiyXUk5QjwmJw7xuy3OjS2+rZ1yN5Ze+EoduJi7vGtZpd8r7QzaRGyiL fyAA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si15335547plm.126.2018.11.11.12.01.01; Sun, 11 Nov 2018 12:01:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729426AbeKLFtY (ORCPT + 99 others); Mon, 12 Nov 2018 00:49:24 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51324 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730845AbeKLFsf (ORCPT ); Mon, 12 Nov 2018 00:48:35 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsw-0000tu-DS; Sun, 11 Nov 2018 19:59:06 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsU-0001do-Hg; Sun, 11 Nov 2018 19:58:38 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "J. Bruce Fields" , "Jeff Layton" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 201/366] nfsd: silence sparse warning about accessing credentials In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Jeff Layton commit ae4b884fc6316b3190be19448cea24b020c1cad6 upstream. 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 Signed-off-by: J. Bruce Fields Signed-off-by: Ben Hutchings --- fs/nfsd/auth.c | 2 +- include/linux/cred.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c @@ -28,7 +28,7 @@ int nfsd_setuser(struct svc_rqst *rqstp, 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; --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -261,6 +261,15 @@ static inline void put_cred(const struct 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 *