Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp965339rwb; Tue, 27 Sep 2022 06:53:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ZN7t82qaIGMESAe2iKa5nBKICWNsE+NXcMsfDGtDuY2CEhPc5v6rFjuj1szFwl4nTsYyP X-Received: by 2002:a17:90b:3e8c:b0:202:c7b1:b20b with SMTP id rj12-20020a17090b3e8c00b00202c7b1b20bmr4682222pjb.54.1664286795249; Tue, 27 Sep 2022 06:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664286795; cv=none; d=google.com; s=arc-20160816; b=y7eiEf8LdgMA/FAtQqDdYk/dmVJ9YFfsJufdhMd7/YalqyAJgWMT0FgjWkev6y42B4 b1gTSW2bzFYDBi/tKc8BdK0HLa7IBfuIMCWiCoq8ROFm9Ze7uDhqUtDgaq7VSp9Tg/w3 uasicavrgZ4AsyPdRw0TgVKD6QBleXHmOhotmGZj3gWteJjCG8/SqlP27PBovRLThnIE Hby/2aIE07L/dJxaSyd9WMTj25hGOg84lST7i70CpDk9UJwBgaOFYi+w0VzMFzpRQN9O rn5BR13GMQYXNK1WBp9FbwSqwLbTkcTZCcwbZ1esloLCVYjXulW2JzrWop5K80mAICzv Es3Q== 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=DRKoB4i1kyjBX969qRgmwUuckSUYaI9xbVtwKkAiyMA=; b=SX+CcFug8s54AtlJz1XhxBV9MapHmuFkYcYj20RVMoWLtAqjM6tjG4SBWKNCfsVzea O5C3IO1fbyTMZG1SKupUrnbRqJmuyg8O+uR5hHW6imtdGc2OGBSesei9Q1RjQr7eVgzZ OSLcizU/UC8LAW96iva74uO4IMvQGZLDCHigGBjP8LFjQw6wpy5LILCFOmQ5r0nQWdDa ZfmKBB9N1z3opd6+kv/iWtnlbr5NxB+lZ303f3SLAoEFc7AFB2sbb37/r+EH4Z1T1Bo5 ZfUniQI9A2V33a2IdKSU9W66QfuMCu1AkCewpEqeA16sO3CKYlVJrw1YAz1dOUu85xtf GTLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TSBzagRi; 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 o20-20020a635d54000000b0043980f3cf36si2217533pgm.602.2022.09.27.06.53.03; Tue, 27 Sep 2022 06:53:15 -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=TSBzagRi; 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 S232764AbiI0NT4 (ORCPT + 99 others); Tue, 27 Sep 2022 09:19:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232736AbiI0NSm (ORCPT ); Tue, 27 Sep 2022 09:18:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B28E818359; Tue, 27 Sep 2022 06:17:16 -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 0AD6961977; Tue, 27 Sep 2022 13:17:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A25EC433B5; Tue, 27 Sep 2022 13:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664284623; bh=YX50CyMPv+QeqZWeqvuQdIqygaaBPbt0G7syFQ3oahg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TSBzagRif/7KEuNh05bndddeO+IfQxgSIk6P2IK8UZyZvI4sQyAtEsQSZA4S55ZLX ELxaf43a1qqiIhX2LO0LzDukDzcVXPyTqW4YcM8hEMWg7XhFwn2TFO5SdAAnjoDXva e1KVrKlegJbH3mZFAKyNm+NHIZZGUhxm8gauPpQvKOoH9nMAnzF7sIJNWuc7yVevSc /JSu8iExkaYUEeGnd5qCoIpIoeBfDdsgr5M2Is7IP2XDjxugJhbEVmBbvwlvBK+BbB 63Saq5SkGdnapglDVfGciTriJ2iZIZOR81X90zmwyq5n633HU2H8MyfUDfYMq64pHL x5i5M8ijnlIrg== 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 v10 15/27] scripts: checkpatch: diagnose uses of `%pA` in the C side as errors Date: Tue, 27 Sep 2022 15:14:46 +0200 Message-Id: <20220927131518.30000-16-ojeda@kernel.org> In-Reply-To: <20220927131518.30000-1-ojeda@kernel.org> References: <20220927131518.30000-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 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 79e759aac543..74a769310adf 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6783,15 +6783,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.3