netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lijun Pan <ljp@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: sukadev@linux.ibm.com, drt@linux.ibm.com, Lijun Pan <ljp@linux.ibm.com>
Subject: [PATCH net 13/15] ibmvnic: fix NULL pointer dereference in ibmvic_reset_crq
Date: Fri, 20 Nov 2020 16:40:47 -0600	[thread overview]
Message-ID: <20201120224049.46933-14-ljp@linux.ibm.com> (raw)
In-Reply-To: <20201120224049.46933-1-ljp@linux.ibm.com>

crq->msgs could be NULL if the previous reset did not complete after
freeing crq->msgs. Check for NULL before dereferencing them.

Snippet of call trace:
...
ibmvnic 30000003 env3 (unregistering): Releasing sub-CRQ
ibmvnic 30000003 env3 (unregistering): Releasing CRQ
BUG: Kernel NULL pointer dereference on read at 0x00000000
Faulting instruction address: 0xc0000000000c1a30
Oops: Kernel access of bad area, sig: 11 [#1]
LE PAGE_SIZE=64K MMU=Hash SMP NR_CPUS=2048 NUMA pSeries
Modules linked in: ibmvnic(E-) rpadlpar_io rpaphp xt_CHECKSUM xt_MASQUERADE xt_conntrack ipt_REJECT nf_reject_ipv4 nft_compat nft_counter nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables xsk_diag tcp_diag udp_diag tun raw_diag inet_diag unix_diag bridge af_packet_diag netlink_diag stp llc rfkill sunrpc pseries_rng xts vmx_crypto uio_pdrv_genirq uio binfmt_misc ip_tables xfs libcrc32c sd_mod t10_pi sg ibmvscsi ibmveth scsi_transport_srp dm_mirror dm_region_hash dm_log dm_mod [last unloaded: ibmvnic]
CPU: 20 PID: 8426 Comm: kworker/20:0 Tainted: G            E     5.10.0-rc1+ #12
Workqueue: events __ibmvnic_reset [ibmvnic]
NIP:  c0000000000c1a30 LR: c008000001b00c18 CTR: 0000000000000400
REGS: c00000000d05b7a0 TRAP: 0380   Tainted: G            E      (5.10.0-rc1+)
MSR:  800000000280b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 44002480  XER: 20040000
CFAR: c0000000000c19ec IRQMASK: 0
GPR00: 0000000000000400 c00000000d05ba30 c008000001b17c00 0000000000000000
GPR04: 0000000000000000 0000000000000000 0000000000000000 00000000000001e2
GPR08: 000000000001f400 ffffffffffffd950 0000000000000000 c008000001b0b280
GPR12: c0000000000c19c8 c00000001ec72e00 c00000000019a778 c00000002647b440
GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20: 0000000000000006 0000000000000001 0000000000000003 0000000000000002
GPR24: 0000000000001000 c008000001b0d570 0000000000000005 c00000007ab5d550
GPR28: c00000007ab5c000 c000000032fcf848 c00000007ab5cc00 c000000032fcf800
NIP [c0000000000c1a30] memset+0x68/0x104
LR [c008000001b00c18] ibmvnic_reset_crq+0x70/0x110 [ibmvnic]
Call Trace:
[c00000000d05ba30] [0000000000000800] 0x800 (unreliable)
[c00000000d05bab0] [c008000001b0a930] do_reset.isra.40+0x224/0x634 [ibmvnic]
[c00000000d05bb80] [c008000001b08574] __ibmvnic_reset+0x17c/0x3c0 [ibmvnic]
[c00000000d05bc50] [c00000000018d9ac] process_one_work+0x2cc/0x800
[c00000000d05bd20] [c00000000018df58] worker_thread+0x78/0x520
[c00000000d05bdb0] [c00000000019a934] kthread+0x1c4/0x1d0
[c00000000d05be20] [c00000000000d5d0] ret_from_kernel_thread+0x5c/0x6c

Signed-off-by: Lijun Pan <ljp@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index a0dbd963a1ab..dda2d4bb9b40 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -5053,6 +5053,10 @@ static int ibmvnic_reset_crq(struct ibmvnic_adapter *adapter)
 	} while (rc == H_BUSY || H_IS_LONG_BUSY(rc));
 
 	/* Clean out the queue */
+	if (!crq->msgs) {
+		netdev_warn(adapter->netdev, "crq->msgs == NULL\n");
+		return -EINVAL;
+	}
 	memset(crq->msgs, 0, PAGE_SIZE);
 	crq->cur = 0;
 	crq->active = false;
-- 
2.23.0


  parent reply	other threads:[~2020-11-20 22:41 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20 22:40 [PATCH net 00/15] ibmvnic: assorted bug fixes Lijun Pan
2020-11-20 22:40 ` [PATCH net 01/15] ibmvnic: handle inconsistent login with reset Lijun Pan
2020-11-21 23:36   ` Jakub Kicinski
2020-11-20 22:40 ` [PATCH net 02/15] ibmvnic: process HMC disable command Lijun Pan
2020-11-21 23:36   ` Jakub Kicinski
2020-11-21 23:38     ` Jakub Kicinski
2020-11-22 15:12     ` drt
2020-11-23 19:43       ` Jakub Kicinski
2020-11-23 21:46         ` drt
2020-11-20 22:40 ` [PATCH net 03/15] ibmvnic: stop free_all_rwi on failed reset Lijun Pan
2020-11-20 22:40 ` [PATCH net 04/15] ibmvnic: remove free_all_rwi function Lijun Pan
2020-11-21 23:39   ` Jakub Kicinski
2020-11-20 22:40 ` [PATCH net 05/15] ibmvnic: avoid memset null scrq msgs Lijun Pan
2020-11-20 22:40 ` [PATCH net 06/15] ibmvnic: restore adapter state on failed reset Lijun Pan
2020-11-20 22:40 ` [PATCH net 07/15] ibmvnic: delay next reset if hard reset failed Lijun Pan
2020-11-20 22:40 ` [PATCH net 08/15] ibmvnic: track pending login Lijun Pan
2020-11-20 22:40 ` [PATCH net 09/15] ibmvnic: send_login should check for crq errors Lijun Pan
2020-11-20 22:40 ` [PATCH net 10/15] ibmvnic: no reset timeout for 5 seconds after reset Lijun Pan
2020-11-20 23:01   ` drt
2020-11-20 22:40 ` [PATCH net 11/15] ibmvnic: reduce wait for completion time Lijun Pan
2020-11-20 22:40 ` [PATCH net 12/15] ibmvnic: fix NULL pointer dereference in reset_sub_crq_queues Lijun Pan
2020-11-21 23:44   ` Jakub Kicinski
2020-11-20 22:40 ` Lijun Pan [this message]
2020-11-20 22:40 ` [PATCH net 14/15] ibmvnic: enhance resetting status check during module exit Lijun Pan
2020-11-20 22:40 ` [PATCH net 15/15] ibmvnic: add some debugs Lijun Pan
2020-11-21 23:45   ` Jakub Kicinski
2020-11-23 19:48     ` Sukadev Bhattiprolu
2020-11-23 19:38 ` [PATCH net 00/15] ibmvnic: assorted bug fixes ljp

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=20201120224049.46933-14-ljp@linux.ibm.com \
    --to=ljp@linux.ibm.com \
    --cc=drt@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=sukadev@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).