Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1233726yba; Thu, 18 Apr 2019 18:08:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4+/dpThUL4uMOk3gYqt1zBhQIgW0ZKGDpQn3mXnBLh+13P0U9C74Sk8WkkPvViFpLX5kS X-Received: by 2002:a62:305:: with SMTP id 5mr868157pfd.65.1555636113124; Thu, 18 Apr 2019 18:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555636113; cv=none; d=google.com; s=arc-20160816; b=dLNcYJwSWQHj3kpw3tzGTNBzOEvC3rWKWX2ycofVuK2uuQaX5BdyNKRwkyDyrtUTki jfwZwrSIPPC8sP0KGC9iEkZ7fatGVicg3Snz/jl8nqC2X2mtRLe1e0npIiU7tzNDWl8n aT0J0M0vj/zSPHpf4H0iTVniDDwq3HVc6isUImDRxuWG01hYlxglkY7jfqUT7z5bDCgq kA9i0JlldFw0Iw9gPBtNWQ015wbVJXKTpTHo9uWijkyFhN3zv2m2DjQ4WZjyBEyZ28NA bxLPwRps03poK7bc9kYiHwPrEit/S1fevXYfXtlyFB0xgtiDo81YSUh+8fRnBIqhWYNi 9imA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=35diIJS73KQvDrRnDVHsGCCD+aQpo2DkYGTkvHNwcks=; b=SYvQftR0qHxtbYotuM0fJDPsLSYSjP/NrXd7Dx8iGuNyf0SyBeWmDrq5T5ZdppEmb2 jftRfYIOV4qiBxfMMqXTu7oXUhNnnfNNNVdP7+f50cQAQM/7GmKCoqDTRihZkQyoXxh5 zmAfFi+TMjizz6TxH5eCV/A3EfrkQu7ITU3+JYS/sEuR4bzRpU6tbm1r/zybHf6tDsMa K/e6VOU/MVVqNYKKTzVoueM0fy9lntVcl4z3Xv2naBve0zi93fmO+fAP6W31aCPQzIQ8 qSeebXP1OviO9P6A3GrpSunTKLnZm0vuXRoO0HuWP1dBs3Fy3M3qD0/pA2YX3FiDMcTi abcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=noNrtn3l; 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 b17si3628157pls.15.2019.04.18.18.08.17; Thu, 18 Apr 2019 18:08:33 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=noNrtn3l; 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 S1727159AbfDSBHQ (ORCPT + 99 others); Thu, 18 Apr 2019 21:07:16 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46810 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726063AbfDSBHP (ORCPT ); Thu, 18 Apr 2019 21:07:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=35diIJS73KQvDrRnDVHsGCCD+aQpo2DkYGTkvHNwcks=; b=noNrtn3lmSJKq6RLqjIMAiPu3 AhijGEwYtPqa1qnwcAhTihn0PKpcjata3vuw+0ZO5tC7AfFI6vf8EM+2kzf1t/AoVyuuB6iYVl19+ ou9sn9kCdUEPB473KOFAukioBAY5otnlL7YfteDsOGUCyiOfpzpmWHrnkFT1agzKEo+Bf8URBhGvc qvc5XgF/LbofWAR/LMkK/pf0dLTB7w53gIClNvrMOCapP0DlKbiRWfOnCJJJLEg5de44V9EWucJ29 d7ACqawnoLFVZjzF0w0SKiQ+kSG+ChfIcAuIm2gZdJw0MgZ6B/CMGogyCtmrIwbTpQ7NRZYilInbK 3H4Cxm8XA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hHHzm-0006YG-JW; Fri, 19 Apr 2019 01:07:14 +0000 Date: Thu, 18 Apr 2019 18:07:14 -0700 From: Matthew Wilcox To: Matteo Croce Cc: Andrew Morton , LKML , linux-fsdevel@vger.kernel.org, Kees Cook Subject: Re: [PATCH v3] proc/sysctl: add shared variables for range check Message-ID: <20190419010714.GH7751@bombadil.infradead.org> References: <20190417131531.9525-1-mcroce@redhat.com> <20190418154045.2ad0bd50e73a6e71c0fac768@linux-foundation.org> <1109DAD2-E25B-47A3-8381-E02260FE51B9@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1109DAD2-E25B-47A3-8381-E02260FE51B9@redhat.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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])