public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.cz>, stable@kernel.org
Subject: Re: [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers
Date: Mon, 11 Mar 2024 19:45:57 +0100	[thread overview]
Message-ID: <20240311184557.3apdu2nhen3cgbjn@quack3> (raw)
In-Reply-To: <cff4953b5c9306aba71e944ab176a5d396b9a1b7.1709182250.git.ritesh.list@gmail.com>

On Thu 29-02-24 11:40:13, Ritesh Harjani (IBM) wrote:
> Truncate operation can race with writeback, in which inode->i_size can get
> truncated and therefore size - folio_pos() can be negative. This fixes the
> len calculation. However this path doesn't get easily triggered even
> with data journaling.
> 
> Cc:  <stable@kernel.org> # v6.5
> Fixes: 80be8c5cc925 ("Fixes: ext4: Make mpage_journal_page_buffers use folio")
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>

Looks good. Feel free to add:

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

								Honza

> ---
>  fs/ext4/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 537803250ca9..bab9223d94ac 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2334,7 +2334,7 @@ static int mpage_journal_page_buffers(handle_t *handle,
>  
>  	if (folio_pos(folio) + len > size &&
>  	    !ext4_verity_in_progress(inode))
> -		len = size - folio_pos(folio);
> +		len = size & (len - 1);
>  
>  	return ext4_journal_folio_buffers(handle, folio, len);
>  }
> -- 
> 2.39.2
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  parent reply	other threads:[~2024-03-11 18:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29  6:10 [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Ritesh Harjani (IBM)
2024-02-29  6:10 ` [PATCH 2/2] ext4: Remove PAGE_MASK dependency on mpage_submit_folio Ritesh Harjani (IBM)
2024-03-11 18:46   ` Jan Kara
2024-03-11 18:45 ` Jan Kara [this message]
2024-05-02 14:51 ` [PATCH 1/2] ext4: Fixes len calculation in mpage_journal_page_buffers Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240311184557.3apdu2nhen3cgbjn@quack3 \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=ritesh.list@gmail.com \
    --cc=stable@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox