Skip to contentSkip to conversation

fs/nfsd/nfs4xdr.c:4200:18: sparse: sparse: incorrect type in assignment (different base types)

PATCH kernel test robot 2 participants 2 messages Jul 30 – Jul 31

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux nfsd-testing
head:   67be65963a6470b667125cc648b56161ed3dfdce
commit: 4b64b811f368bcd98a5a11f7079f863db3a2e1c5 [110/222] nfsd: add notification handlers for dir events
config: m68k-randconfig-r122-20260730 (https://download.01.org/0day-ci/archive/20260731/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 13.4.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260731/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> fs/nfsd/nfs4xdr.c:4200:18: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] *attrmask @@     got restricted __be32 [usertype] * @@

fs/nfsd/nfs4xdr.c:4200:18: sparse: expected unsigned int [usertype] *attrmask
fs/nfsd/nfs4xdr.c:4200:18: sparse: got restricted __be32 [usertype] *

vim +4200 fs/nfsd/nfs4xdr.c

4191
4192 static bool
4193 nfsd4_setup_notify_entry4(struct notify_entry4 *ne, struct xdr_stream *xdr,
4194 struct dentry *dentry, struct nfs4_delegation *dp,
4195 struct nfsd_file *nf, char *name, u32 namelen)
4196 {
4197 uint32_t *attrmask;
4198
4199 /* Reserve space for attrmask */

> 4200		attrmask = xdr_reserve_space(xdr, 3 * sizeof(uint32_t));

4201 if (!attrmask)
4202 return false;
4203
4204 ne->ne_file.data = name;
4205 ne->ne_file.len = namelen;
4206 ne->ne_attrs.attrmask.element = attrmask;
4207
4208 attrmask[0] = 0;
4209 attrmask[1] = 0;
4210 attrmask[2] = 0;
4211 ne->ne_attrs.attr_vals.data = NULL;
4212 ne->ne_attrs.attr_vals.len = 0;
4213 ne->ne_attrs.attrmask.count = 1;
4214 return true;
4215 }
4216

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

#1 lore raw
Quoted 56 lines · kernel test robot

tree: https://git.kernel.org/pub/scm/linux/kernel/git/cel/linux
nfsd-testing

head:   67be65963a6470b667125cc648b56161ed3dfdce
commit: 4b64b811f368bcd98a5a11f7079f863db3a2e1c5 [110/222] nfsd: add 

notification handlers for dir events
config: m68k-randconfig-r122-20260730
(https://download.01.org/0day-ci/archive/20260731/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 13.4.0
sparse: v0.6.5-rc1
reproduce (this is a W=1 build):
(https://download.01.org/0day-ci/archive/20260731/[email protected]/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 <[email protected]>
| Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

fs/nfsd/nfs4xdr.c:4200:18: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] *attrmask @@ got restricted __be32 [usertype] * @@

fs/nfsd/nfs4xdr.c:4200:18: sparse: expected unsigned int
[usertype] *attrmask
fs/nfsd/nfs4xdr.c:4200:18: sparse: got restricted __be32
[usertype] *

vim +4200 fs/nfsd/nfs4xdr.c

4191
4192 static bool
4193 nfsd4_setup_notify_entry4(struct notify_entry4 *ne, struct
xdr_stream *xdr,
4194 struct dentry *dentry, struct nfs4_delegation *dp,
4195 struct nfsd_file *nf, char *name, u32 namelen)
4196 {
4197 uint32_t *attrmask;
4198
4199 /* Reserve space for attrmask */

Quoted 1 line

4200 attrmask = xdr_reserve_space(xdr, 3 * sizeof(uint32_t));

4201 if (!attrmask)
4202 return false;
4203
4204 ne->ne_file.data = name;
4205 ne->ne_file.len = namelen;
4206 ne->ne_attrs.attrmask.element = attrmask;
4207
4208 attrmask[0] = 0;
4209 attrmask[1] = 0;
4210 attrmask[2] = 0;
4211 ne->ne_attrs.attr_vals.data = NULL;
4212 ne->ne_attrs.attr_vals.len = 0;
4213 ne->ne_attrs.attrmask.count = 1;
4214 return true;
4215 }
4216

Quoted 3 lines

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

Jeff, I actually can't tell how to fix this.

The obvious problem is that xdr_reserve_space() returns a __be32 * not a uint32_t * ... then the code sets the values of the attribute mask, in an XDR buffer, to host-endian zeroes instead of network-endian zeroes. (equivalent but not semantically the same). If the attrmask.count is 1, why set three bitmask4 entries? Or is this reserving buffer space for more than just the bitmask4 ?

Signature · 1 line
Chuck Lever