Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3297899lfo; Mon, 23 May 2022 01:02:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLd0hSjKRGzK+b6bK1h6jVcPgFzSSsvyMqefzVEGypzQRZ/ywa9tRnAKHqNT99IdK6++ok X-Received: by 2002:a63:698a:0:b0:3f9:6c36:3de2 with SMTP id e132-20020a63698a000000b003f96c363de2mr11923892pgc.502.1653292930827; Mon, 23 May 2022 01:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653292930; cv=none; d=google.com; s=arc-20160816; b=lcAzy+NhY7ar+VF9/iyMf11DDc6cSX23nAj1QSZ700JV+TsSIeJIzNwEziqilQ1cL2 Rp25aOPBk/P34jc6k3EFfwkftRseeqr+BKLF1ICEUviS9v4t7IA7S1PEuYFmUlZH8MBC 4GV9qYsLyk6RVXzee86Vnhjne4bEMpzdbz8ixiYBstrjPX9CiGGOAINliLAHpmT91Pi4 dOPggVBFBi6xgw7wIWt+h/NgWQuyDHcE35mockiqTzyq8gKGoSqUHeprzTyemQpwg8s6 +dzmpPHbbG4ktqhM14MKnMb23z5rBNpIhgrCPlyhjhG/mWYng8lnEFO1MBIFNVCuhN/J OlWQ== 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=DA1vkapjmkkE1KUYwyj3k+/u9tn5ZfjEoLOt8TYYOes=; b=w57xK8VYrA/gfm8JA4Q9crhg75mkT4eS3PqrK00X2Jfmz/pHwUUpaQOr4uEk/DYyQA 9LCVWEmvgBJuRFYOnsXazKh+PU8l7+2RDV2yqEWfvYXPvmyJMPe4yj63U0TIpRpIeZnu bps8oP+rBotmtUHU/35FfDJnHcUvkVt4youv+t4lZaDiwfoZedK5zfYUERYAgP1d8BbR 5ASCcbgmsw34Y/fRR8AdGWMK2IEfqPFuttgy9h+mVfx+3B+5yESwQGtGyX4GW4V540il uzrkkFgghesJLe+3FuGne8XREXZoUhsIBwOVnsKxl4/SMO5608mhQ09sGbgVN1EnY3Jx 2Bpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zayvx34R; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j5-20020a170902690500b0015f3d889431si8960570plk.446.2022.05.23.01.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 01:02:10 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zayvx34R; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3A25C172239; Mon, 23 May 2022 00:02:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346563AbiEWCF3 (ORCPT + 99 others); Sun, 22 May 2022 22:05:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352705AbiEWCEX (ORCPT ); Sun, 22 May 2022 22:04:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EA20393EE; Sun, 22 May 2022 19:04:07 -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 DD01160F55; Mon, 23 May 2022 02:04:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C522C385AA; Mon, 23 May 2022 02:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653271446; bh=/8UpaMSYs61DMNlz4chI/v1lHncBMbdLeSx/dxrI6ww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zayvx34RpsBhHG4F+cOf2NnpgS3Ath1NRW+5/ZKN8n6XC/rEqxEFGdpu093d43ga7 Pj9BNQrM38cHLxDpZ+DZxNqYE+2XUazOM9a3M3UIOyGgQNOUroQipoYC+gAlB3K6nr yysK9p7ejieK9FsXJ4I2+b0rgSPpbgqfg0rJutwQk7FEdcqNO5SfiojN6TlWSoCdUI QxMcO+H21kdST1bjJs2DRv+TCi+sIcj+mnsq2CepM6L1NdBkyDWmjdeU37F80PD388 q0Ki6tAzRPPlJfHSlJU10hU0p1/uc3wfq9xPZOThsw6YHP3CIFtUosLsibxqCWMjm6 fX16UQQ4B23nQ== 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 , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn Subject: [PATCH v7 15/25] scripts: checkpatch: diagnose uses of `%pA` in the C side Date: Mon, 23 May 2022 04:01:28 +0200 Message-Id: <20220523020209.11810-16-ojeda@kernel.org> In-Reply-To: <20220523020209.11810-1-ojeda@kernel.org> References: <20220523020209.11810-1-ojeda@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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' With this change, we introduce an error message with further explanation: ERROR: '%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 Signed-off-by: Miguel Ojeda --- scripts/checkpatch.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 577e02998701..457d544b0b9d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6784,6 +6784,10 @@ sub process { my $stat_real = get_stat_real($linenr, $lc); my $ext_type = "Invalid"; my $use = ""; + if ($bad_specifier =~ /pA/) { + ERROR("VSPRINTF_RUST", + "'\%pA' is only intended to be used from Rust code\n" . "$here\n$stat_real\n"); + } if ($bad_specifier =~ /p[Ff]/) { $use = " - use %pS instead"; $use =~ s/pS/ps/ if ($bad_specifier =~ /pf/); -- 2.36.1