From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Huisong Li <lihuisong@huawei.com>,
Adam Young <admiyo@os.amperecomputing.com>,
Robbie King <robbiek@xsightlabs.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Jassi Brar <jassisinghbrar@gmail.com>,
Sasha Levin <sashal@kernel.org>,
linux-acpi@vger.kernel.org
Subject: [PATCH AUTOSEL 6.14 22/23] mailbox: pcc: Fix the possible race in updation of chan_in_use flag
Date: Thu, 3 Apr 2025 20:03:59 -0400 [thread overview]
Message-ID: <20250404000402.2688049-22-sashal@kernel.org> (raw)
In-Reply-To: <20250404000402.2688049-1-sashal@kernel.org>
From: Huisong Li <lihuisong@huawei.com>
[ Upstream commit 9779d45c749340ab461d595c1a4a664cb28f3007 ]
The function mbox_chan_received_data() calls the Rx callback of the
mailbox client driver. The callback might set chan_in_use flag from
pcc_send_data(). This flag's status determines whether the PCC channel
is in use.
However, there is a potential race condition where chan_in_use is
updated incorrectly due to concurrency between the interrupt handler
(pcc_mbox_irq()) and the command sender(pcc_send_data()).
The 'chan_in_use' flag of a channel is set to true after sending a
command. And the flag of the new command may be cleared erroneous by
the interrupt handler afer mbox_chan_received_data() returns,
As a result, the interrupt being level triggered can't be cleared in
pcc_mbox_irq() and it will be disabled after the number of handled times
exceeds the specified value. The error log is as follows:
| kunpeng_hccs HISI04B2:00: PCC command executed timeout!
| kunpeng_hccs HISI04B2:00: get port link status info failed, ret = -110
| irq 13: nobody cared (try booting with the "irqpoll" option)
| Call trace:
| dump_backtrace+0x0/0x210
| show_stack+0x1c/0x2c
| dump_stack+0xec/0x130
| __report_bad_irq+0x50/0x190
| note_interrupt+0x1e4/0x260
| handle_irq_event+0x144/0x17c
| handle_fasteoi_irq+0xd0/0x240
| __handle_domain_irq+0x80/0xf0
| gic_handle_irq+0x74/0x2d0
| el1_irq+0xbc/0x140
| mnt_clone_write+0x0/0x70
| file_update_time+0xcc/0x160
| fault_dirty_shared_page+0xe8/0x150
| do_shared_fault+0x80/0x1d0
| do_fault+0x118/0x1a4
| handle_pte_fault+0x154/0x230
| __handle_mm_fault+0x1ac/0x390
| handle_mm_fault+0xf0/0x250
| do_page_fault+0x184/0x454
| do_translation_fault+0xac/0xd4
| do_mem_abort+0x44/0xb4
| el0_da+0x40/0x74
| el0_sync_handler+0x60/0xb4
| el0_sync+0x168/0x180
| handlers:
| pcc_mbox_irq
| Disabling IRQ #13
To solve this issue, pcc_mbox_irq() must clear 'chan_in_use' flag before
the call to mbox_chan_received_data().
Tested-by: Adam Young <admiyo@os.amperecomputing.com>
Tested-by: Robbie King <robbiek@xsightlabs.com>
Signed-off-by: Huisong Li <lihuisong@huawei.com>
(sudeep.holla: Minor updates to the subject, commit message and comment)
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/mailbox/pcc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 82102a4c5d688..8fd4d0f79b090 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -333,10 +333,16 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
if (pcc_chan_reg_read_modify_write(&pchan->plat_irq_ack))
return IRQ_NONE;
+ /*
+ * Clear this flag after updating interrupt ack register and just
+ * before mbox_chan_received_data() which might call pcc_send_data()
+ * where the flag is set again to start new transfer. This is
+ * required to avoid any possible race in updatation of this flag.
+ */
+ pchan->chan_in_use = false;
mbox_chan_received_data(chan, NULL);
check_and_ack(pchan, chan);
- pchan->chan_in_use = false;
return IRQ_HANDLED;
}
--
2.39.5
next prev parent reply other threads:[~2025-04-04 0:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-04 0:03 [PATCH AUTOSEL 6.14 01/23] crypto: ecdsa - Harden against integer overflows in DIV_ROUND_UP() Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 02/23] selftests/bpf: Fix stdout race condition in traffic monitor Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 03/23] pinctrl: renesas: rza2: Fix potential NULL pointer dereference Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 04/23] pinctrl: mcp23s08: Get rid of spurious level interrupts Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 05/23] MIPS: cm: Detect CM quirks from device tree Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 06/23] crypto: ccp - Add support for PCI device 0x1134 Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 07/23] crypto: lib/Kconfig - Fix lib built-in failure when arch is modular Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 08/23] crypto: null - Use spin lock instead of mutex Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 09/23] bpf: Fix kmemleak warning for percpu hashmap Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 10/23] HSI: ssi_protocol: Fix use after free vulnerability in ssi_protocol Driver Due to Race Condition Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 11/23] bpf: Fix deadlock between rcu_tasks_trace and event_mutex Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 12/23] clk: check for disabled clock-provider in of_clk_get_hw_from_clkspec() Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 13/23] parisc: PDT: Fix missing prototype warning Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 14/23] s390/sclp: Add check for get_zeroed_page() Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 15/23] s390/tty: Fix a potential memory leak bug Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 16/23] clk: renesas: rzv2h: Adjust for CPG_BUS_m_MSTOP starting from m = 1 Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 17/23] selftests/bpf: Fix cap_enable_effective() return code Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 18/23] bpf: bpftool: Setting error code in do_loader() Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 19/23] bpf: Only fails the busy counter check in bpf_cgrp_storage_get if it creates storage Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 20/23] bpf: Reject attaching fexit/fmod_ret to __noreturn functions Sasha Levin
2025-04-04 0:03 ` [PATCH AUTOSEL 6.14 21/23] x86/Kconfig: Make CONFIG_PCI_CNB20LE_QUIRK depend on X86_32 Sasha Levin
2025-04-04 0:03 ` Sasha Levin [this message]
2025-04-04 0:04 ` [PATCH AUTOSEL 6.14 23/23] mailbox: pcc: Always clear the platform ack interrupt first Sasha Levin
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=20250404000402.2688049-22-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=admiyo@os.amperecomputing.com \
--cc=jassisinghbrar@gmail.com \
--cc=lihuisong@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robbiek@xsightlabs.com \
--cc=stable@vger.kernel.org \
--cc=sudeep.holla@arm.com \
/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
all inboxes | Powered by JetHome®