* [bug report] SUNRPC: simplify auth_unix.
@ 2018-12-21 9:10 Dan Carpenter
2019-01-07 6:53 ` [PATCH] SUNRPC: remove pointless test in unx_match() NeilBrown
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2018-12-21 9:10 UTC (permalink / raw)
To: neilb; +Cc: linux-nfs
Hello NeilBrown,
This is a semi-automatic email about new static checker warnings.
The patch 394f319df78e: "SUNRPC: simplify auth_unix." from Dec 3,
2018, leads to the following Smatch complaint:
net/sunrpc/auth_unix.c:90 unx_match()
warn: variable dereferenced before check 'acred->cred' (see line 87)
net/sunrpc/auth_unix.c
86
87 if (!uid_eq(cred->cr_cred->fsuid, acred->cred->fsuid) || !gid_eq(cred->cr_cred->fsgid, acred->cred->fsgid))
^^^^^^^^^^^
New dereference
88 return 0;
89
90 if (acred->cred && acred->cred->group_info != NULL)
^^^^^^^^^^^
But the old code checked for NULL
91 groups = acred->cred->group_info->ngroups;
92 if (groups > UNX_NGROUPS)
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] SUNRPC: remove pointless test in unx_match()
2018-12-21 9:10 [bug report] SUNRPC: simplify auth_unix Dan Carpenter
@ 2019-01-07 6:53 ` NeilBrown
2019-02-21 22:39 ` Trond Myklebust
0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2019-01-07 6:53 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker; +Cc: Dan Carpenter, linux-nfs
[-- Attachment #1: Type: text/plain, Size: 1084 bytes --]
As reported by Dan Carpenter, this test for acred->cred being set is
inconsistent with the dereference of the pointer a few lines earlier.
An 'auth_cred' *always* has ->cred set - every place that creates one
initializes this field, often as the first thing done.
So remove this test.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NeilBrown <neilb@suse.com>
---
net/sunrpc/auth_unix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c
index 387f6b3ffbea..770e338a9b11 100644
--- a/net/sunrpc/auth_unix.c
+++ b/net/sunrpc/auth_unix.c
@@ -87,7 +87,7 @@ unx_match(struct auth_cred *acred, struct rpc_cred *cred, int flags)
if (!uid_eq(cred->cr_cred->fsuid, acred->cred->fsuid) || !gid_eq(cred->cr_cred->fsgid, acred->cred->fsgid))
return 0;
- if (acred->cred && acred->cred->group_info != NULL)
+ if (acred->cred->group_info != NULL)
groups = acred->cred->group_info->ngroups;
if (groups > UNX_NGROUPS)
groups = UNX_NGROUPS;
--
2.14.0.rc0.dirty
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] SUNRPC: remove pointless test in unx_match()
2019-01-07 6:53 ` [PATCH] SUNRPC: remove pointless test in unx_match() NeilBrown
@ 2019-02-21 22:39 ` Trond Myklebust
0 siblings, 0 replies; 3+ messages in thread
From: Trond Myklebust @ 2019-02-21 22:39 UTC (permalink / raw)
To: anna.schumaker, neilb; +Cc: dan.carpenter, linux-nfs
On Mon, 2019-01-07 at 17:53 +1100, NeilBrown wrote:
> As reported by Dan Carpenter, this test for acred->cred being set is
> inconsistent with the dereference of the pointer a few lines earlier.
>
> An 'auth_cred' *always* has ->cred set - every place that creates one
> initializes this field, often as the first thing done.
>
> So remove this test.
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
>
Thanks Neil! Applied to the linux-next branch for inclusion in the 5.1
merge window.
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-02-21 22:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-21 9:10 [bug report] SUNRPC: simplify auth_unix Dan Carpenter
2019-01-07 6:53 ` [PATCH] SUNRPC: remove pointless test in unx_match() NeilBrown
2019-02-21 22:39 ` Trond Myklebust
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.