Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1852495ybi; Mon, 1 Jul 2019 01:25:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVOJfIP5oceS+RmRx/SNdOysWZjQ1N1rKxqSWPsMh2UMuNdKS4xyJaAPIMvKNKO5M3Elkr X-Received: by 2002:a17:90a:f491:: with SMTP id bx17mr13694264pjb.118.1561969556620; Mon, 01 Jul 2019 01:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561969556; cv=none; d=google.com; s=arc-20160816; b=QharZ4BnkfnT1NUWmTGsQiciYUgxNdd30tpfcfiBLIxvgnwv8HSfzKpV6wYw4iaOOY X5mHmp1nZrMfgxHeaGr32u6ByGbJ5X3g228g+xgkyruAxsq9JJjZMEk99XlgJnpMbIkz CtTB6L6nrgH4ma7NzXOSuPZtyG7jn7RH6uFAQAbMF4tFlGIhUfobTuGd8E/xnRb8bvJr lZXONnx5ia/PCSk7f9IrrnsAuFazvrhK5/F5ss3qQWuMxCdbq0nJ4WsiYDrMR/xW76dl p5U2O7xamNb89wYgeDgKfb4AOr6ZRKRmaQEh6x28126H94Bm4OpXQHXV8u3LvFEFH2hw uiAw== 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:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject; bh=i5yF/OSALT4E5ukrdzQtdBsoy6M9LA0/0CVRhwZpp4k=; b=zu0v609DqjS1numR8O35h/CeF0HsTkWK+X/LYv5JakwxkNSj63acOfhuQg59SHBC3c MKQ53fbjjucH56WYqSM64N0Se8SZ+wnRpEUkOhBnO1/zebRiYzH78t4OVsPXH8FFcKF5 NF/yW8RzWhIAIs/qwKDFKC7xQ6uoz8FEhlvS5knGuI7cQZ9+Oi2PPL4TAhOAmy+TbJo0 XUDXFqbBg/pq01oggJeOz96lVEJqDwz5By1mmmQ/mQK8ZwOlCkjWwl7V9SHhjY18ptDy u6eGvfzjLo5K+KF4ayeV+wT7B0/t/h2ZgNAAv6016oLQ/Lj7p3Hrxg3P065hnPv9G2ux gMJA== ARC-Authentication-Results: i=1; mx.google.com; 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 c15si10088830pfr.73.2019.07.01.01.25.41; Mon, 01 Jul 2019 01:25:56 -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; 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 S1727733AbfGAIGl (ORCPT + 99 others); Mon, 1 Jul 2019 04:06:41 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:41782 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727080AbfGAIGk (ORCPT ); Mon, 1 Jul 2019 04:06:40 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2F55DB8DA46031B0CC6B; Mon, 1 Jul 2019 16:06:37 +0800 (CST) Received: from [127.0.0.1] (10.184.225.177) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.439.0; Mon, 1 Jul 2019 16:06:29 +0800 Subject: Re: [PATCH next] sysctl: add proc_dointvec_jiffies_minmax to limit the min/max write value From: Zhiqiang Liu To: Kees Cook , CC: , , , , , , , , , "Zhoukang (A)" , References: <032e024f-2b1b-a980-1b53-d903bc8db297@huawei.com> <3e421384-a9cb-e534-3370-953c56883516@huawei.com> <201905150945.C9D1F811F@keescook> Message-ID: <20d5857e-de44-4f02-5465-7febc57f0a20@huawei.com> Date: Mon, 1 Jul 2019 16:06:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.184.225.177] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org friendly ping ... On 2019/6/4 23:27, Zhiqiang Liu wrote: >> On Wed, May 15, 2019 at 10:53:55PM +0800, Zhiqiang Liu wrote: >> >> (Please include akpm on CC for next versions of this, as he's likely >> the person to take this patch.) > Thanks for your advice. And sorry to reply you so late. > >>>>> In proc_dointvec_jiffies func, the write value is only checked >>>>> whether it is larger than INT_MAX. If the write value is less >>>>> than zero, it can also be successfully writen in the data. >> >> This appears to be "be design", but I see many "unsigned int" users >> that might be tricked into giant values... (for example, see >> net/netfilter/nf_conntrack_standalone.c) >> >> Should proc_dointvec_jiffies() just be fixed to disallow negative values >> entirely? Looking at the implementation, it seems to be very intentional >> about accepting negative values. >> >> However, when I looked through a handful of proc_dointvec_jiffies() >> users, it looks like they're all expecting a positive value. Many in the >> networking subsystem are, in fact, writing to unsigned long variables, >> as I mentioned. >> > I totally agree with you. And I also cannot find an scenario that expects > negative values. Consideing the "negative" scenario may be exist, I add the > proc_dointvec_jiffies_minmax like proc_dointvec_minmax. > >> Are there real-world cases of wanting to set a negative jiffie value >> via proc_dointvec_jiffies()? > Until now, I do not find such cases. > >>>>> >>>>> Here, we add a new func, proc_dointvec_jiffies_minmax, to limit the >>>>> min/max write value, which is similar to the proc_dointvec_minmax func. >>>>> >> >> If proc_dointvec_jiffies() can't just be fixed, where will the new >> function get used? It seems all the "unsigned int" users could benefit. >> > I tend to add the proc_dointvec_jiffies_minmax func to provide more choices and > not change the previous use of proc_dointvec_jiffies func. > > Thanks for your reply again. > > > . >