public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Baokun Li <libaokun1@huawei.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu,
	adilger.kernel@dilger.ca, jack@suse.cz, ritesh.list@gmail.com,
	linux-kernel@vger.kernel.org, yi.zhang@huawei.com,
	yangerkun@huawei.com, chengzhihao1@huawei.com,
	yukuai3@huawei.com, libaokun1@huawei.com
Subject: Re: [PATCH 1/7] ext4: avoid overflow when setting values via sysfs
Date: Sat, 27 Jan 2024 12:44:09 +0300	[thread overview]
Message-ID: <1da0649d-812f-4dee-9c1b-af567afa2e46@p183> (raw)

Baokun Li wrote:

> @@ -463,6 +463,8 @@ static ssize_t ext4_attr_store(struct kobject *kobj,
>  		ret = kstrtoul(skip_spaces(buf), 0, &t);
>  		if (ret)
>  			return ret;
> +		if (t != (unsigned int)t)
> +			return -EINVAL;

kstrto*() interface has variants for all standard types.
It should be changed to kstrtou32() or kstrtouint();

If you check if kstrto*() result fits into another type,
you're probably doing it wrong.

>  		if (a->attr_ptr == ptr_ext4_super_block_offset)
>  			*((__le32 *) ptr) = cpu_to_le32(t);

             reply	other threads:[~2024-01-27  9:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-27  9:44 Alexey Dobriyan [this message]
2024-01-27 10:44 ` [PATCH 1/7] ext4: avoid overflow when setting values via sysfs Baokun Li
  -- strict thread matches above, loose matches on Subject: below --
2024-01-26  8:57 [PATCH 0/7] ext4: avoid sysfs variables overflow causing BUG_ON/SOOB Baokun Li
2024-01-26  8:57 ` [PATCH 1/7] ext4: avoid overflow when setting values via sysfs Baokun Li
2024-01-26  9:28   ` Zhang Yi
2024-02-13 16:05   ` Jan Kara
2024-02-17  7:09     ` Baokun Li
2024-02-23 11:54       ` Jan Kara
2024-02-24  1:59         ` Baokun Li

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=1da0649d-812f-4dee-9c1b-af567afa2e46@p183 \
    --to=adobriyan@gmail.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=chengzhihao1@huawei.com \
    --cc=jack@suse.cz \
    --cc=libaokun1@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ritesh.list@gmail.com \
    --cc=tytso@mit.edu \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@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