[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240801071707.8296-1-r.smirnov@omp.ru>
Date: Thu, 1 Aug 2024 10:17:07 +0300
From: Roman Smirnov <r.smirnov@....ru>
To: Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>
CC: Roman Smirnov <r.smirnov@....ru>,
<linux-f2fs-devel@...ts.sourceforge.net>, <linux-kernel@...r.kernel.org>,
Sergey Shtylyov <s.shtylyov@....ru>, Karina Yankevich <k.yankevich@....ru>,
<lvc-project@...uxtesting.org>
Subject: [PATCH] f2fs: file: add checks to f2fs_ioc_flush_device()
If invalid data is copied from user space and if GET_SEGNO()
returns NULL_SEGNO an overflow is possible.
Add checks for invalid values.
Found by Linux Verification Center (linuxtesting.org) with Svace.
Signed-off-by: Roman Smirnov <r.smirnov@....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;
+
while (start_segno < end_segno) {
if (!f2fs_down_write_trylock(&sbi->gc_lock)) {
ret = -EBUSY;
--
2.43.0
Powered by blists - more mailing lists