lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240826-delstid-v2-5-e8ab5c0e39cc@kernel.org>
Date: Mon, 26 Aug 2024 08:46:15 -0400
From: Jeff Layton <jlayton@...nel.org>
To: Chuck Lever <chuck.lever@...cle.com>, Neil Brown <neilb@...e.de>, 
 Olga Kornievskaia <kolga@...app.com>, Dai Ngo <Dai.Ngo@...cle.com>, 
 Tom Talpey <tom@...pey.com>, Trond Myklebust <trondmy@...nel.org>, 
 Anna Schumaker <anna@...nel.org>, Olga Kornievskaia <okorniev@...hat.com>, 
 Alexander Viro <viro@...iv.linux.org.uk>, 
 Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, 
 Jonathan Corbet <corbet@....net>
Cc: Tom Haynes <loghyr@...il.com>, linux-kernel@...r.kernel.org, 
 linux-nfs@...r.kernel.org, linux-fsdevel@...r.kernel.org, 
 linux-doc@...r.kernel.org, Jeff Layton <jlayton@...nel.org>
Subject: [PATCH v2 5/7] fs: add an ATTR_CTIME_DLG flag

When updating the ctime on an inode for a setattr with a multigrain
filesystem, we usually want to take the latest time we can get for the
ctime. The exception to this rule is when there is a nfsd write
delegation and the server is proxying timestamps from the client.

When nfsd gets a CB_GETATTR response, we want to update the timestamp
value in the inode to the values that the client is tracking. The client
doesn't send a ctime value (since that's always determined by the
exported filesystem), but it does send a mtime value. In the case where
it does, then we may also need to update the ctime to a value
commensurate with that.

Add a ATTR_CTIME_DELEG flag, which tells the underlying setattr
machinery to respect that value and not to set it to the current time.

Signed-off-by: Jeff Layton <jlayton@...nel.org>
---
 fs/attr.c          | 10 +++++++++-
 include/linux/fs.h |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/attr.c b/fs/attr.c
index 7144b207e715..0eb7b228b94d 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -295,7 +295,15 @@ static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr)
 		return;
 	}
 
-	now = inode_set_ctime_current(inode);
+	/*
+	 * In the case of an update for a write delegation, we must respect
+	 * the value in ia_ctime and not use the current time.
+	 */
+	if (ia_valid & ATTR_CTIME_DLG)
+		inode_set_ctime_to_ts(inode, attr->ia_ctime);
+	else
+		now = inode_set_ctime_current(inode);
+
 	if (ia_valid & ATTR_ATIME_SET)
 		inode_set_atime_to_ts(inode, attr->ia_atime);
 	else if (ia_valid & ATTR_ATIME)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7c1da3c687bd..43a802b2cb0d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -211,6 +211,7 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
 #define ATTR_TIMES_SET	(1 << 16)
 #define ATTR_TOUCH	(1 << 17)
 #define ATTR_DELEG	(1 << 18) /* Delegated attrs (don't break) */
+#define ATTR_CTIME_DLG	(1 << 19) /* Delegation in effect */
 
 /*
  * Whiteout is represented by a char device.  The following constants define the

-- 
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ