NFS: change nfs_access_get_cached to only report the mask

Currently the nfs_access_get_cached family of functions report a
'struct nfs_access_entry' as the result, with both .mask and .cred set.
However the .cred is never used.  This is probably good and there is no
guarantee that it won't be freed before use.

Change to only report the 'mask' - as this is all that is used or needed.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
NeilBrown 2021-09-28 09:47:57 +10:00 committed by Anna Schumaker
parent c9e6606c7f
commit b5e7b59c34
3 changed files with 20 additions and 22 deletions

View file

@ -7611,7 +7611,7 @@ static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler,
const char *key, const void *buf,
size_t buflen, int flags)
{
struct nfs_access_entry cache;
u32 mask;
int ret;
if (!nfs_server_capable(inode, NFS_CAP_XATTR))
@ -7626,8 +7626,8 @@ static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler,
* do a cached access check for the XA* flags to possibly avoid
* doing an RPC and getting EACCES back.
*/
if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) {
if (!(cache.mask & NFS_ACCESS_XAWRITE))
if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) {
if (!(mask & NFS_ACCESS_XAWRITE))
return -EACCES;
}
@ -7648,14 +7648,14 @@ static int nfs4_xattr_get_nfs4_user(const struct xattr_handler *handler,
struct dentry *unused, struct inode *inode,
const char *key, void *buf, size_t buflen)
{
struct nfs_access_entry cache;
u32 mask;
ssize_t ret;
if (!nfs_server_capable(inode, NFS_CAP_XATTR))
return -EOPNOTSUPP;
if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) {
if (!(cache.mask & NFS_ACCESS_XAREAD))
if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) {
if (!(mask & NFS_ACCESS_XAREAD))
return -EACCES;
}
@ -7680,13 +7680,13 @@ nfs4_listxattr_nfs4_user(struct inode *inode, char *list, size_t list_len)
ssize_t ret, size;
char *buf;
size_t buflen;
struct nfs_access_entry cache;
u32 mask;
if (!nfs_server_capable(inode, NFS_CAP_XATTR))
return 0;
if (!nfs_access_get_cached(inode, current_cred(), &cache, true)) {
if (!(cache.mask & NFS_ACCESS_XALIST))
if (!nfs_access_get_cached(inode, current_cred(), &mask, true)) {
if (!(mask & NFS_ACCESS_XALIST))
return 0;
}