From: liulongfang <liulongfang@huawei.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
Marion & Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: "David S. Miller" <davem@davemloft.net>,
Zaibo Xu <xuzaibo@huawei.com>, <linux-kernel@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>, <linux-crypto@vger.kernel.org>
Subject: Re: [PATCH] crypto: hisilicon/hpre - Fix a erroneous check after snprintf()
Date: Wed, 6 Sep 2023 10:04:42 +0800 [thread overview]
Message-ID: <f4379fee-22c2-3b94-1725-70a317cc9baf@huawei.com> (raw)
In-Reply-To: <ZPbkJOPsx4as96D/@gondor.apana.org.au>
On 2023/9/5 16:17, Herbert Xu wrote:
> On Tue, Sep 05, 2023 at 07:27:47AM +0200, Marion & Christophe JAILLET wrote:
>>
>> Some debugfs dir of file way be left around. Is it what your are talking
>> about?
>
> Yes all allocated resources should be freed on the error path.
>
>>> The other snprintf in the same file also looks suspect.
>>
>> It looks correct to me.
>>
>> And HPRE_DBGFS_VAL_MAX_LEN being 20, it doesn't really matter. The string
>> can't be truncated with just a "%u\n".
>
> Well if you're going to go with that line of reasoning then this
> case ("cluster%d") can't overflow either, no?
>
First, I checked the calling code of the snprintf function in all driver files in
the hisilicon directory. Only here is the processing of return value judgment.
This treatment is indeed problematic and needs to be modified.
Then, I don't quite agree with your modification plan.
The modification of this solution is not complete.
As Herbert said, ("cluster%d") may still have overflow problems.
In the end, my proposed modification scheme is this:
...
int ret;
u8 i;
for (i = 0; i < clusters_num; i++) {
snprintf(buf, HPRE_DBGFS_VAL_MAX_LEN, "cluster%u", i);
tmp_d = debugfs_create_dir(buf, qm->debug.debug_root);
...
}
...
Thanks,
Longfang.
> Cheers,
>
next prev parent reply other threads:[~2023-09-06 2:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 20:17 [PATCH] crypto: hisilicon/hpre - Fix a erroneous check after snprintf() Christophe JAILLET
2023-09-05 2:27 ` Herbert Xu
2023-09-05 5:27 ` Marion & Christophe JAILLET
2023-09-05 8:17 ` Herbert Xu
2023-09-06 2:04 ` liulongfang [this message]
2023-09-08 16:11 ` Christophe JAILLET
2023-09-11 1:52 ` liulongfang
2023-09-07 11:15 ` Dan Carpenter
2023-09-11 1:58 ` liulongfang
2023-09-11 7:27 ` Dan Carpenter
2023-09-12 6:39 ` Dan Carpenter
2023-09-12 10:05 ` Herbert Xu
2023-09-15 10:43 ` Herbert Xu
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=f4379fee-22c2-3b94-1725-70a317cc9baf@huawei.com \
--to=liulongfang@huawei.com \
--cc=christophe.jaillet@wanadoo.fr \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xuzaibo@huawei.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