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] [day] [month] [year] [list]
Message-ID: <n4xg7ncsvtey5wn6macx6nwt7x463uc4xqqcjaskvtpm227bzc@536xrtegrdq7>
Date: Tue, 9 Dec 2025 12:23:11 +0100
From: Jan Kara <jack@...e.cz>
To: 
	Ahelenia Ziemiańska <nabijaczleweli@...ijaczleweli.xyz>
Cc: 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: Re: [PATCH] fs: send fsnotify_xattr()/IN_ATTRIB from
 vfs_fileattr_set()/chattr(1)

On Mon 08-12-25 23:20:24, Ahelenia Ziemiańska wrote:
> 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>

Thanks. Yes, I guess this makes sense. I've picked up the patch to my tree.

								Honza

> ---
> 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


-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ