Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp657551yba; Thu, 18 Apr 2019 07:31:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGOS5EsmShBr630Cd0QYVfgdojsV20payZzKcqiY8Lb0pDP5HzJtJWASnyjOLHgEq/0zNS X-Received: by 2002:aa7:8b08:: with SMTP id f8mr94950359pfd.146.1555597901559; Thu, 18 Apr 2019 07:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555597901; cv=none; d=google.com; s=arc-20160816; b=SgmbJ3Ay+tW1SulQLd/qLqgLIgOrCk0tuGI0FVhJ+YVFNgMG2BlWTu/4GupikgERxH 4WJEUPHHKF9mFTM3t8cJT9xdJHwkrxBbFHeaz+CPPSBE8OQMYX9Ittv7C4EWlDKljsho VOgOB3V5dYTJ6EfbpF+KGtDvW6fUsBUnrxduVXNXLopdQKTeeZFotaNoyeUXM1CS82tS zbRNWcCA4LAGRh4rXhf3Ee/xS4nq4MjYowH6MD3/9CipQhgmr3QPqMTDVM/rr+sSewSs IAZMFk824t4qBmbIpokzkUVMTBvPnLjKxDwwq5xrF51dc/8q8KStbBTQmy3/BDzAtjQK fWkA== 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=TOim+RvcEJbfbsP7H/7gIz1+X3BL6hy1WaOS2FPi6JE=; b=KbRoOntLsRTGgg3TsKHf1V9o1c2A0in9Uikge6bjFm+DDd40BI2vsEazjwhgov0CO9 ton3/W8E1qbvCSnjzliUPgjjumWuc/LvUSA2BWYc8Pjukjhozs39uIaRaTf+Qe04GqSA 7mjfm46e0TYY8Sc+mA0EHNp7xYE0HjiAQECR/uAkF21mTCaHhTQAMFLKdygIwgmCD08W vetG5l6QxfB8XFPD+l+WEKJYdCERBT1vaGFYWi94d89h81v7TUgG7HkpCZwGYcMFArSk muIXqlMe1CzJlWG+GYtEYx7nv3lQt+8BrVaToUM8i5iknPfGQEhl4eQJxRO/KhW/i6ZV bpXQ== 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 l11si2192970pgg.554.2019.04.18.07.31.24; Thu, 18 Apr 2019 07:31:41 -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 S2389390AbfDRO2T convert rfc822-to-8bit (ORCPT + 99 others); Thu, 18 Apr 2019 10:28:19 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43178 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389258AbfDRO2T (ORCPT ); Thu, 18 Apr 2019 10:28:19 -0400 Received: by mail-pl1-f195.google.com with SMTP id n8so1247670plp.10 for ; Thu, 18 Apr 2019 07:28:18 -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=iY11L4FnZ0bdBG/SRDQrmyEHylklCDemsvSEJjdMFaM=; b=fTF8ijNjxWm+8EtHoxm4yA+NIHZgZJYzhMfg8X2U+Dfgw/8d5OJ0wxZg8KtjNjl1xR aAKUhoM73jILEIFjXseENyoAa+qUDEmxyJEf1oqrkhr5nRlEDRMdqhs6ERzcLTVJXhqa os35Gc6UERJEtGyGKxMSikfcME03Vegq13cU/l94RjYOY5ntxbr2nsPC7B5d6J1YNU4y CGENQAI/Zf0zBhTIsVUT2/jYcCvVhWK9aroiR774m25XtARcVbqLNl3FtuO4bqKKAW/A 3SuuuKXKtraxXFGHzfCVgwB+GLMaw4ndFQZffxAKuSCFhMFDpcD86m7PzNkmsqzY9Rba MbBw== X-Gm-Message-State: APjAAAX+D9Wd75nFMJ+fEcjjkDSu/cb7Z7LRKrjH12NcHlDwDhyQIgxv Yz85/YUZ1lNKsgIyCy3sSO09XA== X-Received: by 2002:a17:902:24a2:: with SMTP id w31mr63133354pla.78.1555597698567; Thu, 18 Apr 2019 07:28:18 -0700 (PDT) Received: from [10.99.178.44] (p3300202-ipngn21401hodogaya.kanagawa.ocn.ne.jp. [153.129.48.202]) by smtp.gmail.com with ESMTPSA id r145sm6290213pgr.84.2019.04.18.07.28.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 07:28:17 -0700 (PDT) Date: Thu, 18 Apr 2019 23:28:10 +0900 User-Agent: K-9 Mail for Android In-Reply-To: <20190417154900.GD7751@bombadil.infradead.org> References: <20190417131531.9525-1-mcroce@redhat.com> <20190417154900.GD7751@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: LKML , linux-fsdevel@vger.kernel.org, Kees Cook , Andrew Morton From: Matteo Croce Message-ID: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On April 18, 2019 12:49:00 AM GMT+09:00, Matthew Wilcox wrote: > On Wed, Apr 17, 2019 at 03:15:31PM +0200, Matteo Croce wrote: > > In the sysctl code the proc_dointvec_minmax() function is often used > to > > validate the user supplied value between an allowed range. This > function > > uses the extra1 and extra2 members from struct ctl_table as minimum > and > > maximum allowed value. > > > > On sysctl handler declaration, in every source file there are some > readonly > > variables containing just an integer which address is assigned to > the > > extra1 and extra2 members, so the sysctl range is enforced. > > > > The special values 0, 1 and INT_MAX are very often used as range > boundary, > > leading duplication of variables like zero=0, one=1, int_max=INT_MAX > in > > different source files: > > > > $ git grep -E '\.extra[12].*&(zero|one|int_max)\b' |wc -l > > 245 > > > > This patch adds three const variables for the most commonly used > values, > > and use them instead of creating a local one for every object file. > > Does this actually cause the kernel size to shrink? EXPORT_SYMBOL > isn't > free, you know. Hi Matthew, In this case we have three __kstrtab_ symbols of size 11,12 and 15, and a bunch of u32 removed, so the size should shrink anyway. I will try to calculate the exact saving with bloat-o-meter. Regards, -- Matteo Croce per aspera ad upstream