| From 6031c59d1be453a79775435260bc63da22cd3e22 Mon Sep 17 00:00:00 2001 | |
| From: Sasha Levin <sashal@kernel.org> | |
| Date: Wed, 28 Oct 2026 17:42:48 +0900 | |
| Subject: ntfs: avoid overflow when limiting attribute read length | |
| From: Hyunchul Lee <hyc.lee@gmail.com> | |
| [ Upstream commit 4b927614d92d7326f265d22b50ba7b4a33966e48 ] | |
| ntfs_inode_attr_pread() limits a read to the attribute size using | |
| pos + count. A large count can overflow the signed sum and bypass | |
| the attribute EOF boundary check. Compare count with isize - pos | |
| instead, after validating pos, so the read length limit cannot wrap. | |
| Fixes: af0db57d4293 ("ntfs: update inode operations") | |
| Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com> | |
| Reviewed-by: Baolin Liu <liubaolin@kylinos.cn> | |
| Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> | |
| Signed-off-by: Sasha Levin <sashal@kernel.org> | |
| --- | |
| fs/ntfs/inode.c | 2 +- | |
| 1 file changed, 1 insertion(+), 1 deletion(-) | |
| diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c | |
| index 64c415edc398c..907fe8ecb2a30 100644 | |
| --- a/fs/ntfs/inode.c | |
| +++ b/fs/ntfs/inode.c | |
| @@ -3630,7 +3630,7 @@ s64 ntfs_inode_attr_pread(struct inode *vi, s64 pos, s64 count, u8 *buf) | |
| mutex_unlock(&ni->mrec_lock); | |
| return -EINVAL; | |
| } | |
| - if (pos + count > isize) | |
| + if (count > isize - pos) | |
| count = isize - pos; | |
| if (!NInoNonResident(ni)) { | |
| -- | |
| 2.53.0 | |