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: <2025050600-economist-display-2d25@gregkh>
Date: Tue, 6 May 2025 19:43:28 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Max Kellermann <max.kellermann@...os.com>
Cc: tj@...nel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs/kernfs: implement STATX_BTIME

On Tue, May 06, 2025 at 06:40:17PM +0200, Max Kellermann wrote:
> This allows finding out when an inode was initially created, for
> example:
> 
> - when was a device plugged in (and its node in sysfs was created)?
> - when was a cgroup created?
> 
> kernfs currently only implements `atime`, `mtime` and `ctime`.  All of
> these are volatile (`mtime` and `ctime` get updated automatically, and
> `atime` can be mainpulated using utime()).  Therefore, I suggest
> implementing STATX_BTIME to have a reliable birth time in userspace.
> 
> Signed-off-by: Max Kellermann <max.kellermann@...os.com>
> ---
>  fs/kernfs/dir.c        | 2 ++
>  fs/kernfs/inode.c      | 6 ++++++
>  include/linux/kernfs.h | 7 +++++++
>  3 files changed, 15 insertions(+)
> 
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index fc70d72c3fe8..9a6857f2f3d7 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -678,6 +678,8 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root,
>  			goto err_out3;
>  	}
>  
> +	ktime_get_real_ts64(&kn->btime);
> +
>  	return kn;
>  
>   err_out3:
> diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
> index b83054da68b3..1ff2ee62bfe6 100644
> --- a/fs/kernfs/inode.c
> +++ b/fs/kernfs/inode.c
> @@ -189,6 +189,12 @@ int kernfs_iop_getattr(struct mnt_idmap *idmap,
>  	struct kernfs_root *root = kernfs_root(kn);
>  
>  	down_read(&root->kernfs_iattr_rwsem);
> +
> +	if (request_mask & STATX_BTIME) {
> +		stat->result_mask |= STATX_BTIME;
> +		stat->btime = kn->btime;
> +	}
> +
>  	kernfs_refresh_inode(kn, inode);
>  	generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
>  	up_read(&root->kernfs_iattr_rwsem);
> diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h
> index b5a5f32fdfd1..9332aadf4b48 100644
> --- a/include/linux/kernfs.h
> +++ b/include/linux/kernfs.h
> @@ -229,6 +229,13 @@ struct kernfs_node {
>  	void			*priv;
>  	struct kernfs_iattrs	*iattr;
>  
> +	/*
> +	 * The birth time (for STATX_BTIME).  It lives here and not in
> +	 * struct kernfs_iattrs because the latter is only created on
> +	 * demand, not at actual node birth time.
> +	 */
> +	struct timespec64	btime;

You did just make this structure bigger, which has a real effect on many
systems (think 32bit s390 systems with 30k disks.)  Are you sure this is
really needed?

What userspace tools want this in such that they can not determine this
any other way?  What do they want this information for?  What is going
to depend and require this to warrent it being added like this?

I'm loath to increase the size of this structure just for "it would be
nice" type of things.  We need to see a real user and a real use case
for this please.

And knowing when a device shows up in the system isn't that, sorry, the
kernel log shows that for you already, right?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ