Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2305667imn; Mon, 1 Aug 2022 20:05:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR6mP2ilQD77hQS9ortV4OutujYBzd742moxsvEBPCH/n6+YKmiCBsFTu0h/83wgnHfYHZs9 X-Received: by 2002:a17:90b:1d05:b0:1f4:ed4a:764e with SMTP id on5-20020a17090b1d0500b001f4ed4a764emr11736707pjb.192.1659409500120; Mon, 01 Aug 2022 20:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659409500; cv=none; d=google.com; s=arc-20160816; b=FPWTquCABKFc+QLHA7QfxSUtZI6oY8RvO4qp5PGomlseG8N81DmKZT5ui4lc4GWYOb SQolaqmQJXUQQIeKSdD/y6Sne8rgKu3KshziZAQSU+RFv91JTiOfcfjyuyuF+FdBjDK4 7ntlGCuwjX53F7KSlES1/7sUipqAp7o81OoOJNxmwnd4sTNZrDihs7KrevVtorFt2P4p Ei2hMYbM/k3nKU9UMssbS8uE9ceRtk1YPXmFhR5bqD1aOQIEnuxKeFsLAt1KYadeItzh gdxlJtAk2+Vibi6DtR/vnuC2PJaSflQiQAP7jNE1GCLEriKJZbVaSU985kqYv446IU0L gxgA== 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=nr3qpgrsR/x4J1uvTfTgmmteZYGCCuikLPHFrhu0wMfKicNTUt4dhPqhPm/0uw1lt8 8GljgmzWUVx6OxnLawzuHAhW4y/JtJ9Jdt6GKZ8H4vNExsyfoLXKEr7j+Zfjh7YpuHsu 2vNiINCY4R4/DYRpsOKogGYBm/OYWhYnkS+qxvI8rGPTtaoAtaXOfWq5OghAlfvTY4Kn uCTKGukQs+QVVn8tDXHdqv/b0ylqQ1TPbWx6DvSEMxbnC3J1QZVpQ+tT+31IW/PwTiSM GB6CR2sa0NpZfy7btnTHEqUlHuSYKbkyddoDa3kKyXDco4wCf1CYWR5xuMFv442omQq/ YIww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bT7r0rS6; 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 z1-20020a170903018100b0016ccf06c2aesi403771plg.512.2022.08.01.20.04.46; Mon, 01 Aug 2022 20:05:00 -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=bT7r0rS6; 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 S235743AbiHBBzA (ORCPT + 99 others); Mon, 1 Aug 2022 21:55:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235742AbiHBBx6 (ORCPT ); Mon, 1 Aug 2022 21:53:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 355724B0D5; Mon, 1 Aug 2022 18:53:09 -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 B7D4F6106F; Tue, 2 Aug 2022 01:53:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16D62C433D6; Tue, 2 Aug 2022 01:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659405188; bh=FzcxabaZhSQ69xBMAwnH2bzRNcykHT1NhBRq2p1N3ek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bT7r0rS66XSpWMdO0B6TKWtlShJeFO7LPSLKtMp9cChYXGq15fzk4esB6Q/60zf6A LNmcYrcajSADLWhRtoF9thhYQftiwq/MJMhd9p+10zsVKqCZWm6MPmaucfJysRg6f+ NpB1Gs5+i+eQCx3ug0EpjXofXATz8o6ZHjidfyaLw4+4Q46BYNTlotfalbPPqODOnK 9TLhXKFKY0ep4ZmSktd1Qqto4m6Xg6Bk5oXh3LLRYtF0bSOW1TROJrYv6gwBTQJTR+ HOqMyq9IzQO8gk3+N/afKBOaboK13B2/m8x0qUWfW7KZKUE8nykJb4ImMl/DcVnAYi 12h4zpY0H9rCQ== From: Miguel Ojeda To: Linus Torvalds , Greg Kroah-Hartman Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Jarkko Sakkinen , Miguel Ojeda , Kees Cook , Alex Gaynor , Wedson Almeida Filho , Joe Perches , Andy Whitcroft , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH v8 20/31] scripts: checkpatch: diagnose uses of `%pA` in the C side as errors Date: Tue, 2 Aug 2022 03:50:07 +0200 Message-Id: <20220802015052.10452-21-ojeda@kernel.org> In-Reply-To: <20220802015052.10452-1-ojeda@kernel.org> References: <20220802015052.10452-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 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