From: Cong Wang <amwang@redhat.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: linux-kernel@vger.kernel.org,
Octavian Purdila <opurdila@ixiacom.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
penguin-kernel@I-love.SAKURA.ne.jp, netdev@vger.kernel.org,
Neil Horman <nhorman@tuxdriver.com>,
ebiederm@xmission.com, David Miller <davem@davemloft.net>
Subject: Re: [Patch 1/3] sysctl: refactor integer handling proc code
Date: Tue, 13 Apr 2010 15:35:44 +0800 [thread overview]
Message-ID: <4BC41ED0.3020807@redhat.com> (raw)
In-Reply-To: <20100413111814.GB4396@x200>
Alexey Dobriyan wrote:
> On Mon, Apr 12, 2010 at 06:04:04AM -0400, Amerigo Wang wrote:
>> As we are about to add another integer handling proc function a little
>> bit of cleanup is in order: add a few helper functions to improve code
>> readability and decrease code duplication.
>>
>> In the process a bug is also fixed: if the user specifies a number
>> with more then 20 digits it will be interpreted as two integers
>> (e.g. 10000...13 will be interpreted as 100.... and 13).
>
> ULONG_MAX is not 22 digits always.
>
> The fix is to not rely on simple_strtoul()
>
> I guess it's time to finally remove it. :-(
Or use strict_strtoul()?
>
> Also, it's better to copy_from user stuff once.
> Without looking at non-trivial users, one page should be enough.
It seems that all proc code assumes that the input buffer will
not exceed one page size.
>
>> Behavior for EFAULT handling was changed as well. Previous to this
>> patch, when an EFAULT error occurred in the middle of a write
>> operation, although some of the elements were set, that was not
>> acknowledged to the user (by shorting the write and returning the
>> number of bytes accepted). EFAULT is now treated just like any other
>> errors by acknowledging the amount of bytes accepted.
>
>> +static int proc_skip_wspace(char __user **buf, size_t *size)
>> +{
>> + char c;
>> +
>> + while (*size) {
>> + if (get_user(c, *buf))
>> + return -EFAULT;
>> + if (!isspace(c))
>> + break;
>> + (*size)--;
>> + (*buf)++;
>> + }
>> +
>> + return 0;
>> +}
>
> yeah, copy_from_user once, so we won't have this.
Ok.
>
>> +static bool isanyof(char c, const char *v, unsigned len)
>
> A what?
> this is memchr()
>
Hmm, right, it should be memchr(v, c, len).
Thanks!
next prev parent reply other threads:[~2010-04-13 7:35 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-12 10:03 [Patch v8 0/3] net: reserve ports for applications using fixed port numbers Amerigo Wang
2010-04-12 10:04 ` [Patch 1/3] sysctl: refactor integer handling proc code Amerigo Wang
2010-04-12 10:18 ` Alexey Dobriyan
2010-04-13 7:35 ` Cong Wang [this message]
2010-04-12 10:18 ` Alexey Dobriyan
2010-04-12 10:04 ` [Patch 2/3] sysctl: add proc_do_large_bitmap Amerigo Wang
2010-04-12 10:04 ` [Patch 3/3] net: reserve ports for applications using fixed port numbers Amerigo Wang
2010-04-13 1:21 ` Tetsuo Handa
2010-04-13 7:13 ` Cong Wang
2010-04-13 8:48 ` Cong Wang
2010-04-13 13:07 ` Tetsuo Handa
2010-04-13 16:32 ` Sean Hefty
2010-04-14 2:01 ` [PATCH] Infiniband: Randomize local port allocation penguin-kernel
2010-04-14 4:38 ` Cong Wang
2010-04-15 0:01 ` Sean Hefty
2010-04-15 2:29 ` Tetsuo Handa
[not found] ` <201004150229.o3F2T4dZ054768-etx+eQDEXHD7nzcFbJAaVXf5DAMn2ifp@public.gmane.org>
2010-04-15 19:55 ` [PATCH] rdma/cm: " Sean Hefty
2010-04-16 2:22 ` Cong Wang
[not found] ` <4BC7C9CF.20403-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2010-04-16 13:54 ` Tetsuo Handa
[not found] ` <201004162254.FJF73478.SHOOMOFtQFVJLF-JPay3/Yim36HaxMnTkn67Xf5DAMn2ifp@public.gmane.org>
2010-04-16 20:30 ` David Miller
2010-04-20 4:34 ` Cong Wang
2010-04-21 23:19 ` [PATCH] Infiniband: " Roland Dreier
2010-04-21 23:22 ` Roland Dreier
2010-04-15 5:46 ` Tetsuo Handa
-- strict thread matches above, loose matches on Subject: below --
2010-05-05 10:26 [Patch v10 0/3] net: reserve ports for applications using fixed port numbers Amerigo Wang
2010-05-05 10:26 ` [Patch 1/3] sysctl: refactor integer handling proc code Amerigo Wang
2010-04-30 8:25 [Patch v9 0/3] net: reserve ports for applications using fixed port numbers Amerigo Wang
2010-04-30 8:25 ` [Patch 1/3] sysctl: refactor integer handling proc code Amerigo Wang
2010-04-30 22:49 ` Changli Gao
2010-05-05 3:02 ` Cong Wang
2010-04-09 10:10 [Patch v7 0/3] net: reserve ports for applications using fixed port numbers Amerigo Wang
2010-04-09 10:11 ` [Patch 1/3] sysctl: refactor integer handling proc code Amerigo Wang
2010-04-09 10:49 ` Changli Gao
2010-04-09 13:40 ` Octavian Purdila
2010-04-12 6:30 ` Cong Wang
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=4BC41ED0.3020807@redhat.com \
--to=amwang@redhat.com \
--cc=adobriyan@gmail.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=opurdila@ixiacom.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
/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).