From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758605AbcK3Vdp (ORCPT ); Wed, 30 Nov 2016 16:33:45 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:52338 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758519AbcK3Vdn (ORCPT ); Wed, 30 Nov 2016 16:33:43 -0500 Date: Wed, 30 Nov 2016 13:33:58 -0800 From: Andrew Morton To: Yisheng Xie Cc: , , , , , , , , , , , , Subject: Re: [PATCH] kernel/sysctl: return -EINVAL if write invalid val to ulong type sysctl Message-Id: <20161130133358.d508cc8931be6f08ee88561f@linux-foundation.org> In-Reply-To: <1480501852-36968-1-git-send-email-xieyisheng1@huawei.com> References: <1480501852-36968-1-git-send-email-xieyisheng1@huawei.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 Nov 2016 18:30:52 +0800 Yisheng Xie wrote: > I tried to echo an invalid value to an unsigned long type sysctl on > 4.9.0-rc6: > linux:~# cat /proc/sys/vm/user_reserve_kbytes > 131072 > linux:~# echo -1 > /proc/sys/vm/user_reserve_kbytes > linux:~# cat /proc/sys/vm/user_reserve_kbytes > 131072 > > The echo operation got error and the value do not write to > user_reserve_kbytes, however, user do not know it until checking > the value again. > > This patch return -EINVAL when write an invalid value to unsigned > long type sysctl to make user know what happened without > checking its value once more, just as what proc_douintvec do. hmpf. # echo 18446744073709551615 > /proc/sys/vm/user_reserve_kbytes # cat /proc/sys/vm/user_reserve_kbytes 18446744073709551615 I think that when taking in an unsigned long the kernel should simply treat -1 as 0xffffffff (or 0xffffffffffffffff). It's natural and normal and everyone knows what it means?