Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp580647img; Fri, 22 Mar 2019 04:28:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFUiq3zR5haZA7ku7ncL2UW/8KXXx77Q/VNzAPVvq9tKqlkLZ+7BDhsgAT910KevJd3FLh X-Received: by 2002:a62:1212:: with SMTP id a18mr8613891pfj.177.1553254133359; Fri, 22 Mar 2019 04:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553254133; cv=none; d=google.com; s=arc-20160816; b=jz7fnAMzE6n9VAAbiB+xcSrJEyPjdsKt9+KcRnoth5zPT8oxzKhjBAkkjrr7IAPfmC YZifwejg3oxMlB88WmV3gBHhL7/Wrc/NRGLSQMGPztUEUAaCQG43C1djweayMvYOsJZN 3oAY2J3T49r/JwzJM7H2nq+QsnlN2FU0WmdZbqmgT4QGRtrXR0mEmi3nNXHJthMyxeR9 eJXxAialfVy1qeHdLjU2SzZJhplyELrHi6bo037QGI3C4i8jhUHfkWz2Gg6x29NlIg68 a2xzijUGzS5Fj0N3FA5A8srLMGy7/BkJ+dyk0nG8QUI58HUpgF3ZejU+AIF+tojssHlE zN3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FfWri3hIzJqdY3V8UierLMBbEbe/dij0+cCQ20Xf7fY=; b=DxIWpsAbAVNepa/TsETOA+YUzYa1lLKwm6ZFiQT+Gvmo1li4xS/27eZoRDWzW2nj0M xA2BhYJytu+i2jUk/RHKiICkWOMnJY6dY3rqx+gTqpIB2z4vDc4ktXUL8kOxZ8xMgLx+ Vwq6tS26LmZuYPOt5urqmFmSeVe3oHCz8GXlsr/mzBjsz04tv+lOTBE0GbYD85YQSaO6 unXp7j9rYbsZgGvaCCz96WfphbnrLwxsf/eJXIiK2hVI6bunttPbbtCfrhe6WnMydWBH Gs4wfYfe3uCKMAutDWWZmSxFobM+NSV59cRC4Vclxl9OIM8ruN+hCAcE8XFCTsABarwb 0DhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RBvggWnk; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p6si6403632pga.151.2019.03.22.04.28.36; Fri, 22 Mar 2019 04:28:53 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=RBvggWnk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729452AbfCVL0n (ORCPT + 99 others); Fri, 22 Mar 2019 07:26:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:54438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728527AbfCVL0m (ORCPT ); Fri, 22 Mar 2019 07:26:42 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E738020657; Fri, 22 Mar 2019 11:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553254001; bh=EnF7MeBTW0j7hpgBQXTSAHzkd7ebYsc5Oy6a1iM5aQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBvggWnkGIoyluQF2gyg+Vh00HS9tnGyy7GyEJvQr1BB0DAew+fxB5kC1iAZ0WGQu QZ1+6FRMHhHaHagra7VRi3N396yl0yZb3QPR64akMT70JdxtUJzr3Vhd+DbXHo+QIF +8GRd+oxJhD+JHJA/Trc5PVduoB4ES/TQ1GNIaNI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zev Weiss , Brendan Higgins , Iurii Zaikin , Kees Cook , Luis Chamberlain , Andrew Morton , Linus Torvalds Subject: [PATCH 3.18 121/134] kernel/sysctl.c: add missing range check in do_proc_dointvec_minmax_conv Date: Fri, 22 Mar 2019 12:15:34 +0100 Message-Id: <20190322111219.145981996@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zev Weiss commit 8cf7630b29701d364f8df4a50e4f1f5e752b2778 upstream. This bug has apparently existed since the introduction of this function in the pre-git era (4500e91754d3 in Thomas Gleixner's history.git, "[NET]: Add proc_dointvec_userhz_jiffies, use it for proper handling of neighbour sysctls."). As a minimal fix we can simply duplicate the corresponding check in do_proc_dointvec_conv(). Link: http://lkml.kernel.org/r/20190207123426.9202-3-zev@bewilderbeest.net Signed-off-by: Zev Weiss Cc: Brendan Higgins Cc: Iurii Zaikin Cc: Kees Cook Cc: Luis Chamberlain Cc: [2.6.2+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/sysctl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2153,7 +2153,16 @@ static int do_proc_dointvec_minmax_conv( { struct do_proc_dointvec_minmax_conv_param *param = data; if (write) { - int val = *negp ? -*lvalp : *lvalp; + int val; + if (*negp) { + if (*lvalp > (unsigned long) INT_MAX + 1) + return -EINVAL; + val = -*lvalp; + } else { + if (*lvalp > (unsigned long) INT_MAX) + return -EINVAL; + val = *lvalp; + } if ((param->min && *param->min > val) || (param->max && *param->max < val)) return -EINVAL;