net/sunrpc/auth.c:725:34: sparse: sparse: incorrect type in initializer (different address spaces)

From: kernel test robot
Date: Mon Dec 25 2023 - 06:55:20 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 861deac3b092f37b2c5e6871732f3e11486f7082
commit: 5e16923b432bfe79fdfb7cd95ed8e63f6438b663 NFS/SUNRPC: don't lookup machine credential until rpcauth_bindcred().
date: 5 years ago
config: x86_64-randconfig-x001-20230717 (https://download.01.org/0day-ci/archive/20231225/202312251922.sGIFj35A-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231225/202312251922.sGIFj35A-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312251922.sGIFj35A-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> net/sunrpc/auth.c:725:34: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected struct cred const *cred @@ got struct cred const [noderef] __rcu *extern [addressable] [toplevel] cred @@
net/sunrpc/auth.c:725:34: sparse: expected struct cred const *cred
net/sunrpc/auth.c:725:34: sparse: got struct cred const [noderef] __rcu *extern [addressable] [toplevel] cred
net/sunrpc/auth.c: note: in included file:
include/linux/slab.h:332:43: sparse: sparse: dubious: x & !y
include/linux/slab.h:332:43: sparse: sparse: dubious: x & !y

vim +725 net/sunrpc/auth.c

718
719 static struct rpc_cred *
720 rpcauth_bind_machine_cred(struct rpc_task *task, int lookupflags)
721 {
722 struct rpc_auth *auth = task->tk_client->cl_auth;
723 struct auth_cred acred = {
724 .principal = task->tk_client->cl_principal,
> 725 .cred = init_task.cred,
726 };
727
728 if (!acred.principal)
729 return NULL;
730 dprintk("RPC: %5u looking up %s machine cred\n",
731 task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);
732 return auth->au_ops->lookup_cred(auth, &acred, lookupflags);
733 }
734

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki