From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753163AbbCaWp5 (ORCPT ); Tue, 31 Mar 2015 18:45:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54684 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752412AbbCaWp4 (ORCPT ); Tue, 31 Mar 2015 18:45:56 -0400 Date: Tue, 31 Mar 2015 15:45:54 -0700 From: Andrew Morton To: Heinrich Schuchardt 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 Message-Id: <20150331154554.a0c878277c6d912db39316f9@linux-foundation.org> In-Reply-To: <1427657309-4344-4-git-send-email-xypron.glpk@gmx.de> References: <1427657309-4344-1-git-send-email-xypron.glpk@gmx.de> <1427657309-4344-4-git-send-email-xypron.glpk@gmx.de> 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 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.