Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1892234rwb; Fri, 5 Aug 2022 09:25:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nKCqTW9cq8ge3Nfiq7ONAqhb6jUAwwPmXquMsnk9+8VTpKb7twJDi6TQMbMQ3ACD6KgQi X-Received: by 2002:a63:5f86:0:b0:41c:f1:f494 with SMTP id t128-20020a635f86000000b0041c00f1f494mr6529333pgb.51.1659716730834; Fri, 05 Aug 2022 09:25:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659716730; cv=none; d=google.com; s=arc-20160816; b=OAeEx/+fLvPe61F8FkDjRw7rn9OcPrLkoGZPmln7YGFyzGipNUkBuqbR+STTWhpw5t OeQVAgGvz4PxL9J9a/Nybu1rdKSiElNab78WgZJSyKPFLzTx3l9Mn2KwmFyrW8EVgRv+ afscfN38FezApVl5b40NmoUYRAkRlMerGHLv9dcsnDN8FIttg/gOzUqZdCk5Sq5Ku5eZ rOkwLhtTzCO0J999+hFCsamPNobrvOonPdZLQwS2YmOmpRPv7Ft3tWa8Vb89brIDm1qB fNfmvIgxz2r4mUvbHBIb4DzbgA34uQ/2T1mPm6tI04UlIyo/+2GzhdUh54sXJLSz7A2b 1EKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fi2mBpBnzYP0nzrVm1pckCkz8K7UmwSh9Hl3WHMusU4=; b=kugJt9f3CHUnF8UgSmmhRTgKgUqqHvgFduUGznyhFMRurSsNVm2QWBTA/YdN2bwISl 4TNMBL/+OY+YS/G5SEjy4fOiO0ANs4MubYLmCAdnCezsbkFZdDLGFRaE4sYGeilkSfyE d27aY0STZCo5MDZrewC9Xz+GgVOb7iBVeOMnhupPNS1jbTPmL4AtaL65COSStmJ85g4+ mGTgGdkR0Q4GHa/QSjjpQu43qo0g5RCSUyfrhdFgkgC+lWcnrOo7TVDu9dadgT0EPElb e3zUGhUIL13E7IJXK80wkuqeuY2kAcJ7EeHGoRE11fb7PhPr4nG7JJvjb963I5EGDolO aE8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VXW1GvZf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a056a0002c500b0052dc6d9042csi4139386pft.356.2022.08.05.09.25.15; Fri, 05 Aug 2022 09:25:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VXW1GvZf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241222AbiHEPqL (ORCPT + 99 others); Fri, 5 Aug 2022 11:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241141AbiHEPpa (ORCPT ); Fri, 5 Aug 2022 11:45:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8098971712; Fri, 5 Aug 2022 08:44:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CDA7E61640; Fri, 5 Aug 2022 15:44:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16817C433B5; Fri, 5 Aug 2022 15:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659714242; bh=FzcxabaZhSQ69xBMAwnH2bzRNcykHT1NhBRq2p1N3ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VXW1GvZfwu7IDJbJAXyQ4oy7QyUNzEJSNBta1CYHQ6yiMze/2oDjPjH5stV+eeATu qSpmugbtXguvu13FXRHznpn01r+zwo0YHl/VzocXyNDRZ4VMbf0pz3bTTk9wlhvp0l VT4/zvmAR7lsJ7lVMbdOo97f1nndsfYkbaBiNUK2L3TBtRZzSYcJ8nfZxPTI7IukZc QI41ceKkoFkRPqYPVxeQQ+msMAIpVjN4wV96fMwaXuCGNXNt8ITYUVsUlyZ2fTlDkO 3eFD0uItpuCPXL+TDwDI808DJgbQ8ja0G3sBz+ChYpXn00oj45fGx6HvEYMuEXSYGj oW71aNkwEIO4Q== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Miguel Ojeda , Kees Cook , Alex Gaynor , Wedson Almeida Filho , Joe Perches , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH v9 15/27] scripts: checkpatch: diagnose uses of `%pA` in the C side as errors Date: Fri, 5 Aug 2022 17:42:00 +0200 Message-Id: <20220805154231.31257-16-ojeda@kernel.org> In-Reply-To: <20220805154231.31257-1-ojeda@kernel.org> References: <20220805154231.31257-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The `%pA` format specifier is only intended to be used from Rust. `checkpatch.pl` already gives a warning for invalid specificers: WARNING: Invalid vsprintf pointer extension '%pA' This makes it an error and introduces an explanatory message: ERROR: Invalid vsprintf pointer extension '%pA' - '%pA' is only intended to be used from Rust code Suggested-by: Kees Cook Co-developed-by: Alex Gaynor Signed-off-by: Alex Gaynor Co-developed-by: Wedson Almeida Filho Signed-off-by: Wedson Almeida Filho Co-developed-by: Joe Perches Signed-off-by: Joe Perches Signed-off-by: Miguel Ojeda --- scripts/checkpatch.pl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 503e8abbb2c1..23799e8013b3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6782,15 +6782,19 @@ sub process { } if ($bad_specifier ne "") { my $stat_real = get_stat_real($linenr, $lc); + my $msg_level = \&WARN; my $ext_type = "Invalid"; my $use = ""; if ($bad_specifier =~ /p[Ff]/) { $use = " - use %pS instead"; $use =~ s/pS/ps/ if ($bad_specifier =~ /pf/); + } elsif ($bad_specifier =~ /pA/) { + $use = " - '%pA' is only intended to be used from Rust code"; + $msg_level = \&ERROR; } - WARN("VSPRINTF_POINTER_EXTENSION", - "$ext_type vsprintf pointer extension '$bad_specifier'$use\n" . "$here\n$stat_real\n"); + &{$msg_level}("VSPRINTF_POINTER_EXTENSION", + "$ext_type vsprintf pointer extension '$bad_specifier'$use\n" . "$here\n$stat_real\n"); } } } -- 2.37.1