Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753370AbbDARdB (ORCPT ); Wed, 1 Apr 2015 13:33:01 -0400 Received: from mout.gmx.net ([212.227.17.20]:55513 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753298AbbDARc5 (ORCPT ); Wed, 1 Apr 2015 13:32:57 -0400 Message-ID: <551C2B86.6080204@gmx.de> Date: Wed, 01 Apr 2015 19:31:50 +0200 From: Heinrich Schuchardt User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.5.0 MIME-Version: 1.0 To: Andrew Morton CC: Michal Nazarewicz , Ingo Molnar , Steven Rostedt , Peter Zijlstra , Joe Perches , Josh Hunt , Rasmus Villemoes , Rusty Russell , Daniel Walter , David Rientjes , Kees Cook , "David S. Miller" , Johannes Weiner , Aaron Tomlin , Prarit Bhargava , Eric B Munson , "Paul E. McKenney" , Sam Ravnborg , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] sysctl: detect overflows when converting to int References: <1427657309-4344-1-git-send-email-xypron.glpk@gmx.de> <1427657309-4344-4-git-send-email-xypron.glpk@gmx.de> <20150331154554.a0c878277c6d912db39316f9@linux-foundation.org> In-Reply-To: <20150331154554.a0c878277c6d912db39316f9@linux-foundation.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:Kghw8VMh1X1+mwkA5ydVGk3KBRAz1qRFm+yvhQDwZ8iwF5uTkdd mI2JLdo2Y6nXJzxbCZZT/ShvR32CHdwYJoCCYKNp/d8CnU4YbkF6fgPHjk78Yx8DA9/v1zJ Qz2lN/uBNwGniIU8izDY9rstPe/6NeY9uT7y0naqNNLIeiRM6mF1AVq2p+RWKkrgqostWZU /D90AkIi7gbn8uqDaKTTw== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1515 Lines: 42 On 01.04.2015 00:45, Andrew Morton wrote: > On Sun, 29 Mar 2015 21:28:29 +0200 Heinrich Schuchardt wrote: > >> When converting unsigned long to int overflows may occur. >> These currently are not detected when writing to the sysctl >> file system. >> >> E.g. on a system where int has 32 bits and long has 64 bits >> echo 0x800001234 > /proc/sys/kernel/threads-max >> has the same effect as >> echo 0x1234 > /proc/sys/kernel/threads-max >> >> The patch adds the missing check in do_proc_dointvec_conv. >> >> With the patch an overflow will result in an error EINVAL when >> writing to the the sysctl file system. > > hm, why fix this? There's a small risk of breaking > accidentally-working userspace, but I expect we can live with that. > > But how big a problem is this, really? This behaviour is quite > expected, after all. > The typical user of a Linux system has never read the Kernel code and possibly has limited programming experience. Furthermore in Documentation/sysctl/kernel.txt there is no hint that only 32-bit integers can be used. So why should this typical user expect that on a 64-bit system +3000000000 is considered a negative number? Now that we know this is a bug why shouldn't we fix it? Best regards Heinrich -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/