# 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 48 ARCH=powerpc O=/kisskb/build/linus_ps3_defconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- ps3_defconfig # < make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_ps3_defconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- help # make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_ps3_defconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- olddefconfig # make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_ps3_defconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- /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/ipc/shm.c: In function 'ksys_shmdt': /kisskb/src/ipc/shm.c:1712:59: warning: 'file' 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/net/core/gen_stats.c: In function '__gnet_stats_copy_basic': /kisskb/src/net/core/gen_stats.c:156:19: warning: 'seq' may be used uninitialized in this function [-Wuninitialized] /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/net/core/dev.c: In function 'validate_xmit_skb_list': /kisskb/src/net/core/dev.c:3604:15: warning: 'tail' may be used uninitialized in this function [-Wuninitialized] /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/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/fs/cifs/smb2pdu.c: In function 'SMB2_ioctl_init': /kisskb/src/fs/cifs/smb2pdu.c:2845:19: warning: 'in_data_buf' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/wireless/nl80211.c: In function 'nl80211_vendor_cmd_dump': /kisskb/src/net/wireless/nl80211.c:13149:33: warning: 'wdev' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/wireless/nl80211.c:13119:21: warning: 'rdev' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/bluetooth/hidp/core.c: In function 'hidp_connection_add': /kisskb/src/net/bluetooth/hidp/core.c:1386:18: warning: 'session' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/usb/core/devio.c: In function 'async_completed': /kisskb/src/drivers/usb/core/devio.c:625:23: warning: 'errno' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/mac80211/tx.c: In function 'ieee80211_build_hdr': /kisskb/src/net/mac80211/tx.c:2551:27: warning: 'chanctx_conf' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/mac80211/mlme.c: In function 'ieee80211_rx_mgmt_beacon': /kisskb/src/net/mac80211/mlme.c:1576:3: warning: 'pwr_level_cisco' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/mac80211/mlme.c:1533:6: note: 'pwr_level_cisco' was declared here Completed OK # rm -rf /kisskb/build/linus_ps3_defconfig_powerpc-gcc4.6 # Build took: 0:01:16.641453