Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3161329yba; Mon, 22 Apr 2019 21:41:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzt7rMroZKG5iDb3aWwYd6ETVR46bsL47ygpSwrkdhh5u9eMQrLLHTx6LmgK4aQfO4+2u4/ X-Received: by 2002:a17:902:7c01:: with SMTP id x1mr23466038pll.299.1555994481135; Mon, 22 Apr 2019 21:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555994481; cv=none; d=google.com; s=arc-20160816; b=tFJZfd0eh8TXRRY8ZX4IIgNhqsO70jAvinbnUPUfexp+5cXwpTdKtnQuXZFHHjglM1 jTMicJHuR8i1UH6Om9OLLelqy2G93fwHVweZG2fiOb/vtmQpl42Zk9ifjNlwfd/KZ1Qj g7/wdSnhmDhofZzlHI3m7GjDZzpZwBojo3JV5/KGjArIswBHce/y87Scd1BTqNfeA2qw BTglpXEyuMV4hFvTtbNu4H4N2kT0SURw82qdG4JofX1RS8fLwQjiawZ711GzbPIOFjGk RHtEV456NEuQwNiW5/X4sfqGYBBa54scWf/JvLHSwJjAWT07X1ayuUipj6ejwehoh/qq mJIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date; bh=bh4X/YE+BY26r4+IAh5lohzk/FjDOWWb9jVaS/qRt5I=; b=yegqr6l+DkPlMNbPW4obQXlcIwkXs2eA4SXFBkOS+ytcDj9TqI5ngMoRB1SctBcrYz Nl3nV08M7bI+vlXU35i7YySNmwOldc2VSTYozcpsU6SLJdOX+51WagxHmqgQ2uUtd+fA uwJzSmreL6knABDbn8l8GRrXC9Frg6iuijABRDNl8Bhek7AZqrGEc7V/RJVsjlmpyOyC LaF/TOienWY87X1/kq6CGDndjrPc5djxVmbeP68ruhnQjx66C7hrOQB0ao8An3LlCwbq 27FgcD9wNFSZ3sCS6QeJNQF8oBd/b1rxKznrAUm76yEqRvWjLEJfDfqCgR/w1fxVO3VI Vorw== 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 h189si15357940pfc.283.2019.04.22.21.41.06; Mon, 22 Apr 2019 21:41:21 -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 S1729838AbfDWD2d convert rfc822-to-8bit (ORCPT + 99 others); Mon, 22 Apr 2019 23:28:33 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46417 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729097AbfDWD2d (ORCPT ); Mon, 22 Apr 2019 23:28:33 -0400 Received: by mail-pf1-f193.google.com with SMTP id 9so6689629pfj.13 for ; Mon, 22 Apr 2019 20:28:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:cc:from :message-id; bh=D7x2hfvF8OYrm3/iMsirn8coi5z0CjuR9MVDpzeUWlI=; b=R57nsfJhJSNRlLYF8fQkgqHEPP3rLO+rUn9BVpTc6UGXWZAiSolFZAiIUazzT8uKNr la6xY+I/hu9gFHgGkxg874/XzyH4Uy4C0blPckkoq5VhS7062N8s2PuyMmXHohbYis4X Ft3fp3GQNIyqaee9OPwFOePYYlF5jHCM4EvD6+CNzZndyPxXJggeIWP+aDet0kbKlWOW 12/uu006qVBRW8LNR6N2LcXaNIh3sLr2zBUSu6Dw/goscyfpwJjM5tdXtm7UF1+xvNfR zgNqzrOdr00N7ci2d3vAmyLT0z9aB9tnm+cBMV+jBDr7UQOnTN5pqrkwzzc2dRMmzQ0J f7Jw== X-Gm-Message-State: APjAAAWav9rcpnsmmVHEbD5P0LkjhClK7Z8JcTly+WbaDdZyxMa9Ey85 dkWn5MGMf84vAGNkObmTVawrgQ== X-Received: by 2002:a62:e418:: with SMTP id r24mr24731573pfh.52.1555990112093; Mon, 22 Apr 2019 20:28:32 -0700 (PDT) Received: from ?IPv6:2001:240:240e:4025:456d:3cd:582e:ae26? ([2001:240:240e:4025:456d:3cd:582e:ae26]) by smtp.gmail.com with ESMTPSA id y3sm17410608pge.7.2019.04.22.20.28.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Apr 2019 20:28:31 -0700 (PDT) Date: Tue, 23 Apr 2019 12:28:16 +0900 User-Agent: K-9 Mail for Android In-Reply-To: <20190419010714.GH7751@bombadil.infradead.org> References: <20190417131531.9525-1-mcroce@redhat.com> <20190418154045.2ad0bd50e73a6e71c0fac768@linux-foundation.org> <1109DAD2-E25B-47A3-8381-E02260FE51B9@redhat.com> <20190419010714.GH7751@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH v3] proc/sysctl: add shared variables for range check To: Matthew Wilcox CC: Andrew Morton , LKML , linux-fsdevel@vger.kernel.org, Kees Cook From: Matteo Croce Message-ID: <5C263FB9-DC10-4D51-B6E4-776ED03C0E9E@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, -- Matteo Croce per aspera ad upstream