public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] fs: f2fs: integer overflow in f2fs_truncate_inode_blocks()
@ 2024-03-22  9:05 Roman Smirnov
  0 siblings, 0 replies; only message in thread
From: Roman Smirnov @ 2024-03-22  9:05 UTC (permalink / raw)
  To: jaegeuk@kernel.org, chao@kernel.org
  Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Sergey Shtylyov, Karina Yankevich,
	lvc-project@linuxtesting.org

Hello. 

There is a possible bug in f2fs_truncate_inode_blocks():

    if (err < 0 && err != -ENOENT)
    			goto fail;
        ...
        offset[1] = 0;
        offset[0]++;
        nofs += err;

If err = -ENOENT then nofs will sum with an error code,
which is strange behaviour. Also if nofs < ENOENT this will
cause an overflow. err will be equal to -ENOENT with the
following call stack:

truncate_nodes()
  f2fs_get_node_page()
     __get_node_page()
        read_node_page()

It looks like ENOENT processing is missing here. What can you
say about it? How can it be fixed?

Found by Linux Verification Center (linuxtesting.org) with the
Svace static analysis tool.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-22  9:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-22  9:05 [bug report] fs: f2fs: integer overflow in f2fs_truncate_inode_blocks() Roman Smirnov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox