mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
The hard-coded MSDOS_SUPER_MAGIC check in nfsd3_proc_pathconf() only recognizes FAT filesystems as case-insensitive. Modern filesystems like F2FS, exFAT, and CIFS support case-insensitive directories, but NFSv3 clients cannot discover this capability. Query the export's actual case behavior through ->fileattr_get instead. This allows NFSv3 clients to correctly handle case sensitivity for any filesystem that implements the fileattr interface. Filesystems without ->fileattr_get continue to report the default POSIX behavior (case-sensitive, case-preserving). This change depends on the earlier "fat: Implement fileattr_get for case sensitivity" patch in this series, which ensures FAT filesystems report their case behavior correctly via the fileattr interface. Case-folding is a per-directory property, so nfsd_get_case_info() queries the parent dentry for non-directory filehandles. Three inherent corner cases follow: a single-file export's parent lies outside the exported subtree, so the LSM hook evaluates against an unexported directory; a disconnected dentry from fh_verify() has d_parent == itself, so the file's own attributes are reported until the dentry connects; and a hardlinked file resolves through the alias the dcache currently holds, so when the inode is linked into both case-folded and case-sensitive directories the reported value tracks whichever parent is active. These limitations are not addressable without redefining the protocol attribute as per-parent rather than per-object. RFC 1813 restricts PATHCONF errors to NFS3ERR_STALE, NFS3ERR_BADHANDLE, and NFS3ERR_SERVERFAULT. When an LSM hook denies the case-folding query on the parent, NFS3ERR_STALE is the only correct mapping: NFS3ERR_SERVERFAULT misrepresents a working server as broken, and NFS3ERR_BADHANDLE implies a decoding failure that did not occur. A client purging the filehandle on receipt is the desired outcome, since the server has refused to read attributes through it. Substituting POSIX defaults instead would let the same handle report casefold=false now and casefold=true once policy permits, opening a silent name-collision window on case-insensitive exports. Reviewed-by: Roland Mainz <roland.mainz@nrubsig.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Link: https://patch.msgid.link/20260507-case-sensitivity-v14-13-e62cc8200435@oracle.com Signed-off-by: Christian Brauner <brauner@kernel.org>
315 lines
7.8 KiB
C
315 lines
7.8 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* XDR types for NFSv3 in nfsd.
|
|
*
|
|
* Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de>
|
|
*/
|
|
|
|
#ifndef _LINUX_NFSD_XDR3_H
|
|
#define _LINUX_NFSD_XDR3_H
|
|
|
|
#include "xdr.h"
|
|
|
|
struct nfsd3_sattrargs {
|
|
struct svc_fh fh;
|
|
struct iattr attrs;
|
|
int check_guard;
|
|
struct timespec64 guardtime;
|
|
};
|
|
|
|
struct nfsd3_diropargs {
|
|
struct svc_fh fh;
|
|
char * name;
|
|
unsigned int len;
|
|
};
|
|
|
|
struct nfsd3_accessargs {
|
|
struct svc_fh fh;
|
|
__u32 access;
|
|
};
|
|
|
|
struct nfsd3_readargs {
|
|
struct svc_fh fh;
|
|
__u64 offset;
|
|
__u32 count;
|
|
};
|
|
|
|
struct nfsd3_writeargs {
|
|
svc_fh fh;
|
|
__u64 offset;
|
|
__u32 count;
|
|
int stable;
|
|
__u32 len;
|
|
struct xdr_buf payload;
|
|
};
|
|
|
|
struct nfsd3_createargs {
|
|
struct svc_fh fh;
|
|
char * name;
|
|
unsigned int len;
|
|
int createmode;
|
|
struct iattr attrs;
|
|
__be32 * verf;
|
|
};
|
|
|
|
struct nfsd3_mknodargs {
|
|
struct svc_fh fh;
|
|
char * name;
|
|
unsigned int len;
|
|
__u32 ftype;
|
|
__u32 major, minor;
|
|
struct iattr attrs;
|
|
};
|
|
|
|
struct nfsd3_renameargs {
|
|
struct svc_fh ffh;
|
|
char * fname;
|
|
unsigned int flen;
|
|
struct svc_fh tfh;
|
|
char * tname;
|
|
unsigned int tlen;
|
|
};
|
|
|
|
struct nfsd3_linkargs {
|
|
struct svc_fh ffh;
|
|
struct svc_fh tfh;
|
|
char * tname;
|
|
unsigned int tlen;
|
|
};
|
|
|
|
struct nfsd3_symlinkargs {
|
|
struct svc_fh ffh;
|
|
char * fname;
|
|
unsigned int flen;
|
|
char * tname;
|
|
unsigned int tlen;
|
|
struct iattr attrs;
|
|
struct kvec first;
|
|
};
|
|
|
|
struct nfsd3_readdirargs {
|
|
struct svc_fh fh;
|
|
__u64 cookie;
|
|
__u32 count;
|
|
__be32 * verf;
|
|
};
|
|
|
|
struct nfsd3_commitargs {
|
|
struct svc_fh fh;
|
|
__u64 offset;
|
|
__u32 count;
|
|
};
|
|
|
|
struct nfsd3_getaclargs {
|
|
struct svc_fh fh;
|
|
__u32 mask;
|
|
};
|
|
|
|
struct posix_acl;
|
|
struct nfsd3_setaclargs {
|
|
struct svc_fh fh;
|
|
__u32 mask;
|
|
struct posix_acl *acl_access;
|
|
struct posix_acl *acl_default;
|
|
};
|
|
|
|
struct nfsd3_attrstat {
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
struct kstat stat;
|
|
};
|
|
|
|
/* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */
|
|
struct nfsd3_diropres {
|
|
__be32 status;
|
|
struct svc_fh dirfh;
|
|
struct svc_fh fh;
|
|
};
|
|
|
|
struct nfsd3_accessres {
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
__u32 access;
|
|
struct kstat stat;
|
|
};
|
|
|
|
struct nfsd3_readlinkres {
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
__u32 len;
|
|
struct page **pages;
|
|
};
|
|
|
|
struct nfsd3_readres {
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
unsigned long count;
|
|
__u32 eof;
|
|
struct page **pages;
|
|
};
|
|
|
|
struct nfsd3_writeres {
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
unsigned long count;
|
|
int committed;
|
|
__be32 verf[2];
|
|
};
|
|
|
|
struct nfsd3_renameres {
|
|
__be32 status;
|
|
struct svc_fh ffh;
|
|
struct svc_fh tfh;
|
|
};
|
|
|
|
struct nfsd3_linkres {
|
|
__be32 status;
|
|
struct svc_fh tfh;
|
|
struct svc_fh fh;
|
|
};
|
|
|
|
struct nfsd3_readdirres {
|
|
/* Components of the reply */
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
__be32 verf[2];
|
|
|
|
/* Used to encode the reply's entry list */
|
|
struct xdr_stream xdr;
|
|
struct xdr_buf dirlist;
|
|
struct svc_fh scratch;
|
|
struct readdir_cd common;
|
|
unsigned int cookie_offset;
|
|
struct svc_rqst * rqstp;
|
|
|
|
};
|
|
|
|
struct nfsd3_fsstatres {
|
|
__be32 status;
|
|
struct kstatfs stats;
|
|
__u32 invarsec;
|
|
};
|
|
|
|
struct nfsd3_fsinfores {
|
|
__be32 status;
|
|
__u32 f_rtmax;
|
|
__u32 f_rtpref;
|
|
__u32 f_rtmult;
|
|
__u32 f_wtmax;
|
|
__u32 f_wtpref;
|
|
__u32 f_wtmult;
|
|
__u32 f_dtpref;
|
|
__u64 f_maxfilesize;
|
|
__u32 f_properties;
|
|
};
|
|
|
|
struct nfsd3_pathconfres {
|
|
__be32 status;
|
|
__u32 p_link_max;
|
|
__u32 p_name_max;
|
|
__u32 p_no_trunc;
|
|
__u32 p_chown_restricted;
|
|
bool p_case_insensitive;
|
|
bool p_case_preserving;
|
|
};
|
|
|
|
struct nfsd3_commitres {
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
__be32 verf[2];
|
|
};
|
|
|
|
struct nfsd3_getaclres {
|
|
__be32 status;
|
|
struct svc_fh fh;
|
|
int mask;
|
|
struct posix_acl *acl_access;
|
|
struct posix_acl *acl_default;
|
|
struct kstat stat;
|
|
};
|
|
|
|
/* dummy type for release */
|
|
struct nfsd3_fhandle_pair {
|
|
__u32 dummy;
|
|
struct svc_fh fh1;
|
|
struct svc_fh fh2;
|
|
};
|
|
|
|
/*
|
|
* Storage requirements for XDR arguments and results.
|
|
*/
|
|
union nfsd3_xdrstore {
|
|
struct nfsd3_sattrargs sattrargs;
|
|
struct nfsd3_diropargs diropargs;
|
|
struct nfsd3_readargs readargs;
|
|
struct nfsd3_writeargs writeargs;
|
|
struct nfsd3_createargs createargs;
|
|
struct nfsd3_renameargs renameargs;
|
|
struct nfsd3_linkargs linkargs;
|
|
struct nfsd3_symlinkargs symlinkargs;
|
|
struct nfsd3_readdirargs readdirargs;
|
|
struct nfsd3_diropres diropres;
|
|
struct nfsd3_accessres accessres;
|
|
struct nfsd3_readlinkres readlinkres;
|
|
struct nfsd3_readres readres;
|
|
struct nfsd3_writeres writeres;
|
|
struct nfsd3_renameres renameres;
|
|
struct nfsd3_linkres linkres;
|
|
struct nfsd3_readdirres readdirres;
|
|
struct nfsd3_fsstatres fsstatres;
|
|
struct nfsd3_fsinfores fsinfores;
|
|
struct nfsd3_pathconfres pathconfres;
|
|
struct nfsd3_commitres commitres;
|
|
struct nfsd3_getaclres getaclres;
|
|
};
|
|
|
|
#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
|
|
|
|
bool nfs3svc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_accessargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_decode_commitargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
|
|
bool nfs3svc_encode_getattrres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_wccstat(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_lookupres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_writeres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_createres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_renameres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_linkres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
bool nfs3svc_encode_commitres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
|
|
|
|
void nfs3svc_release_fhandle(struct svc_rqst *);
|
|
void nfs3svc_release_fhandle2(struct svc_rqst *);
|
|
|
|
void nfs3svc_encode_cookie3(struct nfsd3_readdirres *resp, u64 offset);
|
|
int nfs3svc_encode_entry3(void *data, const char *name, int namlen,
|
|
loff_t offset, u64 ino, unsigned int d_type);
|
|
int nfs3svc_encode_entryplus3(void *data, const char *name, int namlen,
|
|
loff_t offset, u64 ino, unsigned int d_type);
|
|
/* Helper functions for NFSv3 ACL code */
|
|
bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp);
|
|
bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status);
|
|
bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr,
|
|
const struct svc_fh *fhp);
|
|
|
|
#endif /* _LINUX_NFSD_XDR3_H */
|