From: Su Hui <suhui@nfschina.com>
To: Dan Carpenter <dan.carpenter@linaro.org>, Baoquan He <bhe@redhat.com>
Cc: akpm@linux-foundation.org, vgoyal@redhat.com, dyoung@redhat.com,
kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org,
Su Hui <suhui@nfschina.com>
Subject: Re: [PATCH] fs/proc/vmcore: a few cleanups for vmcore_add_device_dump
Date: Tue, 24 Jun 2025 10:14:55 +0800 [thread overview]
Message-ID: <a90315db-e2d9-4a86-9be5-6ea88f5c94a2@nfschina.com> (raw)
In-Reply-To: <d60db71a-0b4f-4e7d-8c06-7493934aa507@suswa.mountain>
On 2025/6/23 23:22, Dan Carpenter wrote:
> On Mon, Jun 23, 2025 at 10:36:45PM +0800, Baoquan He wrote:
>> On 06/23/25 at 06:47pm, Su Hui wrote:
>>> There are three cleanups for vmcore_add_device_dump(). Adjust data_size's
>>> type from 'size_t' to 'unsigned int' for the consistency of data->size.
>> It's unclear to me why size_t is not suggested here. Isn't it assigned
>> a 'sizeof() + data->size' in which size_t should be used?
Oh, sorry for this, I missed some things.
1497 data_size = roundup(sizeof(struct vmcoredd_header) +
data->size,
1498 PAGE_SIZE);
1499
1500 /* Allocate buffer for driver's to write their dumps */
1501 buf = vmcore_alloc_buf(data_size);
[...]
1515
1516 dump->buf = buf;
1517 dump->size = data_size;
^^^^^^^^^^^^^^^^^^^^^
If data_size is 64 bit and assume data_size is bigger than 32bit,
dump->size will overflow.
Should we adjust dump->size's type to size_t? Or maybe it's impossible
for data_size bigger
than 32bit?
> Yeah... That's a good point. People should generally default to size_t
> for sizes. It really does prevent a lot of integer overflow bugs. In
> this case data->size is not controlled by the user, but if it were
> then that would be an integer overflow on 32bit systems and not on
> 64bit systems, until we start declaring sizes as unsigned int and
> then all the 32bit bugs start affecting everyone.
Agreed, sorry for my fault again.
I will remove the 'unsigned int' in v2 patch.
Thanks for your suggestions!
regards,
Su Hui
next prev parent reply other threads:[~2025-06-24 2:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-23 10:47 Su Hui
2025-06-23 14:36 ` Baoquan He
2025-06-23 15:22 ` Dan Carpenter
2025-06-24 2:14 ` Su Hui [this message]
2025-06-23 15:06 ` Dan Carpenter
2025-06-24 2:20 ` Su Hui
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=a90315db-e2d9-4a86-9be5-6ea88f5c94a2@nfschina.com \
--to=suhui@nfschina.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=dan.carpenter@linaro.org \
--cc=dyoung@redhat.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kexec@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vgoyal@redhat.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
all inboxes | Powered by JetHome®