Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3343267pxf; Mon, 15 Mar 2021 07:34:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzizFhlYzQwDDRUHlgZalFmH4XxuLD+TSLL1ZaBudm5N4mKtbhBGlLL2sMOP/4KnfFYBzpx X-Received: by 2002:a17:906:b14b:: with SMTP id bt11mr24720783ejb.162.1615818876175; Mon, 15 Mar 2021 07:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615818876; cv=none; d=google.com; s=arc-20160816; b=NZz2JE3N/9+EL5G6NWimJrUJ6+r54vFT7CvptwoTEUL+nlnIBCm0YULgnRKujJztiM L4YnSDWd0KIAcFbDkgSIKBtrFl4fsAJONbDEDpDP7nqhUwiLyITJC8ggaj5frYlK1i+U e0cm6zUr4WMOZ86KKuZiqOfjv+XYNuTIXjPxhyWZWcSWxjec5YQBNfIay+D+EyrduCnl N8XsQXI/Eo3y2yMNH2OfPF6kLMMgRyh4vNEjXrbUoCsFFckoXs/KRn2NNVrebM0y+4YY P3DSvyhLAcVYTzoHq0oD8k3gX0bpQP8eDRCxMsJV8adPymFw4HV1eTGKukFYktbx1R1X HrwA== 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=Ip2/pxYwHkBGJ7IaKikY6nhFJyTNZXw4DppsqrOPTdY=; b=fNrkgCos+nT1yz54XnSujpE+MPJCa0tVVD8Uz+PAqVdDnhBAJAQt4l/BeSTbLJE+F6 oE1JiE+WrkSnFXfJdzXE0AFb27ydyjRcxVqAYqBSr4SNpDUSkL6q6dtCHsI/eLojpfwW Uf/kqImNx3+sMvvyJ8ftwgTJ13ojtDLRRdkzTjwI/vghyQ0dayhv7YC2oFjX/8lyIGcI au4tVW6PIOc9Wy5u1hVde0E3AsiugTbOSney0zmktRQOCoJ/jU5DwNTq8fI/OWvuC9UA eQl67FkRSrEEy+1UgLwNfYYjIPltOoMK31/KgD6RHNaUVUf/H91M4b2KBkjdfPaLFtzA wgnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PMgXrgGE; 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 b68si12381316edf.477.2021.03.15.07.34.13; Mon, 15 Mar 2021 07:34:36 -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=PMgXrgGE; 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 S239511AbhCOOci (ORCPT + 99 others); Mon, 15 Mar 2021 10:32:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:36594 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233234AbhCOOBM (ORCPT ); Mon, 15 Mar 2021 10:01:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4800E64F43; Mon, 15 Mar 2021 14:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816847; bh=uM3Q+PZIupZOsbCw6xpRUJtr3CTQDwRMj31R5SrWZ0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PMgXrgGEm2gEw1ksmaBBMe45jLAqY7atvukPjSSghGNr6daWd8KsKwlcb55j4omM6 /pO3nsRbVfhSVyks+Af2Y/9RSSPNBY2WS5O1kS3yfw+Xk+r3Ksxa93i3ZilCg0XuPQ 4yulUdNf8a0P1pERf9USTysIZ09+zYW9RpEj0U0w= 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.11 159/306] sysctl.c: fix underflow value setting risk in vm_table Date: Mon, 15 Mar 2021 14:53:42 +0100 Message-Id: <20210315135513.009729925@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 c9fbdd848138..62fbd09b5dc1 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2962,7 +2962,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, }, { @@ -2970,7 +2970,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) || \ @@ -2980,7 +2980,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 @@ -2990,7 +2990,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