Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

accel/amdxdna: Prevent ubuf size overflow

The ubuf size calculation may overflow, resulting in an undersized
allocation and possible memory corruption.

Use check_add_overflow() helpers to validate the size calculation before
allocation.

Fixes: bd72d4acda10 ("accel/amdxdna: Support user space allocated buffer")
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20260217192815.1784689-1-lizhi.hou@amd.com

Lizhi Hou 03808abb 1110a949

+5 -1
+5 -1
drivers/accel/amdxdna/amdxdna_ubuf.c
··· 7 7 #include <drm/drm_device.h> 8 8 #include <drm/drm_print.h> 9 9 #include <linux/dma-buf.h> 10 + #include <linux/overflow.h> 10 11 #include <linux/pagemap.h> 11 12 #include <linux/vmalloc.h> 12 13 ··· 177 176 goto free_ent; 178 177 } 179 178 180 - exp_info.size += va_ent[i].len; 179 + if (check_add_overflow(exp_info.size, va_ent[i].len, &exp_info.size)) { 180 + ret = -EINVAL; 181 + goto free_ent; 182 + } 181 183 } 182 184 183 185 ubuf->nr_pages = exp_info.size >> PAGE_SHIFT;