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: <20231102100857.tntr4mdz65bddq2f@quack3>
Date:   Thu, 2 Nov 2023 11:08:57 +0100
From:   Jan Kara <jack@...e.cz>
To:     Ojaswin Mujoo <ojaswin@...ux.ibm.com>
Cc:     linux-ext4@...r.kernel.org, Theodore Ts'o <tytso@....edu>,
        Ritesh Harjani <ritesh.list@...il.com>,
        linux-kernel@...r.kernel.org, Jan Kara <jack@...e.cz>
Subject: Re: [PATCH v2 2/2] ext4: Clarify handling of unwritten bh in
 __ext4_block_zero_page_range()

On Wed 01-11-23 22:08:11, Ojaswin Mujoo wrote:
> As an optimization, I was trying to work on exiting early from this
> function if dealing with unwritten extent since they anyways read 0.
> However, it was realised that there are certain code paths that can
> end up calling ext4_block_zero_page_range() for an unwritten bh that
> might still have data in pagecache. In this case, we can't exit early
> and we do require to process the bh and zero out the pagecache to ensure
> that a writeback can't kick in at a later time and flush the stale
> pagecache to disk.
> 
> Since, adding the logic to exit early for unwritten bh was turning out
> to be much more nuanced and the current code already handles it well,
> just add a comment to explicitly document this behavior.
> 
> Suggested-by: Jan Kara <jack@...e.cz>
> Signed-off-by: Ojaswin Mujoo <ojaswin@...ux.ibm.com>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@...e.cz>

								Honza

> ---
>  fs/ext4/inode.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index d7732320431a..76921e834dd4 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3632,6 +3632,12 @@ void ext4_set_aops(struct inode *inode)
>  		inode->i_mapping->a_ops = &ext4_aops;
>  }
>  
> +/*
> + * Here we can't skip an unwritten buffer even though it usually reads zero
> + * because it might have data in pagecache (eg, if called from ext4_zero_range,
> + * ext4_punch_hole, etc) which needs to be properly zeroed out. Otherwise a
> + * racing writeback can come later and flush the stale pagecache to disk.
> + */
>  static int __ext4_block_zero_page_range(handle_t *handle,
>  		struct address_space *mapping, loff_t from, loff_t length)
>  {
> -- 
> 2.39.3
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ