Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp283ybi; Thu, 30 May 2019 19:06:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqztGJtehuFhqbMqz4H2qfsmNod6dN9EgnrIbpWsnQfka/w9vpA3TO7aOt5cJK+bAlY33tZ8 X-Received: by 2002:a62:5486:: with SMTP id i128mr6855182pfb.156.1559268365241; Thu, 30 May 2019 19:06:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559268365; cv=none; d=google.com; s=arc-20160816; b=o4yuHTo/nDd237kfa5RBnJG2I5AD1jSEnTNNuzZldt/m0pYlC1K+UDPpNOMdenGGJF lHUrmC9nZZNr+E9Hk3BqwRen34JqWRzjUaXQXEuvMTgcinDXoCg2XeM3wpkiNtMrrjGW NHjkRmEPb3NOEaRD2L2sOCwlHIZmwMDFNT26V95ENtRRKZ3k0Tk/gogFKuAC8JJ5OyMj MsB/xZcCRqHTwGh31qxyHjNZw4hbY4sxBO06dcP/1CmOP581MHY3LCF0rfBiwRWshWJw 6rGi80uB9CLFqy/MazHGMfEc1dwGkZRgm0nlByyaY4f0rot1KIqJrEstQH1L6zJ/mG6M M03g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=TL52Gmz6SngGLbkmOVeJjIMB//nPEreA8+KZe6jZL2E=; b=b1JSFn6n95wJwPbYm+mi5+BYYm4opQxju6V6BDZApHw83dZxnLKw2UAuMhfQu5r3Z1 PgK2A75rJWPEYyS18VzanhlCymrMBfZA/6XOPi24nR+gYvMdkvAYeEOvLL6EhWST62X5 P9qPKib7rdkdmNinxhTsrqRQaUQbDdHJAEn8fS66Xq1/1hkeJqhHHKEv03Uq7tNcKu/I z02DQ5gUE8J0vF8gD4C0W8MbB998aMELLhNldtVxh5rrke4nhggitweHBOxOXkJLVZ/5 Qf/D92xVQyX8nu3fyP69m3gYBGSh2gOhaPn6XpKUzt2OlkhfNVY7Ib5z+Al/lugkN/Vj lL5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=m3wzQz5v; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si3118472plz.337.2019.05.30.19.05.49; Thu, 30 May 2019 19:06:05 -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=pass header.i=@chromium.org header.s=google header.b=m3wzQz5v; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbfEaCEi (ORCPT + 99 others); Thu, 30 May 2019 22:04:38 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:32887 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726372AbfEaCEh (ORCPT ); Thu, 30 May 2019 22:04:37 -0400 Received: by mail-pg1-f194.google.com with SMTP id h17so3105948pgv.0 for ; Thu, 30 May 2019 19:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TL52Gmz6SngGLbkmOVeJjIMB//nPEreA8+KZe6jZL2E=; b=m3wzQz5v9QbCfV14C68ip2i+UQ6JIrVLE0AyruLAuUG1goBSkvvyFwL+XF154+9ach G4OhLOuESbU3ejVGt5EJJoxx9Ojaej/rZLoFXVZwMjLEoSgsVnimom6v/ruCHKJyW8Hu vTiHn6WvJQPW2zALLs91xf81yx0UjHlG0u/yo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TL52Gmz6SngGLbkmOVeJjIMB//nPEreA8+KZe6jZL2E=; b=C5XLQ9qvKYWDkNXVW3IUiLsY1b9KaFeIdj3LO1wDBecZROM7ma7bXSaBT+btSzOATt bIc95s4HIB6V6g4kFXR6B8cgJGuVXiisWn3XOn7BoxdoI4qkn+kxBLWCq9SKKkjWD4zV ybcCOMJOxOi5Vv6sbh0VVmPXvbJapwaMlkLwF0wNQ++ZkhH7AtoZzw3s0nBNp0qZZ+gt Uo/QnShfCWk2W/MKNBxhRl6Cuj8qubrv5zpu1tJ685WOBCV+wa5vA84iBsMiCVdYKuXc Y3o51IRzsGbWYghrdDJSQG02HJJiwUY40NzdEW0hHpFLsg2YcgkYszvucjdvPKYKdliC giAw== X-Gm-Message-State: APjAAAW9ONpGA40tMs44ZuSPUbBpjTg9Ny/jb1pk8Z+/9XdInqNWFxhZ 5hRecmd40r/s3ssP8AHYUy6jag== X-Received: by 2002:a17:90a:c38a:: with SMTP id h10mr6436167pjt.124.1559268276841; Thu, 30 May 2019 19:04:36 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x18sm6485774pfj.17.2019.05.30.19.04.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 May 2019 19:04:35 -0700 (PDT) Date: Thu, 30 May 2019 19:04:34 -0700 From: Kees Cook To: Matteo Croce Cc: linux-kernel@vger.kernel.org, Andy Whitcroft , Joe Perches , Aaron Tomlin , Matthew Wilcox , Andrew Morton Subject: Re: [PATCH v2] checkpatch.pl: Warn on duplicate sysctl local variable Message-ID: <201905301904.D8D90210@keescook> References: <20190531011227.21181-1-mcroce@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531011227.21181-1-mcroce@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 31, 2019 at 03:12:27AM +0200, Matteo Croce wrote: > Commit 6a33853c5773 ("proc/sysctl: add shared variables for range check") > adds some shared const variables to be used instead of a local copy in > each source file. > Warn when a chunk duplicates one of these values in a ctl_table struct: > > $ scripts/checkpatch.pl 0001-test-commit.patch > WARNING: duplicated sysctl range checking value 'zero', consider using the shared one in include/linux/sysctl.h > #27: FILE: arch/arm/kernel/isa.c:48: > + .extra1 = &zero, > > WARNING: duplicated sysctl range checking value 'int_max', consider using the shared one in include/linux/sysctl.h > #28: FILE: arch/arm/kernel/isa.c:49: > + .extra2 = &int_max, > > total: 0 errors, 2 warnings, 14 lines checked > > Signed-off-by: Matteo Croce Reviewed-by: Kees Cook -Kees > --- > scripts/checkpatch.pl | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index 342c7c781ba5..629c31435487 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -6639,6 +6639,12 @@ sub process { > "unknown module license " . $extracted_string . "\n" . $herecurr); > } > } > + > +# check for sysctl duplicate constants > + if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max|max_int)\b/) { > + WARN("DUPLICATED_SYSCTL_CONST", > + "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr); > + } > } > > # If we have no input at all, then there is nothing to report on > -- > 2.21.0 > -- Kees Cook