Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp312308ybk; Fri, 15 May 2020 01:08:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgOtTCutaI2i+RMBKM/CFP+kynEKkrRnMqnMPzOPIPz8lKLiaIuKoyFyE5EiwrAycQgn23 X-Received: by 2002:a50:eb8e:: with SMTP id y14mr1654188edr.270.1589530100182; Fri, 15 May 2020 01:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589530100; cv=none; d=google.com; s=arc-20160816; b=PDqSJu1ya6qHxpKzXDVsU1V7CBKFl/eDAnAG02CfnjmscZ7w9RvFmzB6fxscnqyfij sBUCKEl+Ltq9v9PDCEoHf4k+U2P5YnjsupSg4qyGyLGV83fXeLWSDrHF5BcfjedQwnTG yPiU8SpwiYTNFxHNimWy1WSoDSwicL1E/tMiBci99yKrEmt0wUQFvKq5qM7Ros2yFOBp 1Wrk2CWq9ovxaP2/k3nDHIjMtc/YPc9i3/Xt72d5wwdxy+BZU6Vz238E8m3BNS1KrDgz ekafj36SnKAjlz8qLQVkud0hODRu8DAXhR3h6JZniOpDlg7pwwEE3yJblTZZ2eqXbvsA 1dXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=jG2zPlUjuy3TaHmBjzz54CmTcwOEHnFNJYuMRLsgt3o=; b=yvTUqM9YTEWF0I8f3MBBdk4KchlmED8VErgnp4reyIgRTKjb8hun1yPbLgek+mivYd ZsmTzOj+IaPTSJ3X0V+Lz3hWEP7MhAd192OvjZnlpfBVl5YdMYVgEx3O+P2Tx0kTMkQu SGV61/gh/63/En/DSWJtE75AHABdYuZ9NWLZcSvZwUrMDcl3+nkF5OI+KAKUdTJze0BT M/sKf4BFLrRiYBdxqSznkT7RDrbu3KcgZxxzOmroMfD8d2AmP5/4ycX9yKmmBs8PDrLg mofPcG4FISWNp+immFTqXogQRUFQoptbCR/Ev/aTQMO4sSVggj/Qn0sAdU4ApAYMAnY/ 28Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DUoew+YP; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dv25si740694ejb.270.2020.05.15.01.07.56; Fri, 15 May 2020 01:08:20 -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=@chromium.org header.s=google header.b=DUoew+YP; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727844AbgEOIGa (ORCPT + 99 others); Fri, 15 May 2020 04:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726708AbgEOIG3 (ORCPT ); Fri, 15 May 2020 04:06:29 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3748C061A0C for ; Fri, 15 May 2020 01:06:29 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id f15so619435plr.3 for ; Fri, 15 May 2020 01:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jG2zPlUjuy3TaHmBjzz54CmTcwOEHnFNJYuMRLsgt3o=; b=DUoew+YPlBJlFGhJMGcpvILcRmegBRmwn4SG3fljK7KRjGVaf+NbqI92muMsHhxSzd uoD3o+TE+gzuBuLRMXyeGXGh/xmzjhB0YkePh8Qst7glNg/dJ9vLFvlTK+c+5GA2/Kb1 YMiG3vnsDsll6LQA876jclVWLpEEl50gQNWrc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jG2zPlUjuy3TaHmBjzz54CmTcwOEHnFNJYuMRLsgt3o=; b=kh/c6vOIRYUUJ50gTyGlgXcXElIqTRkfFlJMJLKf7VFXVgeUlnll0xU2tF7MTl74lg jmpSbcKrFpBjh4Cm0ufv72Xx042CXdpOdgMLV9VavMTzGl23v4acDEZulWRaRDOd82G0 hc15FxRyUyfzKf/10e2D6/OLD4JkcUvq8Ihq3HEKTJ87F+S1pufSb5l1YrE4D5Xy6DKm HSZoRV+v3QU5sDIAvo+7APSazTYvdEWLajgMjdKFv2o3l0aL2AHGPkdrxfjVTMngnVmk 3z+pYVKon/QsXf/pVXu+0DwfqltMuW/Ay3WCEbzzS8uKD+/S9kkVVVFA2fLuWYRwJSmB g2AQ== X-Gm-Message-State: AOAM5320Km+uRuxxPENzKPms284e2HRK1kW3nJV/qeFEp3dCfbBaCkQD zLrTwTuz00uh+VaBTzNJheEE0A== X-Received: by 2002:a17:902:6b4a:: with SMTP id g10mr2398745plt.141.1589529989396; Fri, 15 May 2020 01:06:29 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id e11sm1105913pgs.41.2020.05.15.01.06.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 01:06:28 -0700 (PDT) Date: Fri, 15 May 2020 01:06:27 -0700 From: Kees Cook To: Xiaoming Ni Cc: mcgrof@kernel.org, yzaikin@google.com, adobriyan@gmail.com, mingo@kernel.org, peterz@infradead.org, akpm@linux-foundation.org, yamada.masahiro@socionext.com, bauerman@linux.ibm.com, gregkh@linuxfoundation.org, skhan@linuxfoundation.org, dvyukov@google.com, svens@stackframe.org, joel@joelfernandes.org, tglx@linutronix.de, Jisheng.Zhang@synaptics.com, pmladek@suse.com, bigeasy@linutronix.de, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, wangle6@huawei.com Subject: Re: [PATCH 2/4] proc/sysctl: add shared variables -1 Message-ID: <202005150105.33CAEEA6C5@keescook> References: <1589517224-123928-1-git-send-email-nixiaoming@huawei.com> <1589517224-123928-3-git-send-email-nixiaoming@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1589517224-123928-3-git-send-email-nixiaoming@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 12:33:42PM +0800, Xiaoming Ni wrote: > Add the shared variable SYSCTL_NEG_ONE to replace the variable neg_one > used in both sysctl_writes_strict and hung_task_warnings. > > Signed-off-by: Xiaoming Ni > --- > fs/proc/proc_sysctl.c | 2 +- > include/linux/sysctl.h | 1 + > kernel/hung_task_sysctl.c | 3 +-- > kernel/sysctl.c | 3 +-- How about doing this refactoring in advance of the extraction patch? > 4 files changed, 4 insertions(+), 5 deletions(-) > > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c > index b6f5d45..acae1fa 100644 > --- a/fs/proc/proc_sysctl.c > +++ b/fs/proc/proc_sysctl.c > @@ -23,7 +23,7 @@ > static const struct inode_operations proc_sys_dir_operations; > > /* shared constants to be used in various sysctls */ > -const int sysctl_vals[] = { 0, 1, INT_MAX }; > +const int sysctl_vals[] = { 0, 1, INT_MAX, -1 }; > EXPORT_SYMBOL(sysctl_vals); > > /* Support for permanently empty directories */ > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h > index 02fa844..6d741d6 100644 > --- a/include/linux/sysctl.h > +++ b/include/linux/sysctl.h > @@ -41,6 +41,7 @@ > #define SYSCTL_ZERO ((void *)&sysctl_vals[0]) > #define SYSCTL_ONE ((void *)&sysctl_vals[1]) > #define SYSCTL_INT_MAX ((void *)&sysctl_vals[2]) > +#define SYSCTL_NEG_ONE ((void *)&sysctl_vals[3]) Nit: let's keep these value-ordered? i.e. -1, 0, 1, INT_MAX. -- Kees Cook