netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Chan <mchan@broadcom.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <eddie.wai@broadcom.com>
Subject: [PATCH net-next 1/3] cnic: Use proper ulp_ops for per device operations.
Date: Mon, 17 Mar 2014 19:19:06 -0800	[thread overview]
Message-ID: <1395112748-21965-2-git-send-email-mchan@broadcom.com> (raw)
In-Reply-To: <1395112748-21965-1-git-send-email-mchan@broadcom.com>

For per device operations, cnic needs to dereference the RCU protected
cp->ulp_ops instead of the global cnic_ulp_tbl.  In 2 locations,
cnic_send_nlmsg() and cnic_copy_ulp_stats(), it was referencing the
global table.  If the device has been unregistered and these functions
are still being called (very unlikely scenarios), it could lead to NULL
pointer dereference.

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/cnic.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index fcf9105..2cb2482 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -342,7 +342,7 @@ static int cnic_send_nlmsg(struct cnic_local *cp, u32 type,
 	while (retry < 3) {
 		rc = 0;
 		rcu_read_lock();
-		ulp_ops = rcu_dereference(cnic_ulp_tbl[CNIC_ULP_ISCSI]);
+		ulp_ops = rcu_dereference(cp->ulp_ops[CNIC_ULP_ISCSI]);
 		if (ulp_ops)
 			rc = ulp_ops->iscsi_nl_send_msg(
 				cp->ulp_handle[CNIC_ULP_ISCSI],
@@ -3244,7 +3244,8 @@ static int cnic_copy_ulp_stats(struct cnic_dev *dev, int ulp_type)
 	int rc;
 
 	mutex_lock(&cnic_lock);
-	ulp_ops = cnic_ulp_tbl_prot(ulp_type);
+	ulp_ops = rcu_dereference_protected(cp->ulp_ops[ulp_type],
+					    lockdep_is_held(&cnic_lock));
 	if (ulp_ops && ulp_ops->cnic_get_stats)
 		rc = ulp_ops->cnic_get_stats(cp->ulp_handle[ulp_type]);
 	else
-- 
1.7.1

  reply	other threads:[~2014-03-18  2:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-18  3:19 [PATCH net-next 0/3] cnic bug fixes for net-next Michael Chan
2014-03-18  3:19 ` Michael Chan [this message]
2014-03-18  3:19   ` [PATCH net-next 2/3] cnic,bnx2i,bnx2fc: Fix inconsistent use of page size Michael Chan
2014-03-18  3:19     ` [PATCH net-next 3/3] cnic: Update version to 2.5.20 and copyright year Michael Chan
2014-03-18 20:03 ` [PATCH net-next 0/3] cnic bug fixes for net-next David Miller

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=1395112748-21965-2-git-send-email-mchan@broadcom.com \
    --to=mchan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=eddie.wai@broadcom.com \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).