target-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tuo Li <islituo@gmail.com>
To: sagi@grimberg.me, jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org, target-devel@vger.kernel.org,
	linux-kernel@vger.kernel.org, baijiaju1990@gmail.com
Subject: [BUG] IB/isert: Possible null-pointer dereference related
Date: Thu, 24 Oct 2024 09:02:00 +0800	[thread overview]
Message-ID: <57cb0385-209e-4cb0-b34c-281e5f99a3d9@gmail.com> (raw)

Hello,

Our static analysis tool has identified a potential null-pointer
dereference related to the wait-completion synchronization mechanism in
ibsert.c.

Consider the following execution scenario:

  isert_login_recv_done()  //1375
    if (isert_conn->conn)  //1390
    complete(&isert_conn->login_req_comp);  //1398

The variable isert_conn->conn is checked by an if statement at Line 1390,
which indicates that isert_conn->conn can be NULL. Then, complete() is
called at Line 1398 which will wake up the wait_for_completion_xxx().

Consider the following wait_for_completion_interruptible().

  isert_get_login_rx()  //2336
    wait_for_completion_interruptible(&isert_conn->login_req_comp); //2342
    isert_rx_login_req(isert_conn);  //2359
      conn = isert_conn->conn;       //981
      login = conn->conn_login;      //982

The value of isert_conn->conn is assigned to conn at Line 981, and then
dereferenced through conn->conn_login at Line 982. However, the variable
isert_conn->conn is checked at Line 1390, which means it can be NULL. If
so, a null-pointer dereference can occur at Line 982.

I am not quite sure whether this possible null-pointer dereference is real
and how to fix it if it is real.
Any feedback would be appreciated, thanks!

Best wishes,
Tuo Li

                 reply	other threads:[~2024-10-24  1:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=57cb0385-209e-4cb0-b34c-281e5f99a3d9@gmail.com \
    --to=islituo@gmail.com \
    --cc=baijiaju1990@gmail.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=sagi@grimberg.me \
    --cc=target-devel@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).