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]
Date:   Thu, 6 Jul 2023 14:36:43 +0200
From:   Jan Kara <jack@...e.cz>
To:     Jeff Layton <jlayton@...nel.org>
Cc:     Christian Brauner <brauner@...nel.org>,
        Theodore Ts'o <tytso@....edu>,
        Andreas Dilger <adilger.kernel@...ger.ca>,
        Al Viro <viro@...iv.linux.org.uk>, Jan Kara <jack@...e.cz>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-ext4@...r.kernel.org
Subject: Re: [PATCH v2 42/92] ext4: convert to ctime accessor functions

On Wed 05-07-23 15:01:07, Jeff Layton wrote:
> In later patches, we're going to change how the inode's ctime field is
> used. Switch to using accessor functions instead of raw accesses of
> inode->i_ctime.
> 
> Signed-off-by: Jeff Layton <jlayton@...nel.org>

Some comment below:

> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 0a2d55faa095..d502b930431b 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3823,6 +3823,27 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
>  	return buffer_uptodate(bh);
>  }
>  
> +static inline void ext4_inode_set_ctime(struct inode *inode, struct ext4_inode *raw_inode)
> +{
> +	struct timespec64 ctime = inode_get_ctime(inode);
> +
> +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra)) {
> +		raw_inode->i_ctime = cpu_to_le32(ctime.tv_sec);
> +		raw_inode->i_ctime_extra = ext4_encode_extra_time(&ctime);
> +	} else {
> +		raw_inode->i_ctime = cpu_to_le32(clamp_t(int32_t, ctime.tv_sec, S32_MIN, S32_MAX));
> +	}
> +}
> +
> +static inline void ext4_inode_get_ctime(struct inode *inode, const struct ext4_inode *raw_inode)
> +{
> +	struct timespec64 ctime = { .tv_sec = (signed)le32_to_cpu(raw_inode->i_ctime) };
> +
> +	if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_ctime_extra))
> +		ext4_decode_extra_time(&ctime, raw_inode->i_ctime_extra);
> +	inode_set_ctime(inode, ctime.tv_sec, ctime.tv_nsec);
> +}
> +

This duplication is kind of unpleasant. I was looking into it for a while
and I think we can rather do some initial cleanup (attached patch 1) and
then your conversion patch would not need to duplicate the conversion code
(see attached patch 2).

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

View attachment "0001-ext4-deduplicate-macros-for-converting-inode-timesta.patch" of type "text/x-patch" (5615 bytes)

View attachment "0002-ext4-convert-to-ctime-accessor-functions.patch" of type "text/x-patch" (15423 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ