From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 262BFC43381 for ; Fri, 22 Mar 2019 12:06:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E71CC21929 for ; Fri, 22 Mar 2019 12:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256416; bh=f+mK0DnmlOSjWm4ehSbcILLiamLvt1MyoPHeTPu9T3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=oHyCoQYk53jFxy2twCLbB1WGXAOmy0bJJkqt1MAQlLJSh5pWMwnFFGc96th5DavJR 5Vlpclvla6YSZwKqkh/NZPun2N+i3MzD7syXN2PzlE0HKiZvqf4vSGuk6bbY5Ehh+0 LcFDInE6LAi4XU0QqLRajHEP61FjR9jIU8Zt+C6E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388973AbfCVMGz (ORCPT ); Fri, 22 Mar 2019 08:06:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:45316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730757AbfCVMGw (ORCPT ); Fri, 22 Mar 2019 08:06:52 -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 58BAE206C0; Fri, 22 Mar 2019 12:06:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256411; bh=f+mK0DnmlOSjWm4ehSbcILLiamLvt1MyoPHeTPu9T3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GlZzXhER3gu3Tjmte5RywrcHGRdSz2Fnwcdqv352j4g7TwqLpAXk7pUKO8kl+26m1 y/hCo//Adxg7IC0ALGYNjaLMi0Da68Qprz+8T6H/HFWj9ialvMWMizr7/6lZtJiw77 4kgEKFSciRIFD1V7c3j+eMGJ173cV/j1DLizjQQs= 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 4.19 203/280] kernel/sysctl.c: add missing range check in do_proc_dointvec_minmax_conv Date: Fri, 22 Mar 2019 12:15:56 +0100 Message-Id: <20190322111331.159172398@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@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 4.19-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 @@ -2552,7 +2552,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;