Commit 96fca68c authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'nfsd-6.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux

Pull nfsd fixes from Chuck Lever:

 - Fix a potential tracepoint crash

 - Fix NFSv4 GETATTR on big-endian platforms

* tag 'nfsd-6.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux:
  NFSD: fix endianness issue in nfsd4_encode_fattr4
  SUNRPC: Fix rpcgss_context trace event acceptor field
parents cef27048 f488138b
...@@ -3490,11 +3490,13 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3490,11 +3490,13 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
struct dentry *dentry, const u32 *bmval, struct dentry *dentry, const u32 *bmval,
int ignore_crossmnt) int ignore_crossmnt)
{ {
DECLARE_BITMAP(attr_bitmap, ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops));
struct nfsd4_fattr_args args; struct nfsd4_fattr_args args;
struct svc_fh *tempfh = NULL; struct svc_fh *tempfh = NULL;
int starting_len = xdr->buf->len; int starting_len = xdr->buf->len;
__be32 *attrlen_p, status; __be32 *attrlen_p, status;
int attrlen_offset; int attrlen_offset;
u32 attrmask[3];
int err; int err;
struct nfsd4_compoundres *resp = rqstp->rq_resp; struct nfsd4_compoundres *resp = rqstp->rq_resp;
u32 minorversion = resp->cstate.minorversion; u32 minorversion = resp->cstate.minorversion;
...@@ -3502,10 +3504,6 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3502,10 +3504,6 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
.mnt = exp->ex_path.mnt, .mnt = exp->ex_path.mnt,
.dentry = dentry, .dentry = dentry,
}; };
union {
u32 attrmask[3];
unsigned long mask[2];
} u;
unsigned long bit; unsigned long bit;
bool file_modified = false; bool file_modified = false;
u64 size = 0; u64 size = 0;
...@@ -3521,20 +3519,19 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3521,20 +3519,19 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
/* /*
* Make a local copy of the attribute bitmap that can be modified. * Make a local copy of the attribute bitmap that can be modified.
*/ */
memset(&u, 0, sizeof(u)); attrmask[0] = bmval[0];
u.attrmask[0] = bmval[0]; attrmask[1] = bmval[1];
u.attrmask[1] = bmval[1]; attrmask[2] = bmval[2];
u.attrmask[2] = bmval[2];
args.rdattr_err = 0; args.rdattr_err = 0;
if (exp->ex_fslocs.migrated) { if (exp->ex_fslocs.migrated) {
status = fattr_handle_absent_fs(&u.attrmask[0], &u.attrmask[1], status = fattr_handle_absent_fs(&attrmask[0], &attrmask[1],
&u.attrmask[2], &args.rdattr_err); &attrmask[2], &args.rdattr_err);
if (status) if (status)
goto out; goto out;
} }
args.size = 0; args.size = 0;
if (u.attrmask[0] & (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE)) { if (attrmask[0] & (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE)) {
status = nfsd4_deleg_getattr_conflict(rqstp, d_inode(dentry), status = nfsd4_deleg_getattr_conflict(rqstp, d_inode(dentry),
&file_modified, &size); &file_modified, &size);
if (status) if (status)
...@@ -3553,16 +3550,16 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3553,16 +3550,16 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
if (!(args.stat.result_mask & STATX_BTIME)) if (!(args.stat.result_mask & STATX_BTIME))
/* underlying FS does not offer btime so we can't share it */ /* underlying FS does not offer btime so we can't share it */
u.attrmask[1] &= ~FATTR4_WORD1_TIME_CREATE; attrmask[1] &= ~FATTR4_WORD1_TIME_CREATE;
if ((u.attrmask[0] & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE | if ((attrmask[0] & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE |
FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) || FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) ||
(u.attrmask[1] & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE | (attrmask[1] & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
FATTR4_WORD1_SPACE_TOTAL))) { FATTR4_WORD1_SPACE_TOTAL))) {
err = vfs_statfs(&path, &args.statfs); err = vfs_statfs(&path, &args.statfs);
if (err) if (err)
goto out_nfserr; goto out_nfserr;
} }
if ((u.attrmask[0] & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) && if ((attrmask[0] & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) &&
!fhp) { !fhp) {
tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL); tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
status = nfserr_jukebox; status = nfserr_jukebox;
...@@ -3577,10 +3574,10 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3577,10 +3574,10 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
args.fhp = fhp; args.fhp = fhp;
args.acl = NULL; args.acl = NULL;
if (u.attrmask[0] & FATTR4_WORD0_ACL) { if (attrmask[0] & FATTR4_WORD0_ACL) {
err = nfsd4_get_nfs4_acl(rqstp, dentry, &args.acl); err = nfsd4_get_nfs4_acl(rqstp, dentry, &args.acl);
if (err == -EOPNOTSUPP) if (err == -EOPNOTSUPP)
u.attrmask[0] &= ~FATTR4_WORD0_ACL; attrmask[0] &= ~FATTR4_WORD0_ACL;
else if (err == -EINVAL) { else if (err == -EINVAL) {
status = nfserr_attrnotsupp; status = nfserr_attrnotsupp;
goto out; goto out;
...@@ -3592,17 +3589,17 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3592,17 +3589,17 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL #ifdef CONFIG_NFSD_V4_SECURITY_LABEL
args.context = NULL; args.context = NULL;
if ((u.attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) || if ((attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) ||
u.attrmask[0] & FATTR4_WORD0_SUPPORTED_ATTRS) { attrmask[0] & FATTR4_WORD0_SUPPORTED_ATTRS) {
if (exp->ex_flags & NFSEXP_SECURITY_LABEL) if (exp->ex_flags & NFSEXP_SECURITY_LABEL)
err = security_inode_getsecctx(d_inode(dentry), err = security_inode_getsecctx(d_inode(dentry),
&args.context, &args.contextlen); &args.context, &args.contextlen);
else else
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
args.contextsupport = (err == 0); args.contextsupport = (err == 0);
if (u.attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) { if (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) {
if (err == -EOPNOTSUPP) if (err == -EOPNOTSUPP)
u.attrmask[2] &= ~FATTR4_WORD2_SECURITY_LABEL; attrmask[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
else if (err) else if (err)
goto out_nfserr; goto out_nfserr;
} }
...@@ -3610,8 +3607,8 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3610,8 +3607,8 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */ #endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
/* attrmask */ /* attrmask */
status = nfsd4_encode_bitmap4(xdr, u.attrmask[0], status = nfsd4_encode_bitmap4(xdr, attrmask[0], attrmask[1],
u.attrmask[1], u.attrmask[2]); attrmask[2]);
if (status) if (status)
goto out; goto out;
...@@ -3620,7 +3617,9 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr, ...@@ -3620,7 +3617,9 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
attrlen_p = xdr_reserve_space(xdr, XDR_UNIT); attrlen_p = xdr_reserve_space(xdr, XDR_UNIT);
if (!attrlen_p) if (!attrlen_p)
goto out_resource; goto out_resource;
for_each_set_bit(bit, (const unsigned long *)&u.mask, bitmap_from_arr32(attr_bitmap, attrmask,
ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops));
for_each_set_bit(bit, attr_bitmap,
ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)) { ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)) {
status = nfsd4_enc_fattr4_encode_ops[bit](xdr, &args); status = nfsd4_enc_fattr4_encode_ops[bit](xdr, &args);
if (status != nfs_ok) if (status != nfs_ok)
......
...@@ -609,7 +609,7 @@ TRACE_EVENT(rpcgss_context, ...@@ -609,7 +609,7 @@ TRACE_EVENT(rpcgss_context,
__field(unsigned int, timeout) __field(unsigned int, timeout)
__field(u32, window_size) __field(u32, window_size)
__field(int, len) __field(int, len)
__string(acceptor, data) __string_len(acceptor, data, len)
), ),
TP_fast_assign( TP_fast_assign(
...@@ -618,7 +618,7 @@ TRACE_EVENT(rpcgss_context, ...@@ -618,7 +618,7 @@ TRACE_EVENT(rpcgss_context,
__entry->timeout = timeout; __entry->timeout = timeout;
__entry->window_size = window_size; __entry->window_size = window_size;
__entry->len = len; __entry->len = len;
strncpy(__get_str(acceptor), data, len); __assign_str(acceptor, data);
), ),
TP_printk("win_size=%u expiry=%lu now=%lu timeout=%u acceptor=%.*s", TP_printk("win_size=%u expiry=%lu now=%lu timeout=%u acceptor=%.*s",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment