Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5103492yba; Tue, 30 Apr 2019 09:11:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfdf976uYWgw9TgEe1IOVlQ2sJ4GTT+O+UGgrk+L8mtqXG2qVdKzSGV8+Jr9ALn5/VKzPx X-Received: by 2002:a17:902:9a07:: with SMTP id v7mr62674633plp.291.1556640663642; Tue, 30 Apr 2019 09:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556640663; cv=none; d=google.com; s=arc-20160816; b=gx17Hx/oSrx/S+H6UpG4EOM5ggQroJcRsbGNwuNTXIrlB2d6Iy71IXeRVLX0Wr5SVj R2h//oIOBpOL0OcNDWdHpeuYUmfSxYIOv73+LFhM36ic4lEV6v1HrQqWso8lVWMPxESj yy0S2bPrBulVujA4SDtaReLBmmuF0jYm5AkOyL97x0viXgyIthmBzZFPo2klu/NAdQDK ZQMCgXmTDbqtEUEDHoy17gbOeRnHUXeowV8qWgGCrDMeMEgVU5gsPm3cjirqTOZU3j3Z 2ipM0rZVMxb9L9amvfLMzwshYroUgeDHWhmTrN1MK6wuZdJ5DWqrOT8kyrKNmWuukoG9 QOQQ== 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=UeaqpmVaWKRnTEkoOf4sPrumE1te9gNrirP9M29Vlnk=; b=BANd2Y/oHTfs9ZEX59/6WGeuQsLnXST5AW3DcmAyu/XnDEdqBk2SJATRWlVbecGr7+ 0ATk/ubPIOX2QxdBr2OHarHjbFDdrYkBiyxqK+nYWTkLmlOu9sQ4216aBDPHr+NQ7xXm AlHfuT76InjAZDS+SWweSELzZa416DtxIdEu7p/D3P+/+fmTraR/YLhPbgIWyudziyGM rf/b2GomutDKZhBiYFpfwg8ml7sY+1TYDdh+DRbYdHQRTnktgGm9Jm1oB7looDx9biRE YVlvEFXG+MzS/DbdsyQO5DtzLSddAB+NCR7lT2LiTG2c0lH2IJeYUJ5ZbxDFrQzknLOr 4arg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=acL+Hmzg; 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 f1si13809689plr.326.2019.04.30.09.10.46; Tue, 30 Apr 2019 09:11:03 -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=acL+Hmzg; 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 S1726341AbfD3QIO (ORCPT + 99 others); Tue, 30 Apr 2019 12:08:14 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:53410 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725942AbfD3QIO (ORCPT ); Tue, 30 Apr 2019 12:08:14 -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=UeaqpmVaWKRnTEkoOf4sPrumE1te9gNrirP9M29Vlnk=; b=acL+HmzgOS/RDc0H5BSxtqC0q 7gQfOtw3uFwOz6N46aQM0TJonu85B90GlYiN5pr5toMYK9O0bIpM3TbnAjek2YYsoWAEJLo7JHNzD /Bk5/W0kzHDvw2lJJYaYdpXr1rkmAzx1ML+IwNOdURsxa9KaGwGLPbqbzk1gfyLuFgmbZjVVHRrzI JFSZ9A5cC/Pkx5etFko/ldRUnoKF1tE/XvmTulOgc0Q5GOv+7OUaVKSk9FWF1CBoiwUWmzGiWg54O 34sh7ewcz2tR6Ou6d8gYRSyCXASvJBBEAcJA+2uL6YBS+kx4d4+jdHihNPaJTxoD9AJ1zGMSAXBFZ AEyBiECcg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLVIj-0004M2-F5; Tue, 30 Apr 2019 16:08:13 +0000 Date: Tue, 30 Apr 2019 09:08:13 -0700 From: Matthew Wilcox To: Kees Cook Cc: Matteo Croce , LKML , "linux-fsdevel@vger.kernel.org" , Andrew Morton Subject: Re: [PATCH v4] proc/sysctl: add shared variables for range check Message-ID: <20190430160813.GI13796@bombadil.infradead.org> References: <20190429222613.13345-1-mcroce@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Apr 30, 2019 at 08:42:42AM -0700, Kees Cook wrote: > On Tue, Apr 30, 2019 at 3:47 AM Matteo Croce wrote: > > On Tue, Apr 30, 2019 at 12:26 AM Matteo Croce wrote: > > > > > > Add a const int array containing the most commonly used values, > > > some macros to refer more easily to the correct array member, > > > and use them instead of creating a local one for every object file. > > > > > > > Ok it seems that this simply can't be done, because there are at least > > two points where extra1,2 are set to a non const struct: > > in ip_vs_control_net_init_sysctl() it's assigned to struct netns_ipvs, > > while in mpls_dev_sysctl_register() it's assigned to a struct mpls_dev > > and a struct net. > > Why can't these be converted to const also? I don't see the pointer > changing anywhere. They're created in one place and never changed. That's not true; I thought the same thing, but you need to see how they're used in the functions they're called. proc_do_defense_mode(struct ctl_table *table, int write, struct netns_ipvs *ipvs = table->extra2; update_defense_level(ipvs); static void update_defense_level(struct netns_ipvs *ipvs) spin_lock(&ipvs->dropentry_lock);