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=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 3BB6EC0650E for ; Mon, 1 Jul 2019 08:06:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1AB0320673 for ; Mon, 1 Jul 2019 08:06:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727723AbfGAIGl (ORCPT ); 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: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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. > > > . >