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-next>] [day] [month] [year] [list]
Message-ID: <iyvn6qjotpu6cei5jdtsoibfcp6l6rgvn47cwgaucgtucpfy2s@tarta.nabijaczleweli.xyz>
Date: Mon, 8 Dec 2025 23:20:24 +0100
From: 
	Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
To: Alexander Viro <viro@...iv.linux.org.uk>, 
	Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>, linux-fsdevel@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: [PATCH] fs: send fsnotify_xattr()/IN_ATTRIB from
 vfs_fileattr_set()/chattr(1)

Currently it seems impossible to observe these changes to the file's
attributes. It's useful to be able to do this to see when the file
becomes immutable, for example, so emit IN_ATTRIB via fsnotify_xattr(),
like when changing other inode attributes.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
---
Given:
	#include <sys/inotify.h>
	#include <unistd.h>
	#include <stdio.h>
	#include <limits.h>
	int main() {
		int fd = inotify_init();
		inotify_add_watch(fd, ".", IN_ATTRIB);
		char buf[sizeof(struct inotify_event) + NAME_MAX + 1];
		for (;;) {
			ssize_t rd = read(fd, buf, sizeof(buf));
			struct inotify_event *ev = buf, *end = buf + rd;
			while (ev < end) {
				printf("%x\t%s\n", ev->mask, ev->name);
				ev = (char *)(ev + 1) + ev->len;
			}
		}
	}

Before:
	sh-5.2# ./test &
	[1] 255
	sh-5.2# chmod -x test
	4       test
	sh-5.2# setfattr -n user.name -v value test
	4       test
	sh-5.2# chattr -i test
	sh-5.2#

After:
	sh-5.2# ./test &
	[1] 280
	sh-5.2# chmod -x test
	4       test
	sh-5.2# setfattr -n user.name -v value test
	4       test
	sh-5.2# chattr -i test
	4       test
	sh-5.2#

 fs/file_attr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/file_attr.c b/fs/file_attr.c
index 4c4916632f11..13cdb31a3e94 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -2,6 +2,7 @@
 #include <linux/fs.h>
 #include <linux/security.h>
 #include <linux/fscrypt.h>
+#include <linux/fsnotify.h>
 #include <linux/fileattr.h>
 #include <linux/export.h>
 #include <linux/syscalls.h>
@@ -298,6 +299,7 @@ int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
 		err = inode->i_op->fileattr_set(idmap, dentry, fa);
 		if (err)
 			goto out;
+		fsnotify_xattr(dentry);
 	}
 
 out:
-- 
2.39.5

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ