From a3ae8fcfd17a6e5e91e3d83a3ab6c88585170fe0 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Fri, 11 Jun 2021 18:51:47 +0800 Subject: [PATCH] Fix for "kmem -s|-S" option on Linux 5.7 and later kernels Release crash-7.3.0-2 Resolves: rhbz#1954913 Signed-off-by: Lianbo Jiang --- ...-option-on-Linux-5.7-and-later-kerne.patch | 58 +++++++++++++++++++ crash.spec | 7 ++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch diff --git a/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch b/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch new file mode 100644 index 0000000..fd8b759 --- /dev/null +++ b/0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch @@ -0,0 +1,58 @@ +From 647a5c33e1c94054d7b63168cd6c12901591cb77 Mon Sep 17 00:00:00 2001 +From: Lianbo Jiang +Date: Thu, 27 May 2021 18:02:11 +0800 +Subject: [PATCH] Fix for "kmem -s|-S" option on Linux 5.7 and later kernels + +Linux 5.7 and later kernels that contain kernel commit 1ad53d9fa3f6 +("slub: improve bit diffusion for freelist ptr obfuscation") changed +the calculation formula in the freelist_ptr(), which added a swab() +call to mix bits a little more. When kernel is configured with the +"CONFIG_SLAB_FREELIST_HARDENED=y", without the patch, the "kmem -s|-S" +options display wrong statistics and state whether slab objects are +in use or free and can print the following errors: + + crash> kmem -s + CACHE OBJSIZE ALLOCATED TOTAL SLABS SSIZE NAME + 87201e00 528 0 0 0 8k xfs_dqtrx + 87201f00 496 0 0 0 8k xfs_dquot + kmem: xfs_buf: slab: 37202e6e900 invalid freepointer: b844bab900001d70 + kmem: xfs_buf: slab: 3720250fd80 invalid freepointer: b8603f9400001370 + ... + +Signed-off-by: Lianbo Jiang +--- + memory.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/memory.c b/memory.c +index 8c6bbe409922..a3cf8a86728d 100644 +--- a/memory.c ++++ b/memory.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + + struct meminfo { /* general purpose memory information structure */ + ulong cache; /* used by the various memory searching/dumping */ +@@ -19336,10 +19337,14 @@ count_free_objects(struct meminfo *si, ulong freelist) + static ulong + freelist_ptr(struct meminfo *si, ulong ptr, ulong ptr_addr) + { +- if (VALID_MEMBER(kmem_cache_random)) ++ if (VALID_MEMBER(kmem_cache_random)) { + /* CONFIG_SLAB_FREELIST_HARDENED */ ++ ++ if (THIS_KERNEL_VERSION >= LINUX(5,7,0)) ++ ptr_addr = (sizeof(long) == 8) ? bswap_64(ptr_addr) ++ : bswap_32(ptr_addr); + return (ptr ^ si->random ^ ptr_addr); +- else ++ } else + return ptr; + } + +-- +2.30.2 + diff --git a/crash.spec b/crash.spec index 7b13aec..1686fc6 100644 --- a/crash.spec +++ b/crash.spec @@ -4,7 +4,7 @@ Summary: Kernel analysis utility for live systems, netdump, diskdump, kdump, LKCD or mcore dumpfiles Name: crash Version: 7.3.0 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3 Source0: https://github.com/crash-utility/crash/archive/crash-%{version}.tar.gz Source1: http://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.gz @@ -18,6 +18,7 @@ Requires: binutils Provides: bundled(libiberty) Provides: bundled(gdb) = 7.6 Patch0: lzo_snappy.patch +Patch1: 0001-Fix-for-kmem-s-S-option-on-Linux-5.7-and-later-kerne.patch %description The core analysis suite is a self-contained tool that can be used to @@ -38,6 +39,7 @@ offered by Mission Critical Linux, or the LKCD kernel patch. %prep %setup -n %{name}-%{version} -q %patch0 -p1 -b lzo_snappy.patch +%patch1 -p1 %build # This package has an internal copy of GDB which has broken configure code for @@ -69,6 +71,9 @@ cp -p defs.h %{buildroot}%{_includedir}/crash %{_includedir}/* %changelog +* Fri Jun 11 2021 Lianbo Jiang - 7.3.0-2 +- Fix for "kmem -s|-S" option on Linux 5.7 and later kernels + * Mon May 10 2021 Lianbo Jiang - 7.3.0-1 - Rebase to upstream 7.3.0