Skip to content

Commit 96fca68

Browse files
committed
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
2 parents cef2704 + f488138 commit 96fca68

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,22 +3490,20 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
34903490
struct dentry *dentry, const u32 *bmval,
34913491
int ignore_crossmnt)
34923492
{
3493+
DECLARE_BITMAP(attr_bitmap, ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops));
34933494
struct nfsd4_fattr_args args;
34943495
struct svc_fh *tempfh = NULL;
34953496
int starting_len = xdr->buf->len;
34963497
__be32 *attrlen_p, status;
34973498
int attrlen_offset;
3499+
u32 attrmask[3];
34983500
int err;
34993501
struct nfsd4_compoundres *resp = rqstp->rq_resp;
35003502
u32 minorversion = resp->cstate.minorversion;
35013503
struct path path = {
35023504
.mnt = exp->ex_path.mnt,
35033505
.dentry = dentry,
35043506
};
3505-
union {
3506-
u32 attrmask[3];
3507-
unsigned long mask[2];
3508-
} u;
35093507
unsigned long bit;
35103508
bool file_modified = false;
35113509
u64 size = 0;
@@ -3521,20 +3519,19 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
35213519
/*
35223520
* Make a local copy of the attribute bitmap that can be modified.
35233521
*/
3524-
memset(&u, 0, sizeof(u));
3525-
u.attrmask[0] = bmval[0];
3526-
u.attrmask[1] = bmval[1];
3527-
u.attrmask[2] = bmval[2];
3522+
attrmask[0] = bmval[0];
3523+
attrmask[1] = bmval[1];
3524+
attrmask[2] = bmval[2];
35283525

35293526
args.rdattr_err = 0;
35303527
if (exp->ex_fslocs.migrated) {
3531-
status = fattr_handle_absent_fs(&u.attrmask[0], &u.attrmask[1],
3532-
&u.attrmask[2], &args.rdattr_err);
3528+
status = fattr_handle_absent_fs(&attrmask[0], &attrmask[1],
3529+
&attrmask[2], &args.rdattr_err);
35333530
if (status)
35343531
goto out;
35353532
}
35363533
args.size = 0;
3537-
if (u.attrmask[0] & (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE)) {
3534+
if (attrmask[0] & (FATTR4_WORD0_CHANGE | FATTR4_WORD0_SIZE)) {
35383535
status = nfsd4_deleg_getattr_conflict(rqstp, d_inode(dentry),
35393536
&file_modified, &size);
35403537
if (status)
@@ -3553,16 +3550,16 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
35533550

35543551
if (!(args.stat.result_mask & STATX_BTIME))
35553552
/* underlying FS does not offer btime so we can't share it */
3556-
u.attrmask[1] &= ~FATTR4_WORD1_TIME_CREATE;
3557-
if ((u.attrmask[0] & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE |
3553+
attrmask[1] &= ~FATTR4_WORD1_TIME_CREATE;
3554+
if ((attrmask[0] & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE |
35583555
FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) ||
3559-
(u.attrmask[1] & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
3556+
(attrmask[1] & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
35603557
FATTR4_WORD1_SPACE_TOTAL))) {
35613558
err = vfs_statfs(&path, &args.statfs);
35623559
if (err)
35633560
goto out_nfserr;
35643561
}
3565-
if ((u.attrmask[0] & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) &&
3562+
if ((attrmask[0] & (FATTR4_WORD0_FILEHANDLE | FATTR4_WORD0_FSID)) &&
35663563
!fhp) {
35673564
tempfh = kmalloc(sizeof(struct svc_fh), GFP_KERNEL);
35683565
status = nfserr_jukebox;
@@ -3577,10 +3574,10 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
35773574
args.fhp = fhp;
35783575

35793576
args.acl = NULL;
3580-
if (u.attrmask[0] & FATTR4_WORD0_ACL) {
3577+
if (attrmask[0] & FATTR4_WORD0_ACL) {
35813578
err = nfsd4_get_nfs4_acl(rqstp, dentry, &args.acl);
35823579
if (err == -EOPNOTSUPP)
3583-
u.attrmask[0] &= ~FATTR4_WORD0_ACL;
3580+
attrmask[0] &= ~FATTR4_WORD0_ACL;
35843581
else if (err == -EINVAL) {
35853582
status = nfserr_attrnotsupp;
35863583
goto out;
@@ -3592,26 +3589,26 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
35923589

35933590
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
35943591
args.context = NULL;
3595-
if ((u.attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) ||
3596-
u.attrmask[0] & FATTR4_WORD0_SUPPORTED_ATTRS) {
3592+
if ((attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) ||
3593+
attrmask[0] & FATTR4_WORD0_SUPPORTED_ATTRS) {
35973594
if (exp->ex_flags & NFSEXP_SECURITY_LABEL)
35983595
err = security_inode_getsecctx(d_inode(dentry),
35993596
&args.context, &args.contextlen);
36003597
else
36013598
err = -EOPNOTSUPP;
36023599
args.contextsupport = (err == 0);
3603-
if (u.attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) {
3600+
if (attrmask[2] & FATTR4_WORD2_SECURITY_LABEL) {
36043601
if (err == -EOPNOTSUPP)
3605-
u.attrmask[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
3602+
attrmask[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
36063603
else if (err)
36073604
goto out_nfserr;
36083605
}
36093606
}
36103607
#endif /* CONFIG_NFSD_V4_SECURITY_LABEL */
36113608

36123609
/* attrmask */
3613-
status = nfsd4_encode_bitmap4(xdr, u.attrmask[0],
3614-
u.attrmask[1], u.attrmask[2]);
3610+
status = nfsd4_encode_bitmap4(xdr, attrmask[0], attrmask[1],
3611+
attrmask[2]);
36153612
if (status)
36163613
goto out;
36173614

@@ -3620,7 +3617,9 @@ nfsd4_encode_fattr4(struct svc_rqst *rqstp, struct xdr_stream *xdr,
36203617
attrlen_p = xdr_reserve_space(xdr, XDR_UNIT);
36213618
if (!attrlen_p)
36223619
goto out_resource;
3623-
for_each_set_bit(bit, (const unsigned long *)&u.mask,
3620+
bitmap_from_arr32(attr_bitmap, attrmask,
3621+
ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops));
3622+
for_each_set_bit(bit, attr_bitmap,
36243623
ARRAY_SIZE(nfsd4_enc_fattr4_encode_ops)) {
36253624
status = nfsd4_enc_fattr4_encode_ops[bit](xdr, &args);
36263625
if (status != nfs_ok)

include/trace/events/rpcgss.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ TRACE_EVENT(rpcgss_context,
609609
__field(unsigned int, timeout)
610610
__field(u32, window_size)
611611
__field(int, len)
612-
__string(acceptor, data)
612+
__string_len(acceptor, data, len)
613613
),
614614

615615
TP_fast_assign(
@@ -618,7 +618,7 @@ TRACE_EVENT(rpcgss_context,
618618
__entry->timeout = timeout;
619619
__entry->window_size = window_size;
620620
__entry->len = len;
621-
strncpy(__get_str(acceptor), data, len);
621+
__assign_str(acceptor, data);
622622
),
623623

624624
TP_printk("win_size=%u expiry=%lu now=%lu timeout=%u acceptor=%.*s",

0 commit comments

Comments
 (0)