aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorNitin Gote <nitin.r.gote@intel.com>2025-07-18 16:20:51 +0530
committerThomas Zimmermann <tzimmermann@suse.de>2025-08-11 17:26:38 +0200
commit5634c8cb298a7146b4e38873473e280b50e27a2c (patch)
tree96db837ffc32573063b2798502679c1eff7f7f43
parentdrm/tests: Fix drm_test_fb_xrgb8888_to_xrgb2101010() on big-endian (diff)
downloadwireguard-linux-5634c8cb298a7146b4e38873473e280b50e27a2c.tar.xz
wireguard-linux-5634c8cb298a7146b4e38873473e280b50e27a2c.zip
iosys-map: Fix undefined behavior in iosys_map_clear()
The current iosys_map_clear() implementation reads the potentially uninitialized 'is_iomem' boolean field to decide which union member to clear. This causes undefined behavior when called on uninitialized structures, as 'is_iomem' may contain garbage values like 0xFF. UBSAN detects this as: UBSAN: invalid-load in include/linux/iosys-map.h:267 load of value 255 is not a valid value for type '_Bool' Fix by unconditionally clearing the entire structure with memset(), eliminating the need to read uninitialized data and ensuring all fields are set to known good values. Closes: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/14639 Fixes: 01fd30da0474 ("dma-buf: Add struct dma-buf-map for storing struct dma_buf.vaddr_ptr") Signed-off-by: Nitin Gote <nitin.r.gote@intel.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20250718105051.2709487-1-nitin.r.gote@intel.com
-rw-r--r--include/linux/iosys-map.h7
1 files changed, 1 insertions, 6 deletions
diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index 4696abfd311c..3e85afe794c0 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -264,12 +264,7 @@ static inline bool iosys_map_is_set(const struct iosys_map *map)
*/
static inline void iosys_map_clear(struct iosys_map *map)
{
- if (map->is_iomem) {
- map->vaddr_iomem = NULL;
- map->is_iomem = false;
- } else {
- map->vaddr = NULL;
- }
+ memset(map, 0, sizeof(*map));
}
/**