From: Andrew Morton <akpm@linux-foundation.org>
To: Eliav Farber <farbere@amazon.com>
Cc: <viro@zeniv.linux.org.uk>, <yangyicong@hisilicon.com>,
<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<andriy.shevchenko@intel.com>, <hhhawa@amazon.com>,
<jonnyc@amazon.com>
Subject: Re: [PATCH] libfs: fix error format in simple_attr_write()
Date: Thu, 15 Sep 2022 14:33:40 -0700 [thread overview]
Message-ID: <20220915143340.eeb3a8ca0bf50df1cd6359f9@linux-foundation.org> (raw)
In-Reply-To: <20220915091544.42767-1-farbere@amazon.com>
On Thu, 15 Sep 2022 09:15:44 +0000 Eliav Farber <farbere@amazon.com> wrote:
> In commit 488dac0c9237 ("libfs: fix error cast of negative value in
> simple_attr_write()"), simple_attr_write() was changed to use kstrtoull()
> instead of simple_strtoll() to convert a string got from a user.
> A user trying to set a negative value will get an error.
>
> This is wrong since it breaks all the places that use
> DEFINE_DEBUGFS_ATTRIBUTE() with format of a signed integer.
>
> For the record there are 43 current users of signed integer which are
> likely to be effected by this:
>
> $ git grep -n -A1 -w DEFINE_DEBUGFS_ATTRIBUTE | grep ');' |
> sed 's,.*\(".*%.*"\).*,\1,' | sort | uniq -c
> 1 "%08llx\n"
> 5 "0x%016llx\n"
> 5 "0x%02llx\n"
> 5 "0x%04llx\n"
> 13 "0x%08llx\n"
> 1 "0x%4.4llx\n"
> 3 "0x%.4llx\n"
> 4 "0x%llx\n"
> 1 "%1lld\n"
> 40 "%lld\n"
> 2 "%lli\n"
> 129 "%llu\n"
> 1 "%#llx\n"
> 2 "%llx\n"
>
> u64 is not an issue for negative numbers.
> The %lld and %llu in any case are for 64-bit value, representing it as
> unsigned simplifies the generic code, but it doesn't mean we can't keep
> their signed value if we know that.
>
> This change uses sscanf() to fix the problem since it does the conversion
> based on the supplied format string.
>
> Fixes: 488dac0c9237 ("libfs: fix error cast of negative value in simple_attr_write()")
488dac0c9237 was two years ago, so I'm assuming that this error isn't
causing a lot of trouble out there.
In which I may be totally wrong. Do you see a reason for backporting
this fix into earlier kernels? If so, what is it?
Thanks.
prev parent reply other threads:[~2022-09-15 21:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-15 9:15 [PATCH] libfs: fix error format in simple_attr_write() Eliav Farber
2022-09-15 21:33 ` Andrew Morton [this message]
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=20220915143340.eeb3a8ca0bf50df1cd6359f9@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=farbere@amazon.com \
--cc=hhhawa@amazon.com \
--cc=jonnyc@amazon.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=yangyicong@hisilicon.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;
as well as URLs for NNTP newsgroup(s).