From patchwork Tue Oct 18 12:27:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 4151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1932814wrs; Tue, 18 Oct 2022 05:29:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7T1egqqfUPmiDsjuM5Ff6d2peGMBNRCDPhNZIz8of0sE+b22OfY9KkLThbn8yzwYmtB/Kq X-Received: by 2002:a17:906:2681:b0:783:6a92:4c38 with SMTP id t1-20020a170906268100b007836a924c38mr2220274ejc.75.1666096179634; Tue, 18 Oct 2022 05:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666096179; cv=none; d=google.com; s=arc-20160816; b=fsP0qCAKsWwOn1FT9ywlJfBujUauLJ51IHYyn9VKGW35tdNgR/E/zReodz329tgigf bNOpCzKa2CQtC19es45Ns8Ugi4gbUIIOizf+E4aQo21dWS+Dh6mrUNIUfbWnh4S4yQ2d d34CnnHLll3TbpAfL3WrK+hCgsqzdQoJK3mjveHlJWgahndHkXd8j8TnJrhfOPI89es2 TUoJFhtW/DeH+l2EaV9L7FyQK3rEaYdBw7KYt5SfghUDUu4jiJs8kKZCLA1y8GDIjk7o +MUlwNqvQi9hP/g2kks9m+afPGTYGUVPgpCWYhiW/gXFzHB1NLY/D2U2Ic0A0YAHsDlK ud5A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=3S5tAXJNU/hSPSvRVRKydKWw46cogc0DhgOH2eIG+pw=; b=F1DF8qL15I6UfD59Cf5G7W0I5WSKKDq/3e6Ol57HM+VJhPaMcPHJB4eil4S42mnE9k G+TasBptBQ8ddkBpyRSTFVtrv+IJmbgZEs+s1N2XY3Qtj6Nq028/04HAZMYTkHe4P8Q5 tnPneyG4K6xeCjhxPmSjiedge1riYkWQfIM6JJaS+b+RfBXe4WCAz4S0cLqP9NAMSz0u pz1xOfxm6mjU9lsf06TyB1RS3aZUATI5D4NPFw5HVWBV7PFq0RoziLvxFWbexAvAfpA+ d5lBEa2oiZe4uBfywJvL6tT9qlYFoY8LIZWpnwZMmzUWr360iAtYxFGs8TLrx3m649z/ UEwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SnamShzR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c8-20020a05640227c800b0045dbd131cd7si3351812ede.65.2022.10.18.05.29.14; Tue, 18 Oct 2022 05:29:39 -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=SnamShzR; 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 S230057AbiJRM1T (ORCPT + 99 others); Tue, 18 Oct 2022 08:27:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbiJRM1S (ORCPT ); Tue, 18 Oct 2022 08:27:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C2D9B1DF5; Tue, 18 Oct 2022 05:27:17 -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 ams.source.kernel.org (Postfix) with ESMTPS id A82E0B81E9F; Tue, 18 Oct 2022 12:27:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DA08C433D6; Tue, 18 Oct 2022 12:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666096034; bh=VQPk5DjCowXwXW+B/j4PJh6cSP/7mrS4QgVwxTpPUrE=; h=From:To:Cc:Subject:Date:From; b=SnamShzRyVDajya2DifAvhooiLO2rs+X1yv+zEsKTGIIEWf+rnyEBaElBV2jhOeUV HO3XiGQn/GxhVD18TF6M1npJGJOuDg5BCi9VRB0VOjicJxBudNTjXhFedimSQvKIlx h2yjtY87OQ1CBhIfj6LkvD/18NqpzDx15OaHRKD12pkUwILEaj0xUjtz8S+LO8/9ug rJF/6pd4qXU8gqYcwSoxrBfkbqNsfW+rquNXAX4N9e6bm58F4tRx4Q30qsXMG0npf5 PDd2MkqAlPFFIv+nX781y3zeLosEdoyyw8kbvpd2LJOQjPptljtOGDYXvFKuxFH0ER vgbIwyaq1KVJw== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Andy Lutomirski Cc: Akihiro HARAI , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo Subject: [PATCH] x86: Include asm/ptrace.h in syscall_wrapper header Date: Tue, 18 Oct 2022 14:27:08 +0200 Message-Id: <20221018122708.823792-1-jolsa@kernel.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747028467432817589?= X-GMAIL-MSGID: =?utf-8?q?1747028467432817589?= From: Jiri Olsa With just the forward declaration of the 'struct pt_regs' in syscall_wrapper.h, the syscall stub functions: __[x64|ia32]_sys_*(struct pt_regs *regs) will have different definition of 'regs' argument in BTF data based on which object file they are defined in. If the syscall's object includes 'struct pt_regs' definition, the BTF argument data will point to 'struct pt_regs' record, like: [226] STRUCT 'pt_regs' size=168 vlen=21 'r15' type_id=1 bits_offset=0 'r14' type_id=1 bits_offset=64 'r13' type_id=1 bits_offset=128 ... If not, it will point to fwd declaration record: [15439] FWD 'pt_regs' fwd_kind=struct and make bpf tracing program hooking on those functions unable to access fields from 'struct pt_regs'. Including asm/ptrace.h directly in syscall_wrapper.h to make sure all syscalls see 'struct pt_regs' definition and resulted BTF for '__*_sys_*(struct pt_regs *regs)' functions point to actual struct, not just forward declaration. Reported-by: Akihiro HARAI Signed-off-by: Jiri Olsa Acked-by: Andrii Nakryiko --- arch/x86/include/asm/syscall_wrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h index 59358d1bf880..fd2669b1cb2d 100644 --- a/arch/x86/include/asm/syscall_wrapper.h +++ b/arch/x86/include/asm/syscall_wrapper.h @@ -6,7 +6,7 @@ #ifndef _ASM_X86_SYSCALL_WRAPPER_H #define _ASM_X86_SYSCALL_WRAPPER_H -struct pt_regs; +#include extern long __x64_sys_ni_syscall(const struct pt_regs *regs); extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);