# git rev-parse -q --verify e3a36eb6dfaeea8175c05d5915dcf0b939be6dab^{commit} e3a36eb6dfaeea8175c05d5915dcf0b939be6dab already have revision, skipping fetch # git checkout -q -f -B kisskb e3a36eb6dfaeea8175c05d5915dcf0b939be6dab # git clean -qxdf # < git log -1 # commit e3a36eb6dfaeea8175c05d5915dcf0b939be6dab # Author: Christoph Hellwig # Date: Wed Mar 11 17:07:10 2020 +0100 # # driver code: clarify and fix platform device DMA mask allocation # # This does three inter-related things to clarify the usage of the # platform device dma_mask field. In the process, fix the bug introduced # by cdfee5623290 ("driver core: initialize a default DMA mask for # platform device") that caused Artem Tashkinov's laptop to not boot with # newer Fedora kernels. # # This does: # # - First off, rename the field to "platform_dma_mask" to make it # greppable. # # We have way too many different random fields called "dma_mask" in # various data structures, where some of them are actual masks, and # some of them are just pointers to the mask. And the structures all # have pointers to each other, or embed each other inside themselves, # and "pdev" sometimes means "platform device" and sometimes it means # "PCI device". # # So to make it clear in the code when you actually use this new field, # give it a unique name (it really should be something even more unique # like "platform_device_dma_mask", since it's per platform device, not # per platform, but that gets old really fast, and this is unique # enough in context). # # To further clarify when the field gets used, initialize it when we # actually start using it with the default value. # # - Then, use this field instead of the random one-off allocation in # platform_device_register_full() that is now unnecessary since we now # already have a perfectly fine allocation for it in the platform # device structure. # # - The above then allows us to fix the actual bug, where the error path # of platform_device_register_full() would unconditionally free the # platform device DMA allocation with 'kfree()'. # # That kfree() was dont regardless of whether the allocation had been # done earlier with the (now removed) kmalloc, or whether # setup_pdev_dma_masks() had already been used and the dma_mask pointer # pointed to the mask that was part of the platform device. # # It seems most people never triggered the error path, or only triggered # it from a call chain that set an explicit pdevinfo->dma_mask value (and # thus caused the unnecessary allocation that was "cleaned up" in the # error path) before calling platform_device_register_full(). # # Robin Murphy points out that in Artem's case the wdat_wdt driver failed # in platform_device_add(), and that was the one that had called # platform_device_register_full() with pdevinfo.dma_mask = 0, and would # have caused that kfree() of pdev.dma_mask corrupting the heap. # # A later unrelated kmalloc() then oopsed due to the heap corruption. # # Fixes: cdfee5623290 ("driver core: initialize a default DMA mask for platform device") # Reported-bisected-and-tested-by: Artem S. Tashkinov # Reviewed-by: Robin Murphy # Cc: Greg Kroah-Hartman # Signed-off-by: Christoph Hellwig # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-gcc --version # < /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-ld --version # < git log --format=%s --max-count=1 e3a36eb6dfaeea8175c05d5915dcf0b939be6dab # < make -s -j 80 ARCH=powerpc O=/kisskb/build/linus-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- randconfig KCONFIG_SEED=0xD28F5E04 # Added to kconfig CONFIG_STANDALONE=y # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_CPU_BIG_ENDIAN=y # Added to kconfig CONFIG_PPC64=y # Added to kconfig CONFIG_PPC_DISABLE_WERROR=y # Added to kconfig CONFIG_SECTION_MISMATCH_WARN_ONLY=y # Added to kconfig CONFIG_PREVENT_FIRMWARE_BUILD=y # Added to kconfig CONFIG_CC_STACKPROTECTOR_STRONG=n # Added to kconfig CONFIG_GCC_PLUGINS=n # Added to kconfig CONFIG_LD_HEAD_STUB_CATCH=y # Added to kconfig CONFIG_TRIM_UNUSED_KSYMS=n # Added to kconfig CONFIG_UBSAN=n # < make -s -j 80 ARCH=powerpc O=/kisskb/build/linus-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- help # make -s -j 80 ARCH=powerpc O=/kisskb/build/linus-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- olddefconfig .config:3899:warning: override: reassigning to symbol MODULE_SIG .config:3903:warning: override: reassigning to symbol SECTION_MISMATCH_WARN_ONLY .config:3904:warning: override: reassigning to symbol PREVENT_FIRMWARE_BUILD .config:3909:warning: override: reassigning to symbol UBSAN # make -s -j 80 ARCH=powerpc O=/kisskb/build/linus-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- /kisskb/src/arch/powerpc/kexec/elf_64.c: In function 'elf64_load': /kisskb/src/arch/powerpc/kexec/elf_64.c:119:2: warning: 'fdt' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/kernel/printk/printk.c: In function 'devkmsg_sysctl_set_loglvl': /kisskb/src/kernel/printk/printk.c:204:16: warning: 'old' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/proc/inode.c: In function 'proc_reg_open': /kisskb/src/include/linux/list.h:72:12: warning: 'pdeo' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/proc/inode.c:338:21: note: 'pdeo' was declared here /kisskb/src/kernel/sched/cputime.c: In function 'kcpustat_field': /kisskb/src/kernel/sched/cputime.c:1004:6: warning: 'val' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/mpi/mpicoder.c: In function 'mpi_read_raw_from_sgl': /kisskb/src/lib/mpi/mpicoder.c:352:8: warning: 'buff' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/video/backlight/adp8860_bl.c: In function 'adp8860_bl_ambient_light_level_show': /kisskb/src/drivers/video/backlight/adp8860_bl.c:578:10: warning: 'ret_val' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/kernel/bpf/btf.c: In function '__btf_resolve_helper_id': /kisskb/src/kernel/bpf/btf.c:4002:20: warning: 't' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/f2fs/node.c: In function '__set_nat_cache_dirty': /kisskb/src/fs/f2fs/node.c:263:17: warning: 'head' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/tty/serial/8250/8250_core.c: In function 'univ8250_release_irq': /kisskb/src/drivers/tty/serial/8250/8250_core.c:242:2: warning: 'i' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/tty/serial/8250/8250_core.c:227:19: note: 'i' was declared here /kisskb/src/fs/udf/unicode.c: In function 'udf_name_conv_char': /kisskb/src/fs/udf/unicode.c:132:8: warning: 'c' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/lightnvm/core.c: In function 'nvm_ioctl_dev_create.isra.18': /kisskb/src/include/linux/string.h:302:29: warning: array subscript is above array bounds [-Warray-bounds] /kisskb/src/lib/rhashtable.c: In function 'rht_deferred_worker': /kisskb/src/include/linux/rhashtable.h:110:10: warning: 'next' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/rhashtable.c:222:28: note: 'next' was declared here /kisskb/src/fs/splice.c: In function '__do_compat_sys_vmsplice': /kisskb/src/fs/splice.c:1416:8: warning: 'type' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/splice.c: In function '__do_sys_vmsplice': /kisskb/src/fs/splice.c:1390:8: warning: 'type' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/ksm.c: In function '__stable_node_chain': /kisskb/src/mm/ksm.c:1391:15: warning: 'found_rmap_hlist_len' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/ksm.c:1363:6: note: 'found_rmap_hlist_len' was declared here /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c: In function 'drm_dp_mst_dsc_aux_for_port': /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c:5400:9: warning: missing braces around initializer [-Wmissing-braces] /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c:5400:9: warning: (near initialization for 'desc.ident') [-Wmissing-braces] /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c: In function 'drm_dp_sideband_msg_build': /kisskb/src/drivers/gpu/drm/drm_dp_mst_topology.c:729:23: warning: 'hdrlen' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/usb/misc/appledisplay.c: In function 'appledisplay_bl_get_brightness': /kisskb/src/drivers/usb/misc/appledisplay.c:155:14: warning: 'brightness' may be used uninitialized in this function [-Wuninitialized] In file included from /kisskb/src/drivers/rtc/rtc-da9052.c:16:0: /kisskb/src/include/linux/mfd/da9052/da9052.h: In function 'da9052_group_read': /kisskb/src/include/linux/mfd/da9052/da9052.h:143:6: warning: 'ret' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/input/mouse/cyapa_gen3.c: In function 'cyapa_gen3_set_power_mode': /kisskb/src/drivers/input/mouse/cyapa_gen3.c:927:5: warning: 'ret' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/input/mouse/cyapa.c: In function 'cyapa_irq': /kisskb/src/drivers/input/mouse/cyapa.c:717:27: warning: 'error' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/memcontrol.c: In function 'commit_charge': /kisskb/src/mm/memcontrol.c:2595:5: warning: 'isolated' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/memcontrol.c:2609:6: note: 'isolated' was declared here /kisskb/src/drivers/hwspinlock/hwspinlock_core.c: In function 'of_hwspin_lock_get_id': /kisskb/src/drivers/hwspinlock/hwspinlock_core.c:345:6: warning: 'id' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/md/raid10.c: In function 'read_balance': /kisskb/src/drivers/md/raid10.c:842:22: warning: 'best_pending_slot' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/leds/leds-lm3601x.c: In function 'lm3601x_probe': /kisskb/src/drivers/leds/leds-lm3601x.c:349:19: warning: 'fwnode' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/leds/leds-lm3601x.c:416:24: note: 'fwnode' was declared here /kisskb/src/drivers/gpu/drm/drm_atomic.c: In function 'drm_atomic_check_only': /kisskb/src/drivers/gpu/drm/drm_atomic.c:426:38: warning: 'crtc_state' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/gpu/drm/drm_atomic.c:405:25: note: 'crtc_state' was declared here /kisskb/src/drivers/md/dm-zoned-metadata.c: In function 'dmz_ctr_metadata': /kisskb/src/drivers/md/dm-zoned-metadata.c:1345:14: warning: 'dmap' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/md/dm-zoned-metadata.c:1320:18: note: 'dmap' was declared here arch/powerpc/perf/perf_regs.o: In function `.perf_reg_value': perf_regs.c:(.text+0x30): undefined reference to `.is_sier_available' make[1]: *** [/kisskb/src/Makefile:1078: vmlinux] Error 1 make: *** [Makefile:180: sub-make] Error 2 Command 'make -s -j 80 ARCH=powerpc O=/kisskb/build/linus-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- ' returned non-zero exit status 2 # rm -rf /kisskb/build/linus-rand_powerpc-randconfig_powerpc-gcc4.6 # Build took: 0:01:51.232476