Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525175pxf; Mon, 15 Mar 2021 11:29:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyONUCz5D4WBYBoHeP9r1wy/3/mLh1ZwfUUv2LQl7hURNccO/uur81JMOgd08KJBN07fNCm X-Received: by 2002:a05:6402:22b5:: with SMTP id cx21mr31634085edb.27.1615832981728; Mon, 15 Mar 2021 11:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832981; cv=none; d=google.com; s=arc-20160816; b=LMKc9eMiDN0Z4uXI/kNMxyF2QUwzVVVLZAfVO72XoTUNsB7KTBMg1O1hy7oTbzF9Tq y87VbgXDDWrmoICk79fQPwII5g+KKgLAmkaflbjEQK5c24JlsBqCU3GCAna1xYr/NkX0 lubm0mJ14f9oWXe3EPCzzaMq6lKDqOrZah94o1rfHEbcePf9WZjkmx9/o2JxxyEYUdZk XRVA/YogwL0GSnYuki4Wcp+ozijGlRN3GETv0fd/IP9hsjzP2j7rhz4TqDqSxM58R03h ha7Rv6g0sXtEHnyiUmLsNNEh3zoGaKn1VuZb4Sx0Q8hm4xFiDzT4wSYBi9gG7uCPSesR j/tw== 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=VgkADaQYY4NcXKGJNPzZw9YK8YahkxXQ2t0hWHBwi8o=; b=WpS7MafJw2C69oypR4F7/mmtivGcpV003mwmlpRBD3E4vhcy9E/h/UdZLwlSvG2d6x J4Y0OQyUHw9XW8BQ6GxWib7sWcQGZHuIScEQC4V7P37wprANcCUe+iO6Wne6nc5P3opj 3Bd9EXAY/7GKPnOhe6OQDa3ZhgybjICOGnt1VOkGpP/1R6N6u3K9lNUvAuT8wWIqZPvP //4ZQ3tiNxStr9gj4UbLP3DnwrYIREyRUqexDBGjXohnOk/i4m4zbiblS+zY0kjPnCok 53f+iZXXXEDqwL9AV64koor5Bxr1zjHyBxYTt08H1am6UpcMNh3nSzmrNCr1YgBUMSs3 aeow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=L9MnKZMP; 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 u10si11791925edj.431.2021.03.15.11.29.14; Mon, 15 Mar 2021 11:29:41 -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=L9MnKZMP; 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 S234600AbhCOOeA (ORCPT + 99 others); Mon, 15 Mar 2021 10:34:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:35610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230180AbhCOOBj (ORCPT ); Mon, 15 Mar 2021 10:01:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BF79F61477; Mon, 15 Mar 2021 14:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816873; bh=OXFMUhrWsMLEq1QAp1RvKwdhzucqcA3BW3VJkhZVZ0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9MnKZMPaxv7rKkvNXL/Rx1/dUkCdZBKNVhnFYnf9ELCM59fk8LUJcaDhdKo4zeGU Fe+1YNif3LZqvBM7oNhcO/76IZcbOwEsEo9oTs9n6s/Wk56Wa4+9690QSCoGkLnTXz mGnVYHq6D1AitL9qUhEKpOGVBzbGqChqUXsy1VJ0= 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.10 162/290] sysctl.c: fix underflow value setting risk in vm_table Date: Mon, 15 Mar 2021 14:54:15 +0100 Message-Id: <20210315135547.381048508@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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 afad085960b8..b9306d2bb426 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2951,7 +2951,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, }, { @@ -2959,7 +2959,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) || \ @@ -2969,7 +2969,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 @@ -2979,7 +2979,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