From: Jon Hunter <jonathanh@nvidia.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: <linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Timo Alho <talho@nvidia.com>, Jon Hunter <jonathanh@nvidia.com>
Subject: [PATCH 1/5] firmware: tegra: add return code checks and increase debugfs size
Date: Sun, 12 Jul 2020 11:01:14 +0100 [thread overview]
Message-ID: <20200712100118.13343-2-jonathanh@nvidia.com> (raw)
In-Reply-To: <20200712100118.13343-1-jonathanh@nvidia.com>
From: Timo Alho <talho@nvidia.com>
Add checking of the BPMP-FW return code values for MRQ_DEBUGFS calls.
Also, development versions of the firmware may have debugfs with
directory structure larger than 256Kb. Hence increase the size of the
memory buffer to accommodate those firmware revisions.
And finally, ensure that no access outside of allocated memory buffer
happens in case BPMP-FW returns an invalid response size (nbytes) from
mrq_debugfs_dumpdir() call.
Signed-off-by: Timo Alho <talho@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
drivers/firmware/tegra/bpmp-debugfs.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
index 3f0a89ce131a..08e0f05f46c6 100644
--- a/drivers/firmware/tegra/bpmp-debugfs.c
+++ b/drivers/firmware/tegra/bpmp-debugfs.c
@@ -127,6 +127,8 @@ static int mrq_debugfs_read(struct tegra_bpmp *bpmp,
err = tegra_bpmp_transfer(bpmp, &msg);
if (err < 0)
return err;
+ else if (msg.rx.ret < 0)
+ return -EINVAL;
*nbytes = (size_t)resp.fop.nbytes;
@@ -184,6 +186,8 @@ static int mrq_debugfs_dumpdir(struct tegra_bpmp *bpmp, dma_addr_t addr,
err = tegra_bpmp_transfer(bpmp, &msg);
if (err < 0)
return err;
+ else if (msg.rx.ret < 0)
+ return -EINVAL;
*nbytes = (size_t)resp.dumpdir.nbytes;
@@ -374,7 +378,7 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
{
dma_addr_t phys;
void *virt;
- const size_t sz = SZ_256K;
+ const size_t sz = SZ_512K;
size_t nbytes;
int ret;
struct dentry *root;
@@ -394,8 +398,12 @@ int tegra_bpmp_init_debugfs(struct tegra_bpmp *bpmp)
}
ret = mrq_debugfs_dumpdir(bpmp, phys, sz, &nbytes);
- if (ret < 0)
+ if (ret < 0) {
+ goto free;
+ } else if (nbytes > sz) {
+ ret = -EINVAL;
goto free;
+ }
ret = create_debugfs_mirror(bpmp, virt, nbytes, root);
free:
--
2.17.1
next prev parent reply other threads:[~2020-07-12 10:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 10:01 [PATCH 0/5] firmware: tegra: Add support for in-band debug Jon Hunter
2020-07-12 10:01 ` Jon Hunter [this message]
2020-07-12 10:01 ` [PATCH 2/5] firmware: tegra: Use consistent return variable name Jon Hunter
2020-07-12 10:01 ` [PATCH 3/5] firmware: tegra: Prepare for supporting in-band debugfs Jon Hunter
2020-07-12 10:01 ` [PATCH 4/5] firmware: tegra: Add support for in-band debug Jon Hunter
2020-07-12 10:01 ` [PATCH 5/5] firmware: tegra: Update BPMP ABI Jon Hunter
2020-07-14 16:18 ` [PATCH 0/5] firmware: tegra: Add support for in-band debug Thierry Reding
2020-07-14 18:12 ` Jon Hunter
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=20200712100118.13343-2-jonathanh@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=talho@nvidia.com \
--cc=thierry.reding@gmail.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