Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4190081yba; Mon, 29 Apr 2019 15:25:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzIB64YUdRssCTkmRTYgLXnpw4N6pJMkH2M72pgy7At5AK8V1HDm2r+amTtzJP8YVditJWU X-Received: by 2002:a62:6490:: with SMTP id y138mr67336921pfb.230.1556576731894; Mon, 29 Apr 2019 15:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556576731; cv=none; d=google.com; s=arc-20160816; b=cJDBAxmz613BBmCvFrVggEOo9lJFU4cIHozivG/6T6HqmmaHi/YUz9t6WrKTRll3ce HBMNQxBg37VHFkOoZLd0d1hzdR2On3sI+iXS2A1ROaHpEJE8LOxY13X19DbIsB2bwitp xrpa3rS9N0cR1pWery8MF7CKPwYPtkJ2QTDypmxBGNmmPVzfgQ0eaN3dDoHxehBnC+Qk S7zoICVxAMTkh+mydGkLCrP1EK0x3kQHdENe7flj6kYFcLIqLO2Pj84+1clqi+KvEKEh cEErEOisNxvmky1MsaNtOSemONMMUUF9sNwFm1EBMmkqVvrWUlCPs2DsxtdAnlA74QDq awEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=5qP8LPIS9WDXF+q33OLMR6KRblHE0TT1uumAzaN6KT0=; b=hFcCYyb4XcIACd9yywNvzky/JEmjeZu65If+jlAZlKWdYlFDGzbGfay0XLz0x+awzH Lxa3sCEcjo744hP//F9BZBjWGJQMqsqJ1VY1wTlzo2kc+O2VAfBXxwnMMCeSwTPQpfXg VQE4HhytjPRmZFqLPrcTq/MXKCvk7Duzq2qswngQHUYDycfwf3NcE8senjLWXww1t6CT fuxvtGxPVh7jyvNcx30hqo719t/4bxEs4hwYiRfNyoPSULOJIsLEfX3/YP8c+SCROqJU uyJOI0kwK95ouI6LqQWsAFhYIrJ0Ue53LJ2uMHNuItMUqkU4+PdnLXuqG2/yyOylacls k7ug== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u5si27342189pgc.472.2019.04.29.15.25.15; Mon, 29 Apr 2019 15:25:31 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729645AbfD2WWZ (ORCPT + 99 others); Mon, 29 Apr 2019 18:22:25 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33259 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728105AbfD2WWZ (ORCPT ); Mon, 29 Apr 2019 18:22:25 -0400 Received: by mail-lj1-f193.google.com with SMTP id f23so10932259ljc.0 for ; Mon, 29 Apr 2019 15:22:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5qP8LPIS9WDXF+q33OLMR6KRblHE0TT1uumAzaN6KT0=; b=QKFSL/deTMOIdpGPkhEC6Sa5Tc3PDmxJ1ztlOZroRrlxBmc2bIh8FOBhFGZD+ByhKJ Wg+JVpJY0LLKBw/nuzqrRWp9pAp1p4ueIwRuq6HIY1374mAUaxvBASYaK1Suza6O4gAy t+hZlhJfCEaHwtbVNJRdUJ3CUn2MVhqRtfanVlx8y7lSYG0906FEfFJrRLGoIQjM1yJ5 mkk6jsKk+h5zs+rswQZTMycT5q/fK8dqe1z7ifdfad9FiuI1EfPyfSJH/P4t34ZrSWy0 wSdHAtChFnAKaeIrYFtIlvozFZOVVxHhjEZ4FGN3TSxuDkxxWsyjJYITl1WP29UkRBUB F2DQ== X-Gm-Message-State: APjAAAWYUCd+L26f3lgAhpp5Lvd79fE1IkrSAdcJu4ew0PDN/n8esdtg ya2wjdKtLUfICeQo898xXfs9ZI1OT1BOSK5ilxUlKqKY X-Received: by 2002:a2e:8884:: with SMTP id k4mr10439134lji.138.1556576543331; Mon, 29 Apr 2019 15:22:23 -0700 (PDT) MIME-Version: 1.0 References: <20190417131531.9525-1-mcroce@redhat.com> <20190418154045.2ad0bd50e73a6e71c0fac768@linux-foundation.org> <1109DAD2-E25B-47A3-8381-E02260FE51B9@redhat.com> <20190419010714.GH7751@bombadil.infradead.org> <5C263FB9-DC10-4D51-B6E4-776ED03C0E9E@redhat.com> In-Reply-To: <5C263FB9-DC10-4D51-B6E4-776ED03C0E9E@redhat.com> From: Matteo Croce Date: Tue, 30 Apr 2019 00:21:47 +0200 Message-ID: Subject: Re: [PATCH v3] proc/sysctl: add shared variables for range check To: Matthew Wilcox , Andrew Morton Cc: LKML , linux-fsdevel@vger.kernel.org, Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 23, 2019 at 5:28 AM Matteo Croce wrote: > > On April 19, 2019 10:07:14 AM GMT+09:00, Matthew Wilcox wrote: > > On Fri, Apr 19, 2019 at 09:17:17AM +0900, Matteo Croce wrote: > > > > extern const int sysctl_zero; > > > > /* comment goes here */ > > > > #define SYSCTL_ZERO ((void *)&sysctl_zero) > > > > > > > > and then use SYSCTL_ZERO everywhere. That centralizes the > > ugliness > > > > and > > > > makes it easier to switch over if/when extra1&2 are constified. > > > > > > > > But it's all a bit sad and lame :( > > > > > > No, we didn't decide yet. I need to check for all extra1,2 > > assignment. Not an impossible task, anyway. > > > > > > I agree that the casts are ugly. Your suggested macro moves the > > ugliness in a single point, which is good. Or maybe we can do a single > > macro like: > > > > > > #define SYSCTL_VAL(x) ((void *)&sysctl_##x) > > > > > > to avoid defining one for every value. And when we decide that > > everything can be const, we just update the macro. > > > > If we're going to do that, we can save two EXPORTs and do: > > > > const int sysctl_vals[] = { 0, 1, -1 }; > > EXPORT_SYMBOL(sysctl_vals); > > > > #define SYSCTL_ZERO ((void *)&sysctl_vals[0]) > > Hi Matthew, > > I like this approach, regardless of the const or not const extra1. > > I'll be AFK for a few days, then I will investigate if extra1,2 can be made const and then prepare a v4 with the single export. Hi all, I turned extra{1,2) to const and I see no issues. I'm sending a v4 with extra{1,2} const, a single export for all vars as suggested by Matthew, and the define suggested by Andrew. Comments are welcome as usual. Regards, -- Matteo Croce per aspera ad upstream