linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Cheng Lin <cheng.lin130@zte.com.cn>, akpm@linux-foundation.org
Cc: keescook@chromium.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, zhong.weidong@zte.com.cn,
	wang.yi59@zte.com.cn, Sasha Levin <Alexander.Levin@microsoft.com>
Subject: Re: [PATCH] proc/sysctl: fix return error for proc_doulongvec_minmax
Date: Thu, 6 Dec 2018 00:52:42 -0800	[thread overview]
Message-ID: <20181206085242.GG28501@garbanzo.do-not-panic.com> (raw)
In-Reply-To: <1544081775-15720-1-git-send-email-cheng.lin130@zte.com.cn>

On Thu, Dec 06, 2018 at 03:36:15PM +0800, Cheng Lin wrote:
> If the number of input parameters is less than the total
> parameters, an EINVAL error will be returned.
> 
> e.g.
> We use proc_doulongvec_minmax to pass up to two parameters
> with kern_table.
> 
> {
> 	.procname       = "monitor_signals",
> 	.data           = &monitor_sigs,
> 	.maxlen         = 2*sizeof(unsigned long),
> 	.mode           = 0644,
> 	.proc_handler   = proc_doulongvec_minmax,
> },
> 
> Reproduce:
> When passing two parameters, it's work normal. But passing
> only one parameter, an error "Invalid argument"(EINVAL) is
> returned.
> 
> [root@cl150 ~]# echo 1 2 > /proc/sys/kernel/monitor_signals
> [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
> 1       2
> [root@cl150 ~]# echo 3 > /proc/sys/kernel/monitor_signals
> -bash: echo: write error: Invalid argument
> [root@cl150 ~]# echo $?
> 1
> [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
> 3       2
> [root@cl150 ~]#
> 
> The following is the result after apply this patch. No error
> is returned when the number of input parameters is less than
> the total parameters.
> 
> [root@cl150 ~]# echo 1 2 > /proc/sys/kernel/monitor_signals
> [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
> 1       2
> [root@cl150 ~]# echo 3 > /proc/sys/kernel/monitor_signals
> [root@cl150 ~]# echo $?
> 0
> [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
> 3       2
> [root@cl150 ~]#
> 
> There are three processing functions dealing with digital parameters,
> __do_proc_dointvec/__do_proc_douintvec/__do_proc_doulongvec_minmax.
> 
> This patch deals with __do_proc_doulongvec_minmax, just as
> __do_proc_dointvec does, adding a check for parameters 'left'. In
> __do_proc_douintvec, its code implementation explicitly does not
> support multiple inputs.
> 
> static int __do_proc_douintvec(...){
>          ...
>          /*
>           * Arrays are not supported, keep this simple. *Do not* add
>           * support for them.
>           */
>          if (vleft != 1) {
>                  *lenp = 0;
>                  return -EINVAL;
>          }
>          ...
> }
> 
> So, just __do_proc_doulongvec_minmax has the problem. And most use of
> proc_doulongvec_minmax/proc_doulongvec_ms_jiffies_minmax just have one
> parameter.
> 
> Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn>

Thanks for fixing up the commit log.

Acked-by: Luis Chamberlain <mcgrof@kernel.org>

I think we can live with this outside of stable. So stable is not
needed. But I would not be surprised if autosel algorithm will end
up picking it up. And if so.. well, it cannot hurt.

  Luis

  reply	other threads:[~2018-12-06  8:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06  7:36 [PATCH] proc/sysctl: fix return error for proc_doulongvec_minmax Cheng Lin
2018-12-06  8:52 ` Luis Chamberlain [this message]
2018-12-06 20:57   ` Kees Cook
  -- strict thread matches above, loose matches on Subject: below --
2018-11-30  6:35 Cheng Lin
2018-11-30 19:14 ` Luis Chamberlain

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=20181206085242.GG28501@garbanzo.do-not-panic.com \
    --to=mcgrof@kernel.org \
    --cc=Alexander.Levin@microsoft.com \
    --cc=akpm@linux-foundation.org \
    --cc=cheng.lin130@zte.com.cn \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wang.yi59@zte.com.cn \
    --cc=zhong.weidong@zte.com.cn \
    /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).