linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiaoming Ni <nixiaoming@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <mcgrof@kernel.org>,
	<keescook@chromium.org>, <yzaikin@google.com>,
	<adobriyan@gmail.com>, <linux-fsdevel@vger.kernel.org>,
	<vbabka@suse.cz>, <mhocko@suse.com>, <andy.shevchenko@gmail.com>,
	<wangle6@huawei.com>
Subject: Re: [PATCH v3] proc_sysctl: fix oops caused by incorrect command parameters.
Date: Tue, 12 Jan 2021 14:24:05 +0800	[thread overview]
Message-ID: <89d1369e-f0a8-66f2-c0ea-3aac3a55e2c1@huawei.com> (raw)
In-Reply-To: <20210111203340.98dd3c8fa675b709bcf6d49e@linux-foundation.org>

On 2021/1/12 12:33, Andrew Morton wrote:
> On Tue, 12 Jan 2021 11:31:55 +0800 Xiaoming Ni <nixiaoming@huawei.com> wrote:
> 
>> The process_sysctl_arg() does not check whether val is empty before
>>   invoking strlen(val). If the command line parameter () is incorrectly
>>   configured and val is empty, oops is triggered.
>>
>> --- a/fs/proc/proc_sysctl.c
>> +++ b/fs/proc/proc_sysctl.c
>> @@ -1770,6 +1770,9 @@ static int process_sysctl_arg(char *param, char *val,
>>   			return 0;
>>   	}
>>   
>> +	if (!val)
>> +		return -EINVAL;
>> +
> 
> I think v2 (return 0) was preferable.  Because all the other error-out
> cases in process_sysctl_arg() also do a `return 0'.

https://lore.kernel.org/lkml/bc098af4-c0cd-212e-d09d-46d617d0acab@huawei.com/

patch4:
     +++ b/fs/proc/proc_sysctl.c
     @@ -1757,6 +1757,9 @@ static int process_sysctl_arg(char *param, 
char *val,
             loff_t pos = 0;
             ssize_t wret;

     +       if (!val)
     +               return 0;
     +
             if (strncmp(param, "sysctl", sizeof("sysctl") - 1) == 0) {
                     param += sizeof("sysctl") - 1;

Is this the version you're talking about?

> 
> If we're going to do a separate "patch: make process_sysctl_arg()
> return an errno instead of 0" then fine, we can discuss that.  But it's
> conceptually a different work from fixing this situation.
> .
> 
However, are the logs generated by process_sysctl_arg() clearer and more 
accurate than parse_args()? Should the logs generated by 
process_sysctl_arg() be deleted?

Thanks
Xiaoming Ni


  reply	other threads:[~2021-01-12  6:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12  3:31 [PATCH v3] proc_sysctl: fix oops caused by incorrect command parameters Xiaoming Ni
2021-01-12  4:33 ` Andrew Morton
2021-01-12  6:24   ` Xiaoming Ni [this message]
2021-01-12  6:28     ` Andrew Morton
2021-01-12  7:24       ` Michal Hocko
2021-01-12 11:42         ` Vlastimil Babka
2021-01-17  2:59           ` Xiaoming Ni
2021-01-18 10:50             ` Vlastimil Babka

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=89d1369e-f0a8-66f2-c0ea-3aac3a55e2c1@huawei.com \
    --to=nixiaoming@huawei.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mhocko@suse.com \
    --cc=vbabka@suse.cz \
    --cc=wangle6@huawei.com \
    --cc=yzaikin@google.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).