# git rev-parse -q --verify 348c71344111d7a48892e3e52264ff11956fc196^{commit} 348c71344111d7a48892e3e52264ff11956fc196 already have revision, skipping fetch # git checkout -q -f -B kisskb 348c71344111d7a48892e3e52264ff11956fc196 # git clean -qxdf # < git log -1 # commit 348c71344111d7a48892e3e52264ff11956fc196 # Author: Kajol Jain # Date: Thu May 5 21:04:51 2022 +0530 # # powerpc/papr_scm: Fix buffer overflow issue with CONFIG_FORTIFY_SOURCE # # With CONFIG_FORTIFY_SOURCE enabled, string functions will also perform # dynamic checks for string size which can panic the kernel, like incase # of overflow detection. # # In papr_scm, papr_scm_pmu_check_events function uses stat->stat_id with # string operations, to populate the nvdimm_events_map array. Since # stat_id variable is not NULL terminated, the kernel panics with # CONFIG_FORTIFY_SOURCE enabled at boot time. # # Below are the logs of kernel panic: # # detected buffer overflow in __fortify_strlen # ------------[ cut here ]------------ # kernel BUG at lib/string_helpers.c:980! # Oops: Exception in kernel mode, sig: 5 [#1] # NIP [c00000000077dad0] fortify_panic+0x28/0x38 # LR [c00000000077dacc] fortify_panic+0x24/0x38 # Call Trace: # [c0000022d77836e0] [c00000000077dacc] fortify_panic+0x24/0x38 (unreliable) # [c00800000deb2660] papr_scm_pmu_check_events.constprop.0+0x118/0x220 [papr_scm] # [c00800000deb2cb0] papr_scm_probe+0x288/0x62c [papr_scm] # [c0000000009b46a8] platform_probe+0x98/0x150 # # Fix this issue by using kmemdup_nul() to copy the content of # stat->stat_id directly to the nvdimm_events_map array. # # mpe: stat->stat_id comes from the hypervisor, not userspace, so there is # no security exposure. # # Fixes: 4c08d4bbc089 ("powerpc/papr_scm: Add perf interface support") # Signed-off-by: Kajol Jain # Signed-off-by: Michael Ellerman # Link: https://lore.kernel.org/r/20220505153451.35503-1-kjain@linux.ibm.com # < /opt/cross/kisskb/korg/gcc-5.5.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-5.5.0-nolibc/powerpc64-linux/bin/powerpc64-linux-ld --version # < git log --format=%s --max-count=1 348c71344111d7a48892e3e52264ff11956fc196 # < make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc885_ads_defconfig+HUGETLB_powerpc-gcc5 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-5.5.0-nolibc/powerpc64-linux/bin/powerpc64-linux- mpc885_ads_defconfig # Added to kconfig CONFIG_HUGETLBFS=y # < make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc885_ads_defconfig+HUGETLB_powerpc-gcc5 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-5.5.0-nolibc/powerpc64-linux/bin/powerpc64-linux- help # make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc885_ads_defconfig+HUGETLB_powerpc-gcc5 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-5.5.0-nolibc/powerpc64-linux/bin/powerpc64-linux- olddefconfig # make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-fixes_mpc885_ads_defconfig+HUGETLB_powerpc-gcc5 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-5.5.0-nolibc/powerpc64-linux/bin/powerpc64-linux- Completed OK # rm -rf /kisskb/build/powerpc-fixes_mpc885_ads_defconfig+HUGETLB_powerpc-gcc5 # Build took: 0:00:26.965815