Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3519978pxf; Mon, 15 Mar 2021 11:22:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7bZBWNgkYHtxSJ/JKHBCnpNOKIiThtNn85aboVE2hyr0S2dgz+wN1qhEhzVC/Wko7rGfP X-Received: by 2002:a17:906:1494:: with SMTP id x20mr25154276ejc.101.1615832535675; Mon, 15 Mar 2021 11:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832535; cv=none; d=google.com; s=arc-20160816; b=xnZEoB5160MebmqTUcKcAibGtaq1d3nKYX07g03qP5vKnMoSce4+nOMRGzKFc6YWlh RXuQKAS7RjWiPnx+njZrAW/MvfNSPoVxfg9WosYPrGRx1yVTWqYPD0rImXE8YkUwFqiD sYYKr2y49r3pCGyaWLCagv0XfmfZmR3Wz6Hux1EZGAnG2FDcgmv4uE/PmzS9Q8ngfa3O DRKY24j62Hh5fUkNqyBgCnYZE0Z82x9TVAXdwjT96kRbAn3WRgnQfjjfwbO4PDqIez9J QcBGHfm2nZP1eKH4QXa/HwVLNaDmgfP53cxfA5p/Gd1EKmxUm0dtGNKKNyZqWUhSKUOk Iw/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XfSqOiJrJKTu2yw7QxYKl0+OoJmWyne+6lUqGwIFYdU=; b=hxcau+ZDxMjYQansAj50DH3Un1uh5+aQy0cByk8z4W4f7YA+8ItX3zkvlT3Qjzj0YR S0SHiVcTy3bCAA1YZ/XpTLkP3MqF41BbzPK4sERPOiPmv3SNCRB6pXRJwsJYg750ZCG8 tHCuFeGDX9Q2xftnqh01Yy4jnKDHqFjieefULFq/oIb1rniccZ0omqZQundN30xi6Hlp g7RLd1A8PwHDiZFSnU2I3RFZ+VWUxfFUrPZaVzLKWJ1lvJ3b0F2X9O+h8fospQouLul/ BOXwcvgHaoole9l/ROLJoxXvL3Fx1KGTv97KK4NJCy5CX6NUaeb9CrF1DcqJE0ynJAtZ k0Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cLlFVlpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si11325433ejk.520.2021.03.15.11.21.53; Mon, 15 Mar 2021 11:22:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cLlFVlpg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233682AbhCOOVZ (ORCPT + 99 others); Mon, 15 Mar 2021 10:21:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:37612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbhCON7d (ORCPT ); Mon, 15 Mar 2021 09:59:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4703264EE5; Mon, 15 Mar 2021 13:59:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816749; bh=pF/HBj5xKjySmeKrIbUM6hI8XEgojQkYIDMkItH5Ypo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cLlFVlpgZILIx2Sdn5FrCi1VMnheB85BbkwaBHpj7LMeUph4oSNYKQFZT3oCuBft2 sGqikglWcmcRscyLJ3kG3l5IgeY3X3qQ0tjwQiNcaPIBA3spLRiUKH454DE3ZNPveY CPYO8hpTcBeYT6wBYIohrH80RpM5Q4g6joFh7/Z8= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lin Feng , Alexey Dobriyan , "Eric W. Biederman" , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.4 084/168] sysctl.c: fix underflow value setting risk in vm_table Date: Mon, 15 Mar 2021 14:55:16 +0100 Message-Id: <20210315135553.146806730@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Lin Feng [ Upstream commit 3b3376f222e3ab58367d9dd405cafd09d5e37b7c ] Apart from subsystem specific .proc_handler handler, all ctl_tables with extra1 and extra2 members set should use proc_dointvec_minmax instead of proc_dointvec, or the limit set in extra* never work and potentially echo underflow values(negative numbers) is likely make system unstable. Especially vfs_cache_pressure and zone_reclaim_mode, -1 is apparently not a valid value, but we can set to them. And then kernel may crash. # echo -1 > /proc/sys/vm/vfs_cache_pressure Link: https://lkml.kernel.org/r/20201223105535.2875-1-linf@wangsu.com Signed-off-by: Lin Feng Cc: Alexey Dobriyan Cc: "Eric W. Biederman" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/sysctl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 70665934d53e..eae6a078619f 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1563,7 +1563,7 @@ static struct ctl_table vm_table[] = { .data = &block_dump, .maxlen = sizeof(block_dump), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, { @@ -1571,7 +1571,7 @@ static struct ctl_table vm_table[] = { .data = &sysctl_vfs_cache_pressure, .maxlen = sizeof(sysctl_vfs_cache_pressure), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ @@ -1581,7 +1581,7 @@ static struct ctl_table vm_table[] = { .data = &sysctl_legacy_va_layout, .maxlen = sizeof(sysctl_legacy_va_layout), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, #endif @@ -1591,7 +1591,7 @@ static struct ctl_table vm_table[] = { .data = &node_reclaim_mode, .maxlen = sizeof(node_reclaim_mode), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_minmax, .extra1 = SYSCTL_ZERO, }, { -- 2.30.1