Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10443570imu; Thu, 6 Dec 2018 00:53:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/X7eXf4U9mUSe+zoZWjGZM7Kq3WNKiAFEgUXqPGN73k8GUPbaNAiYpJwF+KU42jQsmhojEj X-Received: by 2002:a63:ac1a:: with SMTP id v26mr23706172pge.293.1544086421068; Thu, 06 Dec 2018 00:53:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544086421; cv=none; d=google.com; s=arc-20160816; b=L8dyDZlyB6lQSFQJ0V/OJ1GBf5l701Wafo255H1ipyBccJFwvHq7yvhhuaqoR+zsiY 93xpeE5fLVJUMkhoOkWDDOeebdJrqQLdsIkpIPoyHoVCy3IVny/arK5fQrF1QcjONFw8 LuZT3FyzPIZsk3EZb9JurmcPBzW+cHXHgpZ3SFcyLH2BFp7JM2rQDqWF1FGC099RrO1H D+ky/4cacTULoYfhOWrqIlrcmUQ0YFqbKZSSTMvK3PUJXnuUi42WjLbIAWjFF72D2TEU BwFvQSlVyS2bAMAd6s9bTPGr/h9fWTKx1FX3N4oZwBCBiZhjad03AbPJiDl+Ht+6AZ28 m2xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rdBsaVY95wa4qiacnYzRDofddx6W9Q6XiFfXLWmnB4Q=; b=BgeGVJM813w3MAmbE/qvOgHbGtlDUF7D9BPOJGNp8rO3Cnsf8qOLeMIJsKK5Dl9HXy WwlgGiFPPgiyh1BsLmFkbOlGaWyHNSVRBEgr7x8KhaLw9+WToTdQTqP+BvUqHWP5w4nl ZWG489Pobv9Y92Or6szTiw2jM3ceMO+5LazgCZlzgwz831cb4MuwPibVnKAdp/eBDoHD GrLoDWO7rKg4L1/PD4Sa2kZ7wwqpzixYJ1CQG5huVkhdYnwQwlLGNmY+l8Dynw4uv9zk 1qqN1EYq7p/Vmom41nDZk7Z5D/HZHRUjr6Bx2II46K79RBZGN80vdfnlaSxsTi7OIYvy qVUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si23305507plz.233.2018.12.06.00.53.24; Thu, 06 Dec 2018 00:53:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728482AbeLFIwq (ORCPT + 99 others); Thu, 6 Dec 2018 03:52:46 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43322 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727763AbeLFIwq (ORCPT ); Thu, 6 Dec 2018 03:52:46 -0500 Received: by mail-pg1-f196.google.com with SMTP id v28so10335307pgk.10; Thu, 06 Dec 2018 00:52:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rdBsaVY95wa4qiacnYzRDofddx6W9Q6XiFfXLWmnB4Q=; b=sJOrGBScWd8KGWpw3qgRbiyvgSgHEjKhm6vLILqzqwmnrr9lTXZjrtIXGZNEawwAuq IVNcddiDwIE/XJriTTsBzxIc4WlVzJ9w4Twto4fAorblKWKFPhQYZfCz6DH1LV/z4Eaj 1zN8JNI7v/JJDFDIa1sRsr5oN1NQV7+QU/4mGU/JXwVG82OsLX/BRw5XMa3GOcIKMyeP IWg6FozLX7vVC3sJxppW2BaNl18xO9KiySKhIWeYFNulKo/vZZ9zmfxKYuFrbUtiYUdn kikuxb0gHfb4c0c34eGQUDxYV+zEIxkrsv7nWKpm0ZRp5I/KrydPgeq2SkkMU8KG0Nuh av0Q== X-Gm-Message-State: AA+aEWaGNzi6VpdE9es5kcmBXAp8RDV1Usr2sWMOgakyGD8IrtPd8ljg 3Y+8Bt5aJ/aFmUKKS5EgCyc= X-Received: by 2002:a63:5122:: with SMTP id f34mr22435124pgb.218.1544086365322; Thu, 06 Dec 2018 00:52:45 -0800 (PST) Received: from garbanzo.do-not-panic.com (c-73-71-40-85.hsd1.ca.comcast.net. [73.71.40.85]) by smtp.gmail.com with ESMTPSA id t2sm38212844pfm.32.2018.12.06.00.52.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 00:52:44 -0800 (PST) Received: by garbanzo.do-not-panic.com (sSMTP sendmail emulation); Thu, 06 Dec 2018 00:52:42 -0800 Date: Thu, 6 Dec 2018 00:52:42 -0800 From: Luis Chamberlain To: Cheng Lin , 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 Subject: Re: [PATCH] proc/sysctl: fix return error for proc_doulongvec_minmax Message-ID: <20181206085242.GG28501@garbanzo.do-not-panic.com> References: <1544081775-15720-1-git-send-email-cheng.lin130@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1544081775-15720-1-git-send-email-cheng.lin130@zte.com.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Thanks for fixing up the commit log. Acked-by: Luis Chamberlain 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