From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Manish Rangankar <mrangankar@marvell.com>,
Martin Hoyer <mhoyer@redhat.com>,
John Meneghini <jmeneghi@redhat.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
Sasha Levin <sashal@kernel.org>,
njavali@marvell.com, GR-QLogic-Storage-Upstream@marvell.com,
James.Bottomley@HansenPartnership.com,
linux-scsi@vger.kernel.org
Subject: [PATCH AUTOSEL 6.9 16/35] scsi: qedi: Fix crash while reading debugfs attribute
Date: Mon, 27 May 2024 10:11:21 -0400 [thread overview]
Message-ID: <20240527141214.3844331-16-sashal@kernel.org> (raw)
In-Reply-To: <20240527141214.3844331-1-sashal@kernel.org>
From: Manish Rangankar <mrangankar@marvell.com>
[ Upstream commit 28027ec8e32ecbadcd67623edb290dad61e735b5 ]
The qedi_dbg_do_not_recover_cmd_read() function invokes sprintf() directly
on a __user pointer, which results into the crash.
To fix this issue, use a small local stack buffer for sprintf() and then
call simple_read_from_buffer(), which in turns make the copy_to_user()
call.
BUG: unable to handle page fault for address: 00007f4801111000
PGD 8000000864df6067 P4D 8000000864df6067 PUD 864df7067 PMD 846028067 PTE 0
Oops: 0002 [#1] PREEMPT SMP PTI
Hardware name: HPE ProLiant DL380 Gen10/ProLiant DL380 Gen10, BIOS U30 06/15/2023
RIP: 0010:memcpy_orig+0xcd/0x130
RSP: 0018:ffffb7a18c3ffc40 EFLAGS: 00010202
RAX: 00007f4801111000 RBX: 00007f4801111000 RCX: 000000000000000f
RDX: 000000000000000f RSI: ffffffffc0bfd7a0 RDI: 00007f4801111000
RBP: ffffffffc0bfd7a0 R08: 725f746f6e5f6f64 R09: 3d7265766f636572
R10: ffffb7a18c3ffd08 R11: 0000000000000000 R12: 00007f4881110fff
R13: 000000007fffffff R14: ffffb7a18c3ffca0 R15: ffffffffc0bfd7af
FS: 00007f480118a740(0000) GS:ffff98e38af00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f4801111000 CR3: 0000000864b8e001 CR4: 00000000007706e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
<TASK>
? __die_body+0x1a/0x60
? page_fault_oops+0x183/0x510
? exc_page_fault+0x69/0x150
? asm_exc_page_fault+0x22/0x30
? memcpy_orig+0xcd/0x130
vsnprintf+0x102/0x4c0
sprintf+0x51/0x80
qedi_dbg_do_not_recover_cmd_read+0x2f/0x50 [qedi 6bcfdeeecdea037da47069eca2ba717c84a77324]
full_proxy_read+0x50/0x80
vfs_read+0xa5/0x2e0
? folio_add_new_anon_rmap+0x44/0xa0
? set_pte_at+0x15/0x30
? do_pte_missing+0x426/0x7f0
ksys_read+0xa5/0xe0
do_syscall_64+0x58/0x80
? __count_memcg_events+0x46/0x90
? count_memcg_event_mm+0x3d/0x60
? handle_mm_fault+0x196/0x2f0
? do_user_addr_fault+0x267/0x890
? exc_page_fault+0x69/0x150
entry_SYSCALL_64_after_hwframe+0x72/0xdc
RIP: 0033:0x7f4800f20b4d
Tested-by: Martin Hoyer <mhoyer@redhat.com>
Reviewed-by: John Meneghini <jmeneghi@redhat.com>
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Link: https://lore.kernel.org/r/20240415072155.30840-1-mrangankar@marvell.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/qedi/qedi_debugfs.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/scsi/qedi/qedi_debugfs.c b/drivers/scsi/qedi/qedi_debugfs.c
index 8deb2001dc2ff..37eed6a278164 100644
--- a/drivers/scsi/qedi/qedi_debugfs.c
+++ b/drivers/scsi/qedi/qedi_debugfs.c
@@ -120,15 +120,11 @@ static ssize_t
qedi_dbg_do_not_recover_cmd_read(struct file *filp, char __user *buffer,
size_t count, loff_t *ppos)
{
- size_t cnt = 0;
-
- if (*ppos)
- return 0;
+ char buf[64];
+ int len;
- cnt = sprintf(buffer, "do_not_recover=%d\n", qedi_do_not_recover);
- cnt = min_t(int, count, cnt - *ppos);
- *ppos += cnt;
- return cnt;
+ len = sprintf(buf, "do_not_recover=%d\n", qedi_do_not_recover);
+ return simple_read_from_buffer(buffer, count, ppos, buf, len);
}
static int
--
2.43.0
next prev parent reply other threads:[~2024-05-27 14:12 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-27 14:11 [PATCH AUTOSEL 6.9 01/35] ssb: Fix potential NULL pointer dereference in ssb_device_uevent() Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 02/35] selftests/bpf: Prevent client connect before server bind in test_tc_tunnel.sh Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 03/35] selftests/bpf: Fix flaky test btf_map_in_map/lookup_update Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 04/35] bpf: Avoid kfree_rcu() under lock in bpf_lpm_trie Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 05/35] devlink: use kvzalloc() to allocate devlink instance resources Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 06/35] batman-adv: bypass empty buckets in batadv_purge_orig_ref() Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 07/35] wifi: rtw89: 8852c: add quirk to set PCI BER for certain platforms Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 08/35] wifi: ath9k: work around memset overflow warning Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 09/35] af_packet: avoid a false positive warning in packet_setsockopt() Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 10/35] clocksource: Make watchdog and suspend-timing multiplication overflow safe Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 11/35] ACPI: x86: Add PNP_UART1_SKIP quirk for Lenovo Blade2 tablets Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 12/35] net: sfp: add quirk for another multigig RollBall transceiver Sasha Levin
2024-05-27 14:54 ` Marek Behún
2024-06-19 14:28 ` Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 13/35] drop_monitor: replace spin_lock by raw_spin_lock Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 14/35] ACPI: resource: Do IRQ override on GMxBGxx (XMG APEX 17 M23) Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 15/35] wifi: ath12k: fix kernel crash during resume Sasha Levin
2024-05-27 14:11 ` Sasha Levin [this message]
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 17/35] net: sfp: enhance quirk for Fibrestore 2.5G copper SFP module Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 18/35] net: sfp: add quirk for ATS SFP-GE-T 1000Base-TX module Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 19/35] net/sched: fix false lockdep warning on qdisc root lock Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 20/35] arm64/sysreg: Update PIE permission encodings Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 21/35] kselftest: arm64: Add a null pointer check Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 22/35] net: dsa: realtek: keep default LED state in rtl8366rb Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 23/35] net: dsa: realtek: do not assert reset on remove Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 24/35] ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MV Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 25/35] netpoll: Fix race condition in netpoll_owner_active Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 26/35] wifi: ath12k: fix the problem that down grade phy mode operation Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 27/35] wifi: mt76: mt7921s: fix potential hung tasks during chip recovery Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 28/35] HID: Add quirk for Logitech Casa touchpad Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 29/35] HID: asus: fix more n-key report descriptors if n-key quirked Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 30/35] ACPI: video: Add backlight=native quirk for Lenovo Slim 7 16ARH7 Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 31/35] HID: bpf: add in-tree HID-BPF fix for the HP Elite Presenter Mouse Sasha Levin
2024-05-27 14:50 ` Benjamin Tissoires
2024-06-19 14:29 ` Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 32/35] bpf: avoid uninitialized warnings in verifier_global_subprogs.c Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 33/35] selftests: net: fix timestamp not arriving in cmsg_time.sh Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 34/35] net: ena: Add validation for completion descriptors consistency Sasha Levin
2024-05-27 14:11 ` [PATCH AUTOSEL 6.9 35/35] Bluetooth: ath3k: Fix multiple issues reported by checkpatch.pl 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=20240527141214.3844331-16-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=jmeneghi@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mhoyer@redhat.com \
--cc=mrangankar@marvell.com \
--cc=njavali@marvell.com \
--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