linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Roman Smirnov <r.smirnov@omp.ru>, Jaegeuk Kim <jaegeuk@kernel.org>
Cc: lvc-project@linuxtesting.org, Sergey Shtylyov <s.shtylyov@omp.ru>,
	linux-kernel@vger.kernel.org,
	Karina Yankevich <k.yankevich@omp.ru>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: file: add checks to f2fs_ioc_flush_device()
Date: Tue, 13 Aug 2024 11:50:27 +0800	[thread overview]
Message-ID: <e82ab6dd-f4a6-4648-a4b4-b092f2eaf2be@kernel.org> (raw)
In-Reply-To: <20240801071707.8296-1-r.smirnov@omp.ru>

On 2024/8/1 15:17, Roman Smirnov wrote:
> If invalid data is copied from user space and if GET_SEGNO()
> returns NULL_SEGNO an overflow is possible.

Can you explain in which condition that FDEV(range.dev_num).start_blk or
FDEV(range.dev_num).end_blk will be invalid?

 > > Add checks for invalid values.
> 
> Found by Linux Verification Center (linuxtesting.org) with Svace.
> 
> Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
> ---
>   fs/f2fs/file.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 168f08507004..1b9c4fee9db1 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3093,6 +3093,9 @@ static int f2fs_ioc_flush_device(struct file *filp, unsigned long arg)
>   		start_segno = dev_start_segno;
>   	end_segno = min(start_segno + range.segments, dev_end_segno);
>   
> +	if (start_segno > F2FS_MAX_SEGMENT - range.segments || end_segno == NULL_SEGNO)
> +		return -EINVAL;

It missed to call mnt_drop_write_file() before return.

Thanks,

> +
>   	while (start_segno < end_segno) {
>   		if (!f2fs_down_write_trylock(&sbi->gc_lock)) {
>   			ret = -EBUSY;



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

      reply	other threads:[~2024-08-13  3:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-01  7:17 [f2fs-dev] [PATCH] f2fs: file: add checks to f2fs_ioc_flush_device() Roman Smirnov
2024-08-13  3:50 ` Chao Yu [this message]

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=e82ab6dd-f4a6-4648-a4b4-b092f2eaf2be@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=k.yankevich@omp.ru \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=r.smirnov@omp.ru \
    --cc=s.shtylyov@omp.ru \
    /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;
as well as URLs for NNTP newsgroup(s).