NFSv4: Observe the NFS_MOUNT_SOFTREVAL flag in _nfs4_proc_lookupp
Subsystems (2)
Hello Trond Myklebust,
This is a new checker rule Harshit and I wrote.
Commit 76998ebb9158 ("NFSv4: Observe the NFS_MOUNT_SOFTREVAL flag in _nfs4_proc_lookupp") from Oct 20, 2020 (linux-next), leads to the following Smatch static checker warning:
fs/nfs/nfs4proc.c:783 nfs4_init_sequence() warn: potentially more than 1 'args->sa_cache_this = 0x1001' type='uchar'
fs/nfs/nfs4proc.c
778 void nfs4_init_sequence(struct nfs4_sequence_args *args,
779 struct nfs4_sequence_res *res, int cache_reply,
780 int privileged)
781 {
782 args->sa_slot = NULL;
--> 783 args->sa_cache_this = cache_reply;
args->sa_cache_this is a 1 bit bitfield in a u8, but the commit mentioned is passing RPC_TASK_TIMEOUT (0x1000). Should this code be changed to:
args->sa_cache_this = cache_reply & RPC_TASK_ASYNC;
Probably not... _nfs4_proc_lookupp() is the only caller which passes anything other than zero.
784 args->sa_privileged = privileged;
785
786 res->sr_slot = NULL;
787 }regards,
dan carpenter
Trond Myklebust
maintainerQuoted 31 lines · Dan Carpenter
Hello Trond Myklebust,
This is a new checker rule Harshit and I wrote.
Commit
76998ebb9158("NFSv4: Observe theNFS_MOUNT_SOFTREVALflag in_nfs4_proc_lookupp") from Oct 20, 2020 (linux-next), leads to the following Smatch static checker warning:fs/nfs/nfs4proc.c:783 nfs4_init_sequence() warn: potentially more than 1 'args->sa_cache_this = 0x1001'type='uchar'
fs/nfs/nfs4proc.c
778 void nfs4_init_sequence(structnfs4_sequence_args*args, 779 structnfs4_sequence_res*res, intcache_reply,
780 int privileged)
781 {
782args->sa_slot= NULL;
--> 783args->sa_cache_this=cache_reply;
args->sa_cache_thisis a 1 bit bitfield in a u8, but the commit mentioned
is passingRPC_TASK_TIMEOUT(0x1000). Should this code be changed to:args->sa_cache_this = cache_reply & RPC_TASK_ASYNC;Probably not...
_nfs4_proc_lookupp()is the only caller which passes anything other than zero.
Quoted 7 lines
784
args->sa_privileged= privileged;
785
786res->sr_slot= NULL;
787 }regards,
dan carpenter
Oops... That's definitely a bug in the lookupp code. Thanks for finding it!
That function should probably be calling nfs4_init_sequence() directly, and then using nfs4_do_call_sync() to pass the RPC_TASK_TIMEOUT flag down to the RPC layer.
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected], [email protected]