Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5126103yba; Tue, 30 Apr 2019 09:31:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpmFOC5OkBx3ysAhNxy4UvbHsw4ib7JpaqRxGwROOEAfLcyXJh+5iOgKopl6RYiscvNx5N X-Received: by 2002:a62:27c2:: with SMTP id n185mr24146761pfn.51.1556641910593; Tue, 30 Apr 2019 09:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556641910; cv=none; d=google.com; s=arc-20160816; b=Yknv63dpwtj23KQ3q4cfYsGTQ8NRvun7+aXU7Khj3Bt0EU1KBVDnmoz1WbC1tedqRR sRDPUqHr2UqkJB944d4pSB60Ep2FqgTbkV+pKMo5Wpe3Ze6w5H7rg/ccwRXI3N6hszFi c3bGz2G1vXzC0Hgwetpy71P15vUO/0nCBcEpdDy881I18gY/yWYmU7qW3PUU+bLdfIbI /pXBNC28nzwWitSK8OMaO4lj5rhfbcw3fTvPEzZJC6eYnzoRR/LwZRhsGh6k3zY20ck/ rejJnAszQekghfvkRJG1eXNqyonlpmYM37sXjN7Pn21XR0LbScaWrMK5Lz9t55xXWKRx 9o7g== 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=YfLhavdIeR7HTTj2ugiDjMzdIxNt+XkZkSlpB23S0bo=; b=KyP3u4kDlnqt9rQArulntfWVI0hMDhgkWTKkRJzJnRrR2JiG7btbVyOAai/vCKn1UW IInanwGTM6RwpT7KfVag9PbnXkpjqsJfxWJnBxukaBlUXuXhgbSQCiqiiRQpiL/BZ/+L +ZNqg0gK4a1GcdXR0rU0pBJ9pnu2nCHZ5IX4q5YqWx9p8ikQGr5lm2x1RO7zfQEz9fJn CQfEwYkRN+qIvIAkvMIkcUDW3Vq8anklkYBRsuhrWf4RKnMkuakaC1R0svotGAaSf4YH O7eAlhuGU7GHp8PxR3esNxT8VifRicMpmt5FFmfPNEhESOAAxwr16g2ZnYbGdLBuhFPO R49g== 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 16si29881190pgu.152.2019.04.30.09.31.34; Tue, 30 Apr 2019 09:31:50 -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 S1726772AbfD3Qa3 (ORCPT + 99 others); Tue, 30 Apr 2019 12:30:29 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:35313 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbfD3Qa1 (ORCPT ); Tue, 30 Apr 2019 12:30:27 -0400 Received: by mail-lf1-f68.google.com with SMTP id j20so11390998lfh.2 for ; Tue, 30 Apr 2019 09:30:26 -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=YfLhavdIeR7HTTj2ugiDjMzdIxNt+XkZkSlpB23S0bo=; b=pk2jrSJCxibbTmfMLFbb4qZCmE1f20iXCJ0kzhoQzJql0mVYKc6zjDrY/mLf3WZVQr 8n9pb67a3GGHv1keIdx89fEVdIdG8kBNjOTo45MYRjiKYOF8Q/6UmQYpuQWtpA+BXf/4 HEkD2gPODQPrSR67r1rQMfwPaZ7Rdwe6EXQYo8mIJin9VNfmWwQfQOKM6K/Nj0+f9ptl wauijFvVXNOsNvNCUy3m+x5uany9kQR2H4D9NF8jEIqR8KgLYkrGGZ2ZtRuwqMMU4y2g 7M85VTs/QgfnLawQ+8OOqfrOdVNvJqbNcSP1fPj0SvuBTGjva4yiv4Yu8iWXS5o5/p4x 2kpQ== X-Gm-Message-State: APjAAAWh1pnZLxz77gB6OvHlhn6sM3ejZIBgo623vPLts3M7K3/YIgTk iPEMPhr5kjMihzCgcG0OkR3PNCzkrVwg/07Ct6Tb3w== X-Received: by 2002:a19:a417:: with SMTP id q23mr35897943lfc.110.1556641826091; Tue, 30 Apr 2019 09:30:26 -0700 (PDT) MIME-Version: 1.0 References: <20190429222613.13345-1-mcroce@redhat.com> <20190430160813.GI13796@bombadil.infradead.org> In-Reply-To: <20190430160813.GI13796@bombadil.infradead.org> From: Matteo Croce Date: Tue, 30 Apr 2019 18:29:49 +0200 Message-ID: Subject: Re: [PATCH v4] proc/sysctl: add shared variables for range check To: Matthew Wilcox Cc: Kees Cook , LKML , "linux-fsdevel@vger.kernel.org" , Andrew Morton 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 30, 2019 at 6:08 PM Matthew Wilcox wrote: > > 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); Indeed. I followed the same code path until I found this: 167 ipvs->drop_rate = 0; 168 ipvs->sysctl_drop_packet = 1; so I think that this can't be done like this. Mind if I send a v5 without the const qualifier? At least to know the kbuildbot opinion. Regards, -- Matteo Croce per aspera ad upstream