Skip to content

Commit 1cc41c8

Browse files
committed
Merge tag 'nfs-for-6.18-3' of git://git.linux-nfs.org/projects/anna/linux-nfs
Pull NFS client fixes from Anna Schumaker: - Various fixes when using NFS with TLS - Localio direct-IO fixes - Fix error handling in nfs_atomic_open_v23() - Fix sysfs memory leak when nfs_client kobject add fails - Fix an incorrect parameter when calling nfs4_call_sync() - Fix a failing LTP test when using delegated timestamps * tag 'nfs-for-6.18-3' of git://git.linux-nfs.org/projects/anna/linux-nfs: NFS: Fix LTP test failures when timestamps are delegated NFSv4: Fix an incorrect parameter when calling nfs4_call_sync() NFS: sysfs: fix leak when nfs_client kobject add fails NFSv2/v3: Fix error handling in nfs_atomic_open_v23() nfs/localio: do not issue misaligned DIO out-of-order nfs/localio: Ensure DIO WRITE's IO on stable storage upon completion nfs/localio: backfill missing partial read support for misaligned DIO nfs/localio: add refcounting for each iocb IO associated with NFS pgio header nfs/localio: remove unecessary ENOTBLK handling in DIO WRITE support NFS: Check the TLS certificate fields in nfs_match_client() pnfs: Set transport security policy to RPC_XPRTSEC_NONE unless using TLS pnfs: Fix TLS logic in _nfs4_pnfs_v4_ds_connect() pnfs: Fix TLS logic in _nfs4_pnfs_v3_ds_connect()
2 parents d5c1b4b + b623390 commit 1cc41c8

File tree

9 files changed

+211
-155
lines changed

9 files changed

+211
-155
lines changed

fs/nfs/client.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,14 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
338338
/* Match the xprt security policy */
339339
if (clp->cl_xprtsec.policy != data->xprtsec.policy)
340340
continue;
341+
if (clp->cl_xprtsec.policy == RPC_XPRTSEC_TLS_X509) {
342+
if (clp->cl_xprtsec.cert_serial !=
343+
data->xprtsec.cert_serial)
344+
continue;
345+
if (clp->cl_xprtsec.privkey_serial !=
346+
data->xprtsec.privkey_serial)
347+
continue;
348+
}
341349

342350
refcount_inc(&clp->cl_count);
343351
return clp;

fs/nfs/dir.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2268,11 +2268,12 @@ int nfs_atomic_open_v23(struct inode *dir, struct dentry *dentry,
22682268
return -ENAMETOOLONG;
22692269

22702270
if (open_flags & O_CREAT) {
2271-
file->f_mode |= FMODE_CREATED;
22722271
error = nfs_do_create(dir, dentry, mode, open_flags);
2273-
if (error)
2272+
if (!error) {
2273+
file->f_mode |= FMODE_CREATED;
2274+
return finish_open(file, dentry, NULL);
2275+
} else if (error != -EEXIST || open_flags & O_EXCL)
22742276
return error;
2275-
return finish_open(file, dentry, NULL);
22762277
}
22772278
if (d_in_lookup(dentry)) {
22782279
/* The only flags nfs_lookup considers are

fs/nfs/inode.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,8 @@ nfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
718718
struct nfs_fattr *fattr;
719719
loff_t oldsize = i_size_read(inode);
720720
int error = 0;
721+
kuid_t task_uid = current_fsuid();
722+
kuid_t owner_uid = inode->i_uid;
721723

722724
nfs_inc_stats(inode, NFSIOS_VFSSETATTR);
723725

@@ -739,9 +741,11 @@ nfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
739741
if (nfs_have_delegated_mtime(inode) && attr->ia_valid & ATTR_MTIME) {
740742
spin_lock(&inode->i_lock);
741743
if (attr->ia_valid & ATTR_MTIME_SET) {
742-
nfs_set_timestamps_to_ts(inode, attr);
743-
attr->ia_valid &= ~(ATTR_MTIME|ATTR_MTIME_SET|
744+
if (uid_eq(task_uid, owner_uid)) {
745+
nfs_set_timestamps_to_ts(inode, attr);
746+
attr->ia_valid &= ~(ATTR_MTIME|ATTR_MTIME_SET|
744747
ATTR_ATIME|ATTR_ATIME_SET);
748+
}
745749
} else {
746750
nfs_update_timestamps(inode, attr->ia_valid);
747751
attr->ia_valid &= ~(ATTR_MTIME|ATTR_ATIME);
@@ -751,10 +755,12 @@ nfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
751755
attr->ia_valid & ATTR_ATIME &&
752756
!(attr->ia_valid & ATTR_MTIME)) {
753757
if (attr->ia_valid & ATTR_ATIME_SET) {
754-
spin_lock(&inode->i_lock);
755-
nfs_set_timestamps_to_ts(inode, attr);
756-
spin_unlock(&inode->i_lock);
757-
attr->ia_valid &= ~(ATTR_ATIME|ATTR_ATIME_SET);
758+
if (uid_eq(task_uid, owner_uid)) {
759+
spin_lock(&inode->i_lock);
760+
nfs_set_timestamps_to_ts(inode, attr);
761+
spin_unlock(&inode->i_lock);
762+
attr->ia_valid &= ~(ATTR_ATIME|ATTR_ATIME_SET);
763+
}
758764
} else {
759765
nfs_update_delegated_atime(inode);
760766
attr->ia_valid &= ~ATTR_ATIME;

0 commit comments

Comments
 (0)