public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Wanming Hu <huwanming@huaweil.com>,
	He Ying <heying24@huawei.com>,
	Chen Jingwen <chenjingwen6@huawei.com>,
	Kees Cook <keescook@chromium.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15 005/106] powerpc/kasan: Silence KASAN warnings in __get_wchan()
Date: Mon, 20 Jun 2022 14:50:24 +0200	[thread overview]
Message-ID: <20220620124724.544207703@linuxfoundation.org> (raw)
In-Reply-To: <20220620124724.380838401@linuxfoundation.org>

From: He Ying <heying24@huawei.com>

[ Upstream commit a1b29ba2f2c171b9bea73be993bfdf0a62d37d15 ]

The following KASAN warning was reported in our kernel.

  BUG: KASAN: stack-out-of-bounds in get_wchan+0x188/0x250
  Read of size 4 at addr d216f958 by task ps/14437

  CPU: 3 PID: 14437 Comm: ps Tainted: G           O      5.10.0 #1
  Call Trace:
  [daa63858] [c0654348] dump_stack+0x9c/0xe4 (unreliable)
  [daa63888] [c035cf0c] print_address_description.constprop.3+0x8c/0x570
  [daa63908] [c035d6bc] kasan_report+0x1ac/0x218
  [daa63948] [c00496e8] get_wchan+0x188/0x250
  [daa63978] [c0461ec8] do_task_stat+0xce8/0xe60
  [daa63b98] [c0455ac8] proc_single_show+0x98/0x170
  [daa63bc8] [c03cab8c] seq_read_iter+0x1ec/0x900
  [daa63c38] [c03cb47c] seq_read+0x1dc/0x290
  [daa63d68] [c037fc94] vfs_read+0x164/0x510
  [daa63ea8] [c03808e4] ksys_read+0x144/0x1d0
  [daa63f38] [c005b1dc] ret_from_syscall+0x0/0x38
  --- interrupt: c00 at 0x8fa8f4
      LR = 0x8fa8cc

  The buggy address belongs to the page:
  page:98ebcdd2 refcount:0 mapcount:0 mapping:00000000 index:0x2 pfn:0x1216f
  flags: 0x0()
  raw: 00000000 00000000 01010122 00000000 00000002 00000000 ffffffff 00000000
  raw: 00000000
  page dumped because: kasan: bad access detected

  Memory state around the buggy address:
   d216f800: 00 00 00 00 00 f1 f1 f1 f1 00 00 00 00 00 00 00
   d216f880: f2 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  >d216f900: 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1 00
                                            ^
   d216f980: f2 f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00
   d216fa00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

After looking into this issue, I find the buggy address belongs
to the task stack region. It seems KASAN has something wrong.
I look into the code of __get_wchan in x86 architecture and
find the same issue has been resolved by the commit
f7d27c35ddff ("x86/mm, kasan: Silence KASAN warnings in get_wchan()").
The solution could be applied to powerpc architecture too.

As Andrey Ryabinin said, get_wchan() is racy by design, it may
access volatile stack of running task, thus it may access
redzone in a stack frame and cause KASAN to warn about this.

Use READ_ONCE_NOCHECK() to silence these warnings.

Reported-by: Wanming Hu <huwanming@huaweil.com>
Signed-off-by: He Ying <heying24@huawei.com>
Signed-off-by: Chen Jingwen <chenjingwen6@huawei.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220121014418.155675-1-heying24@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/powerpc/kernel/process.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 50436b52c213..39a0a13a3a27 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -2124,12 +2124,12 @@ static unsigned long __get_wchan(struct task_struct *p)
 		return 0;
 
 	do {
-		sp = *(unsigned long *)sp;
+		sp = READ_ONCE_NOCHECK(*(unsigned long *)sp);
 		if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD) ||
 		    task_is_running(p))
 			return 0;
 		if (count > 0) {
-			ip = ((unsigned long *)sp)[STACK_FRAME_LR_SAVE];
+			ip = READ_ONCE_NOCHECK(((unsigned long *)sp)[STACK_FRAME_LR_SAVE]);
 			if (!in_sched_functions(ip))
 				return ip;
 		}
-- 
2.35.1




  parent reply	other threads:[~2022-06-20 13:15 UTC|newest]

Thread overview: 121+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20 12:50 [PATCH 5.15 000/106] 5.15.49-rc1 review Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 001/106] Revert "drm/amd/display: Fix DCN3 B0 DP Alt Mapping" Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 002/106] nfsd: Replace use of rwsem with errseq_t Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 003/106] arm64: dts: imx8mm-beacon: Enable RTS-CTS on UART3 Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 004/106] arm64: dts: imx8mn-beacon: " Greg Kroah-Hartman
2022-06-20 12:50 ` Greg Kroah-Hartman [this message]
2022-06-20 12:50 ` [PATCH 5.15 006/106] ASoC: nau8822: Add operation for internal PLL off and on Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 007/106] drm/amd/display: Read Golden Settings Table from VBIOS Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 008/106] drm/amdkfd: Use mmget_not_zero in MMU notifier Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 009/106] dma-debug: make things less spammy under memory pressure Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 010/106] ASoC: cs42l52: Fix TLV scales for mixer controls Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 011/106] ASoC: cs35l36: Update digital volume TLV Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 012/106] ASoC: cs53l30: Correct number of volume levels on SX controls Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 013/106] ASoC: cs42l52: Correct TLV for Bypass Volume Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 014/106] ASoC: cs42l56: Correct typo in minimum level for SX volume controls Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 015/106] ASoC: cs42l51: Correct minimum value for SX volume control Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 016/106] drm/amdkfd: add pinned BOs to kfd_bo_list Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 017/106] ata: libata-core: fix NULL pointer deref in ata_host_alloc_pinfo() Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 018/106] quota: Prevent memory allocation recursion while holding dq_lock Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 019/106] ASoC: wm8962: Fix suspend while playing music Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 020/106] ASoC: es8328: Fix event generation for deemphasis control Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 021/106] ASoC: wm_adsp: Fix event generation for wm_adsp_fw_put() Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 022/106] Input: soc_button_array - also add Lenovo Yoga Tablet2 1051F to dmi_use_low_level_irq Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 023/106] scsi: vmw_pvscsi: Expand vcpuHint to 16 bits Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 024/106] scsi: lpfc: Resolve NULL ptr dereference after an ELS LOGO is aborted Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 025/106] scsi: lpfc: Fix port stuck in bypassed state after LIP in PT2PT topology Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 026/106] scsi: lpfc: Allow reduced polling rate for nvme_admin_async_event cmd completion Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 027/106] scsi: mpt3sas: Fix out-of-bounds compiler warning Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 028/106] scsi: ipr: Fix missing/incorrect resource cleanup in error case Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 029/106] scsi: pmcraid: Fix missing " Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 030/106] ALSA: hda/realtek - Add HW8326 support Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 031/106] virtio-mmio: fix missing put_device() when vm_cmdline_parent registration failed Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 032/106] nfc: nfcmrvl: Fix memory leak in nfcmrvl_play_deferred Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 033/106] ipv6: Fix signed integer overflow in l2tp_ip6_sendmsg Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 034/106] net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface netdev[napi]_alloc_frag Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 035/106] gcc-12: disable -Wdangling-pointer warning for now Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 036/106] mellanox: mlx5: avoid uninitialized variable warning with gcc-12 Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 037/106] netfs: gcc-12: temporarily disable -Wattribute-warning for now Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 038/106] MIPS: Loongson-3: fix compile mips cpu_hwmon as module build error Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 039/106] random: credit cpu and bootloader seeds by default Greg Kroah-Hartman
2022-06-20 12:50 ` [PATCH 5.15 040/106] gpio: dwapb: Dont print error on -EPROBE_DEFER Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 041/106] platform/x86: gigabyte-wmi: Add Z690M AORUS ELITE AX DDR4 support Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 042/106] platform/x86: gigabyte-wmi: Add support for B450M DS3H-CF Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 043/106] platform/x86/intel: hid: Add Surface Go to VGBS allow list Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 044/106] staging: r8188eu: fix rtw_alloc_hwxmits error detection for now Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 045/106] staging: r8188eu: Use zeroing allocator in wpa_set_encryption() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 046/106] staging: r8188eu: Fix warning of array overflow in ioctl_linux.c Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 047/106] pNFS: Dont keep retrying if the server replied NFS4ERR_LAYOUTUNAVAILABLE Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 048/106] pNFS: Avoid a live lock condition in pnfs_update_layout() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 049/106] sunrpc: set cl_max_connect when cloning an rpc_clnt Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 050/106] clocksource: hyper-v: unexport __init-annotated hv_init_clocksource() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 051/106] i40e: Fix adding ADQ filter to TC0 Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 052/106] i40e: Fix calculating the number of queue pairs Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 053/106] i40e: Fix call trace in setup_tx_descriptors Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 054/106] Drivers: hv: vmbus: Release cpu lock in error case Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 055/106] tty: goldfish: Fix free_irq() on remove Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 056/106] misc: atmel-ssc: Fix IRQ check in ssc_probe Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 057/106] io_uring: fix races with file table unregister Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 058/106] io_uring: fix races with buffer " Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 059/106] drm/i915/reset: Fix error_state_read ptr + offset use Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 060/106] net: hns3: split function hclge_update_port_base_vlan_cfg() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 061/106] net: hns3: set port base vlan tbl_sta to false before removing old vlan Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 062/106] net: hns3: dont push link state to VF if unalive Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 063/106] net: hns3: fix tm port shapping of fibre port is incorrect after driver initialization Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 064/106] nvme: add device name to warning in uuid_show() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 065/106] mlxsw: spectrum_cnt: Reorder counter pools Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 066/106] net: bgmac: Fix an erroneous kfree() in bgmac_remove() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 067/106] net: ax25: Fix deadlock caused by skb_recv_datagram in ax25_recvmsg Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 068/106] arm64: ftrace: fix branch range checks Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 069/106] arm64: ftrace: consistently handle PLTs Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 070/106] certs/blacklist_hashes.c: fix const confusion in certs blacklist Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 071/106] init: Initialize noop_backing_dev_info early Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 072/106] block: Fix handling of offline queues in blk_mq_alloc_request_hctx() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 073/106] faddr2line: Fix overlapping text section failures, the sequel Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 074/106] i2c: npcm7xx: Add check for platform_driver_register Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 075/106] irqchip/gic/realview: Fix refcount leak in realview_gic_of_init Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 076/106] irqchip/gic-v3: Fix error handling in gic_populate_ppi_partitions Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 077/106] irqchip/gic-v3: Fix refcount leak " Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 078/106] irqchip/realtek-rtl: Fix refcount leak in map_interrupts Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 079/106] sched: Fix balance_push() vs __sched_setscheduler() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 080/106] i2c: designware: Use standard optional ref clock implementation Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 081/106] mei: hbm: drop capability response on early shutdown Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 082/106] mei: me: add raptor lake point S DID Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 083/106] comedi: vmk80xx: fix expression for tx buffer size Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 084/106] crypto: memneq - move into lib/ Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 085/106] USB: serial: option: add support for Cinterion MV31 with new baseline Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 086/106] USB: serial: io_ti: add Agilent E5805A support Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 087/106] usb: dwc2: Fix memory leak in dwc2_hcd_init Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 088/106] usb: cdnsp: Fixed setting last_trb incorrectly Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 089/106] usb: gadget: lpc32xx_udc: Fix refcount leak in lpc32xx_udc_probe Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 090/106] usb: gadget: f_fs: change ep->status safe in ffs_epfile_io() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 091/106] usb: gadget: f_fs: change ep->ep " Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 092/106] tty: n_gsm: Debug output allocation must use GFP_ATOMIC Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 093/106] serial: 8250: Store to lsr_save_flags after lsr read Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 094/106] bus: fsl-mc-bus: fix KASAN use-after-free in fsl_mc_bus_remove() Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 095/106] dm mirror log: round up region bitmap size to BITS_PER_LONG Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 096/106] drm/amd/display: Cap OLED brightness per max frame-average luminance Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 097/106] cfi: Fix __cfi_slowpath_diag RCU usage with cpuidle Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 098/106] ext4: fix super block checksum incorrect after mount Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 099/106] ext4: fix bug_on ext4_mb_use_inode_pa Greg Kroah-Hartman
2022-06-20 12:51 ` [PATCH 5.15 100/106] ext4: make variable "count" signed Greg Kroah-Hartman
2022-06-20 12:52 ` [PATCH 5.15 101/106] ext4: add reserved GDT blocks check Greg Kroah-Hartman
2022-06-20 12:52 ` [PATCH 5.15 102/106] KVM: arm64: Dont read a HW interrupt pending state in user context Greg Kroah-Hartman
2022-06-20 12:52 ` [PATCH 5.15 103/106] ALSA: hda/realtek: fix right sounds and mute/micmute LEDs for HP machine Greg Kroah-Hartman
2022-06-20 12:52 ` [PATCH 5.15 104/106] virtio-pci: Remove wrong address verification in vp_del_vqs() Greg Kroah-Hartman
2022-06-20 12:52 ` [PATCH 5.15 105/106] powerpc/book3e: get rid of #include <generated/compile.h> Greg Kroah-Hartman
2022-06-20 12:52 ` [PATCH 5.15 106/106] clk: imx8mp: fix usb_root_clk parent Greg Kroah-Hartman
2022-06-20 16:38 ` [PATCH 5.15 000/106] 5.15.49-rc1 review Fox Chen
2022-06-20 18:13 ` Florian Fainelli
2022-06-21  0:47 ` Guenter Roeck
2022-06-21  3:29 ` Bagas Sanjaya
2022-06-21  8:20 ` Ron Economos
2022-06-21  8:36 ` Naresh Kamboju
2022-06-21  8:55   ` Greg Kroah-Hartman
2022-06-21  9:45     ` Jason A. Donenfeld
2022-06-21 10:35       ` Greg Kroah-Hartman
2022-06-21 11:36         ` Naresh Kamboju
2022-06-21 15:12           ` Greg Kroah-Hartman
2022-06-21  9:40 ` Sudip Mukherjee
2022-06-21  9:59 ` Jon Hunter
2022-06-21 21:48 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220620124724.544207703@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=chenjingwen6@huawei.com \
    --cc=heying24@huawei.com \
    --cc=huwanming@huaweil.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox