linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.18 01/39] lib/list_debug.c: Detect uninitialized lists
@ 2022-08-14 16:22 Sasha Levin
  2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 02/39] tty: serial: Fix refcount leak bug in ucc_uart.c Sasha Levin
                   ` (37 more replies)
  0 siblings, 38 replies; 39+ messages in thread
From: Sasha Levin @ 2022-08-14 16:22 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Guenter Roeck, Steven Rostedt, Andrew Morton, Sasha Levin,
	thunder.leizhen

From: Guenter Roeck <linux@roeck-us.net>

[ Upstream commit 0cc011c576aaa4de505046f7a6c90933d7c749a9 ]

In some circumstances, attempts are made to add entries to or to remove
entries from an uninitialized list.  A prime example is
amdgpu_bo_vm_destroy(): It is indirectly called from
ttm_bo_init_reserved() if that function fails, and tries to remove an
entry from a list.  However, that list is only initialized in
amdgpu_bo_create_vm() after the call to ttm_bo_init_reserved() returned
success.  This results in crashes such as

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x0000) - not-present page
 PGD 0 P4D 0
 Oops: 0000 [#1] PREEMPT SMP NOPTI
 CPU: 1 PID: 1479 Comm: chrome Not tainted 5.10.110-15768-g29a72e65dae5
 Hardware name: Google Grunt/Grunt, BIOS Google_Grunt.11031.149.0 07/15/2020
 RIP: 0010:__list_del_entry_valid+0x26/0x7d
 ...
 Call Trace:
  amdgpu_bo_vm_destroy+0x48/0x8b
  ttm_bo_init_reserved+0x1d7/0x1e0
  amdgpu_bo_create+0x212/0x476
  ? amdgpu_bo_user_destroy+0x23/0x23
  ? kmem_cache_alloc+0x60/0x271
  amdgpu_bo_create_vm+0x40/0x7d
  amdgpu_vm_pt_create+0xe8/0x24b
 ...

Check if the list's prev and next pointers are NULL to catch such problems.

Link: https://lkml.kernel.org/r/20220531222951.92073-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 lib/list_debug.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/list_debug.c b/lib/list_debug.c
index 9daa3fb9d1cd..d98d43f80958 100644
--- a/lib/list_debug.c
+++ b/lib/list_debug.c
@@ -20,7 +20,11 @@
 bool __list_add_valid(struct list_head *new, struct list_head *prev,
 		      struct list_head *next)
 {
-	if (CHECK_DATA_CORRUPTION(next->prev != prev,
+	if (CHECK_DATA_CORRUPTION(prev == NULL,
+			"list_add corruption. prev is NULL.\n") ||
+	    CHECK_DATA_CORRUPTION(next == NULL,
+			"list_add corruption. next is NULL.\n") ||
+	    CHECK_DATA_CORRUPTION(next->prev != prev,
 			"list_add corruption. next->prev should be prev (%px), but was %px. (next=%px).\n",
 			prev, next->prev, next) ||
 	    CHECK_DATA_CORRUPTION(prev->next != next,
@@ -42,7 +46,11 @@ bool __list_del_entry_valid(struct list_head *entry)
 	prev = entry->prev;
 	next = entry->next;
 
-	if (CHECK_DATA_CORRUPTION(next == LIST_POISON1,
+	if (CHECK_DATA_CORRUPTION(next == NULL,
+			"list_del corruption, %px->next is NULL\n", entry) ||
+	    CHECK_DATA_CORRUPTION(prev == NULL,
+			"list_del corruption, %px->prev is NULL\n", entry) ||
+	    CHECK_DATA_CORRUPTION(next == LIST_POISON1,
 			"list_del corruption, %px->next is LIST_POISON1 (%px)\n",
 			entry, LIST_POISON1) ||
 	    CHECK_DATA_CORRUPTION(prev == LIST_POISON2,
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2022-08-14 16:34 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-14 16:22 [PATCH AUTOSEL 5.18 01/39] lib/list_debug.c: Detect uninitialized lists Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 02/39] tty: serial: Fix refcount leak bug in ucc_uart.c Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 03/39] KVM: PPC: Book3S HV: Fix "rm_exit" entry in debugfs timings Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 04/39] vfio: Clear the caps->buf to NULL after free Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 05/39] mips: cavium-octeon: Fix missing of_node_put() in octeon2_usb_clocks_start Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 06/39] iommu/io-pgtable-arm-v7s: Add a quirk to allow pgtable PA up to 35bit Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 07/39] riscv: dts: microchip: Add mpfs' topology information Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 08/39] ALSA: hda: Fix page fault in snd_hda_codec_shutdown() Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 09/39] modules: Ensure natural alignment for .altinstructions and __bug_table sections Sasha Levin
2022-08-14 16:22 ` [PATCH AUTOSEL 5.18 10/39] ASoC: rsnd: care default case on rsnd_ssiu_busif_err_irq_ctrl() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 11/39] riscv: dts: sifive: Add fu540 topology information Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 12/39] riscv: dts: sifive: Add fu740 " Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 13/39] riscv: dts: canaan: Add k210 " Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 14/39] riscv: mmap with PROT_WRITE but no PROT_READ is invalid Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 15/39] RISC-V: Add fast call path of crash_kexec() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 16/39] ALSA: hda/realtek: Enable speaker and mute LEDs for HP laptops Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 17/39] ASoC: SOF: Intel: hda: add sanity check on SSP index reported by NHLT Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 18/39] ASoC: Intel: sof_es8336: Fix GPIO quirks set via module option Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 19/39] ASoC: Intel: sof_es8336: ignore GpioInt when looking for speaker/headset GPIO lines Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 20/39] ASoC: Intel: sof_nau8825: Move quirk check to the front in late probe Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 21/39] watchdog: export lockup_detector_reconfigure Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 22/39] powerpc/watchdog: introduce a NMI watchdog's factor Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 23/39] powerpc/pseries/mobility: set NMI watchdog factor during an LPM Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 24/39] powerpc/32: Set an IBAT covering up to _einittext during init Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 25/39] powerpc/32: Don't always pass -mcpu=powerpc to the compiler Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 26/39] ASoC: codecs: va-macro: use fsgen as clock Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 27/39] ovl: warn if trusted xattr creation fails Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 28/39] powerpc/ioda/iommu/debugfs: Generate unique debugfs entries Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 29/39] ALSA: core: Add async signal helpers Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 30/39] ALSA: timer: Use deferred fasync helper Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 31/39] ALSA: pcm: " Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 32/39] ALSA: control: " Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 33/39] f2fs: fix to avoid use f2fs_bug_on() in f2fs_new_node_page() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 34/39] f2fs: fix to do sanity check on segment type in build_sit_entries() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 35/39] smb3: check xattr value length earlier Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 36/39] powerpc/64: Init jump labels before parse_early_param() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 37/39] venus: pm_helpers: Fix warning in OPP during probe Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 38/39] video: fbdev: i740fb: Check the argument of i740_calc_vclk() Sasha Levin
2022-08-14 16:23 ` [PATCH AUTOSEL 5.18 39/39] MIPS: tlbex: Explicitly compare _PAGE_NO_EXEC against 0 Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).