# git rev-parse -q --verify 2bc2026269beb0d7923317f5a4a28ce4d5bbc94c^{commit} 2bc2026269beb0d7923317f5a4a28ce4d5bbc94c already have revision, skipping fetch # git checkout -q -f -B kisskb 2bc2026269beb0d7923317f5a4a28ce4d5bbc94c # git clean -qxdf # < git log -1 # commit 2bc2026269beb0d7923317f5a4a28ce4d5bbc94c # Author: Michael Ellerman # Date: Thu Jul 19 23:36:10 2018 +1000 # # powerpc/mm: Don't report PUDs as memory leaks when using kmemleak # # Paul Menzel reported that kmemleak was producing reports such as: # # unreferenced object 0xc0000000f8b80000 (size 16384): # comm "init", pid 1, jiffies 4294937416 (age 312.240s) # hex dump (first 32 bytes): # 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ # 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ # backtrace: # [<00000000d997deb7>] __pud_alloc+0x80/0x190 # [<0000000087f2e8a3>] move_page_tables+0xbac/0xdc0 # [<00000000091e51c2>] shift_arg_pages+0xc0/0x210 # [<00000000ab88670c>] setup_arg_pages+0x22c/0x2a0 # [<0000000060871529>] load_elf_binary+0x41c/0x1648 # [<00000000ecd9d2d4>] search_binary_handler.part.11+0xbc/0x280 # [<0000000034e0cdd7>] __do_execve_file.isra.13+0x73c/0x940 # [<000000005f953a6e>] sys_execve+0x58/0x70 # [<000000009700a858>] system_call+0x5c/0x70 # # Indicating that a PUD was being leaked. # # However what's really happening is that kmemleak is not able to # recognise the references from the PGD to the PUD, because they are not # fully qualified pointers. # # We can confirm that in xmon, eg: # # Find the task struct for pid 1 "init": # 0:mon> P # task_struct ->thread.ksp PID PPID S P CMD # c0000001fe7c0000 c0000001fe803960 1 0 S 13 systemd # # Dump virtual address 0 to find the PGD: # 0:mon> dv 0 c0000001fe7c0000 # pgd @ 0xc0000000f8b01000 # # Dump the memory of the PGD: # 0:mon> d c0000000f8b01000 # c0000000f8b01000 00000000f8b90000 0000000000000000 |................| # c0000000f8b01010 0000000000000000 0000000000000000 |................| # c0000000f8b01020 0000000000000000 0000000000000000 |................| # c0000000f8b01030 0000000000000000 00000000f8b80000 |................| # ^^^^^^^^^^^^^^^^ # # There we can see the reference to our supposedly leaked PUD. But # because it's missing the leading 0xc, kmemleak won't recognise it. # # We can confirm it's still in use by translating an address that is # mapped via it: # 0:mon> dv 7fff94000000 c0000001fe7c0000 # pgd @ 0xc0000000f8b01000 # pgdp @ 0xc0000000f8b01038 = 0x00000000f8b80000 <-- # pudp @ 0xc0000000f8b81ff8 = 0x00000000037c4000 # pmdp @ 0xc0000000037c5ca0 = 0x00000000fbd89000 # ptep @ 0xc0000000fbd89000 = 0xc0800001d5ce0386 # Maps physical address = 0x00000001d5ce0000 # Flags = Accessed Dirty Read Write # # The fix is fairly simple. We need to tell kmemleak to ignore PUD # allocations and never report them as leaks. We can also tell it not to # scan the PGD, because it will never find pointers in there. However it # will still notice if we allocate a PGD and then leak it. # # Reported-by: Paul Menzel # Signed-off-by: Michael Ellerman # < /opt/cross/kisskb/gcc-5.3.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc --version # < git log --format=%s --max-count=1 2bc2026269beb0d7923317f5a4a28ce4d5bbc94c # < make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-next_ppc6xx_defconfig_powerpc-5.3 CROSS_COMPILE=/opt/cross/kisskb/gcc-5.3.0-nolibc/powerpc64-linux/bin/powerpc64-linux- ppc6xx_defconfig # make -s -j 120 ARCH=powerpc O=/kisskb/build/powerpc-next_ppc6xx_defconfig_powerpc-5.3 CROSS_COMPILE=/opt/cross/kisskb/gcc-5.3.0-nolibc/powerpc64-linux/bin/powerpc64-linux- /kisskb/src/net/Makefile:24: CC cannot link executables. Skipping bpfilter. /kisskb/src/net/Makefile:24: CC cannot link executables. Skipping bpfilter. In file included from /kisskb/src/sound/ppc/pmac.h:25:0, from /kisskb/src/sound/ppc/awacs.c:29: /kisskb/src/sound/ppc/awacs.c: In function 'snd_pmac_awacs_init': /kisskb/src/include/sound/control.h:223:9: warning: 'speaker_vol' may be used uninitialized in this function [-Wmaybe-uninitialized] return _snd_ctl_add_slave(master, slave, 0); ^ /kisskb/src/sound/ppc/awacs.c:886:36: note: 'speaker_vol' was declared here struct snd_kcontrol *master_vol, *speaker_vol; ^ arch/powerpc/boot/mpc832x_rdb.dtb: Warning (interrupts_property): /qe@e0100000/mdio@3120/ethernet-phy@0:#interrupt-cells: size is (4), expected multiple of 8 arch/powerpc/boot/mpc832x_rdb.dtb: Warning (interrupts_property): /qe@e0100000/mdio@3120/ethernet-phy@4:#interrupt-cells: size is (4), expected multiple of 8 INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa64ce4) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa64ce4) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa7543c) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4951758 Bytes = 4835.70 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b001f4 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4951764 Bytes = 4835.71 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b001f4 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4951026 Bytes = 4834.99 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b001f4 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4952276 Bytes = 4836.21 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b001f4 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4927418 Bytes = 4811.93 kB = 4.70 MB Load Address: 00000000 Entry Point: 00000000 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4952122 Bytes = 4836.06 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b007a0 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4951940 Bytes = 4835.88 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b007a0 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4951211 Bytes = 4835.17 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b001f4 Image Name: Linux-4.18.0-rc3+ Created: Fri Jul 20 01:25:31 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4951836 Bytes = 4835.78 kB = 4.72 MB Load Address: 00b00000 Entry Point: 00b001f4 Completed OK # rm -rf /kisskb/build/powerpc-next_ppc6xx_defconfig_powerpc-5.3 # Build took: 0:01:20.802907