From: Tuo Li <islituo@gmail.com>
To: dledford@redhat.com, jgg@ziepe.ca
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
baijiaju1990@gmail.com, Tuo Li <islituo@gmail.com>,
TOTE Robot <oslab@tsinghua.edu.cn>
Subject: [PATCH] IB/mthca: Fix possible uninitialized-variable access in mthca_SYS_EN()
Date: Wed, 11 Aug 2021 05:34:15 -0700 [thread overview]
Message-ID: <20210811123415.8200-1-islituo@gmail.com> (raw)
The variable out is declared without initialization, and its address is
passed to mthca_cmd_imm():
ret = mthca_cmd_imm(dev, 0, &out, 0, 0, CMD_SYS_EN, CMD_TIME_CLASS_D);
In this function, mthca_cmd_wait() or mthca_cmd_poll() will be called with
the argument out_param, which is the address of the varialbe out. In these
two called functions, mthca_cmd_post() will be called with *out_param,
whose value comes from the uninitialized variable out.
err = mthca_cmd_post(dev, in_param, out_param ? *out_param : 0, ...)
In mthca_cmd_post(), mthca_cmd_post_dbell() or mthca_cmd_post_hcr() will
be called, in which the value from the uninitialized varialble out may be
used:
__raw_writel((__force u32) cpu_to_be32(out_param >> 32), ptr + offs[3]);
To fix this possible uninitialized-variable access, initialized out to 0
at the begining of mthca_SYS_EN().
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
---
drivers/infiniband/hw/mthca/mthca_cmd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index bdf5ed38de22..86584982e496 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -635,7 +635,7 @@ void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox)
int mthca_SYS_EN(struct mthca_dev *dev)
{
- u64 out;
+ u64 out = 0;
int ret;
ret = mthca_cmd_imm(dev, 0, &out, 0, 0, CMD_SYS_EN, CMD_TIME_CLASS_D);
--
2.25.1
next reply other threads:[~2021-08-11 12:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-11 12:34 Tuo Li [this message]
2021-08-11 12:49 ` [PATCH] IB/mthca: Fix possible uninitialized-variable access in mthca_SYS_EN() Leon Romanovsky
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=20210811123415.8200-1-islituo@gmail.com \
--to=islituo@gmail.com \
--cc=baijiaju1990@gmail.com \
--cc=dledford@redhat.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=oslab@tsinghua.edu.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.