Skip to content

iov_iter: use kmemdup_array for dup_iter to harden against overflow#736

Open
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1080485=>linus-master
Open

iov_iter: use kmemdup_array for dup_iter to harden against overflow#736
blktests-ci[bot] wants to merge 1 commit intolinus-master_basefrom
series/1080485=>linus-master

Conversation

@blktests-ci
Copy link
Copy Markdown

@blktests-ci blktests-ci Bot commented Apr 13, 2026

Pull request for series with
subject: iov_iter: use kmemdup_array for dup_iter to harden against overflow
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1080485

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 13, 2026

Upstream branch: 9a9c8ce
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 13, 2026

Upstream branch: 028ef9c
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from b85986b to 9c01aee Compare April 13, 2026 06:20
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 8f17195 to 6b4d829 Compare April 14, 2026 06:46
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 14, 2026

Upstream branch: d60bc14
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from 9c01aee to 8057705 Compare April 14, 2026 06:47
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 14, 2026

Upstream branch: d60bc14
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from 8057705 to 5b82972 Compare April 14, 2026 08:28
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 6b4d829 to ceec5ed Compare April 21, 2026 06:51
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 21, 2026

Upstream branch: b4e0758
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from 5b82972 to e971730 Compare April 21, 2026 06:55
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from ceec5ed to 3b54e52 Compare April 22, 2026 20:20
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 22, 2026

Upstream branch: 6596a02
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from e971730 to 8a4509a Compare April 22, 2026 20:28
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 3b54e52 to 6a0b974 Compare April 23, 2026 16:58
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 23, 2026

Upstream branch: 507bd4b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from 8a4509a to e27fd09 Compare April 23, 2026 17:06
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 6a0b974 to 59ca59b Compare April 24, 2026 00:56
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 24, 2026

Upstream branch: dd6c438
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from e27fd09 to bd8ef90 Compare April 24, 2026 01:03
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch 2 times, most recently from 94f0438 to 857ada9 Compare April 24, 2026 07:54
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 24, 2026

Upstream branch: dd6c438
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from bd8ef90 to 9315963 Compare April 24, 2026 07:58
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 857ada9 to 482ce5b Compare April 29, 2026 02:21
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 29, 2026

Upstream branch: dca922e
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from 9315963 to d494deb Compare April 29, 2026 02:39
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 482ce5b to 5a9f7c7 Compare April 30, 2026 07:29
While auditing the Linux 7.0-rc2 kernel, I identified a potential security
vulnerability in the iov_iter framework's memory allocation logic.

The dup_iter() function, which is exported via EXPORT_SYMBOL, currently
uses kmemdup() with a raw multiplication to allocate the duplicate iovec array:

new->iov = kmemdup(from->iov, nr_segs * sizeof(struct iovec), gfp);

The hazard here is that dup_iter() relies on a primitive multiplication without
any integrated overflow check. Since nr_segs is often derived from user-space
input, this line is vulnerable to integer overflow (on 32-bit systems or
via type narrowing), potentially leading to a small allocation followed by a
large out-of-bounds memory copy. Furthermore, it allows for unbounded memory
allocations, as the function lacks intrinsic knowledge of safe limits.

On the 7.0-rc2 branch, several high-impact callchains still rely on this
exported function:

drivers/usb/gadget/function/f_fs.c:
The ffs_epfile_read_iter() path demonstrates why relying on dup_iter() is
dangerous: it performs allocation based on user input before verifying driver
state. This confirms that dup_iter() must be hardened internally as it cannot
assume pre-validated input.

drivers/usb/gadget/legacy/inode.c:
The ep_read_iter() path illustrates how dup_iter()’s lack of boundary awareness
compounds resource risks. When combined with other allocations, it creates
a multiplier effect for kernel memory pressure.

This patch replaces kmemdup() with kmemdup_array(), which utilizes
check_mul_overflow() to ensure the allocation size is calculated safely,
hardening dup_iter() against malicious or malformed inputs from its callers

Signed-off-by: Wang Haoran <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
@blktests-ci
Copy link
Copy Markdown
Author

blktests-ci Bot commented Apr 30, 2026

Upstream branch: e75a43c
series: https://patchwork.kernel.org/project/linux-block/list/?series=1080485
version: 1

@blktests-ci blktests-ci Bot force-pushed the series/1080485=>linus-master branch from d494deb to f559dca Compare April 30, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants