Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3353052pxb; Mon, 4 Apr 2022 14:24:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBo47BPNDaSbKzsTzAP8Bu/dx0NmhxMP/gDm1UDqIfFXsM0r43UP/f/PqXtB6iiK/9Xd7S X-Received: by 2002:a17:902:e549:b0:154:b1f8:cc82 with SMTP id n9-20020a170902e54900b00154b1f8cc82mr174821plf.82.1649107479567; Mon, 04 Apr 2022 14:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649107479; cv=none; d=google.com; s=arc-20160816; b=z6AyR1MTpfm1m4pHkmnT8lbZrFt1H1bf5MAfGWeQk0hZnfz+vMdtX4Qm4O0lioEWRj pnblh3dLT5rxMH5sjvX4mp+I5QVoQMEk010FehrZlCR23JRBN7j+5EVPV5OsZ53UyuV+ EBLOjlolOpUlT2W2jTrGYGuQhR9F+0cOmXlT1gCgMiGRHgUlN9LaKMYKaaxUgkgRMzsN GyoVnYdgW8Qbg5F8WdvdjYAv2gEDU78vqhXF5NtJHhtxkofa3QYSQ+2mzfsbgnm0aGd/ ofOTOtgtQqxJFuc8vMIKryCMx5GZcp2zIWo3SziM8TzT3Cp2FFoEO7dlhpVjcfU1L5fB RkAw== 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=G+MPXwUDTG1tH7e/qclTBf1Y4BxTokg7f44dPM29lg8=; b=HivVT4INj7PWtZlRXvskvkA3mT7r3FKZDMbP/+H2HkLvfZCWDh5nrrwpvqVhoqur/a u324hV7Qi99dZBfxTyOuj8Zhqkw3BfpOQZFpbl6D3PyFw+CiVWN9g9sWJCNnBqTVsZ2w DnlRjLw0H2ybFEYHT/KEv2+MAh1mdjM3PEb33NwvHfUY2qyvDSgxwDcdQkNyDAp0qvDZ 6GtD+3I58GU+tfpn5AbqvoZIeFOEyJHCZMETjMiNR2NtpSBTk5QpE+tnETcjeN9HPjAi ktU8HCq6D8hQ0498lpI88wFCjZmX5Jp5+qBOMYE+fyYxEo+USkFDJG3UinVu7vT3yZ3g YQrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=U1wpOOIG; 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 b9-20020a631b49000000b00385d870e145si11151889pgm.391.2022.04.04.14.24.23; Mon, 04 Apr 2022 14:24: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=U1wpOOIG; 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 S1347591AbiDAOfd (ORCPT + 99 others); Fri, 1 Apr 2022 10:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347398AbiDAOcb (ORCPT ); Fri, 1 Apr 2022 10:32:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E60171EC606; Fri, 1 Apr 2022 07:28:54 -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 BB43E61CA5; Fri, 1 Apr 2022 14:28:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECFF5C2BBE4; Fri, 1 Apr 2022 14:28:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648823333; bh=NVhgl5DRA9+6XmU+6e5/svfpSnBLUwoq6XR+Koivd/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U1wpOOIGMt/eN8NOwhu8+VkacgQkaMCwk6fd5SeSOE0T0oSH+845w5O7agCCTlUUP yxbKFtuEQ36wCYTRFTcKkGZ3n7yGwFEea5iM8ZLJ3OXI9gcJrX7ENggtq42r1+pW/y ziOLn8Zg1aUnzhxnCZEJ221tVBnB1X4LRK8rhlXzSe20jfd696k1NO7v9cCHxUPO/X Fh0eqnIWo9/OHuKC2Rd0TdR5Oqw1+4ykh7Luk3aCRSVOQcbqXjdoqAFfmhqktne2fP sjH4MbyIUp7GKWOmIHHXuczr2E8rt9z9ZcuuVqotFpk70WCC9cUG6HQS5NWuUSsjP3 edmGd9ht3oydA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ilya Leoshkevich , Heiko Carstens , Andrii Nakryiko , Sasha Levin , ast@kernel.org, daniel@iogearbox.net, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 5.17 061/149] libbpf: Fix accessing the first syscall argument on arm64 Date: Fri, 1 Apr 2022 10:24:08 -0400 Message-Id: <20220401142536.1948161-61-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220401142536.1948161-1-sashal@kernel.org> References: <20220401142536.1948161-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 From: Ilya Leoshkevich [ Upstream commit fbca4a2f649730b67488a8b36140ce4d2cf13c63 ] On arm64, the first syscall argument should be accessed via orig_x0 (see arch/arm64/include/asm/syscall.h). Currently regs[0] is used instead, leading to bpf_syscall_macro test failure. orig_x0 cannot be added to struct user_pt_regs, since its layout is a part of the ABI. Therefore provide access to it only through PT_REGS_PARM1_CORE_SYSCALL() by using a struct pt_regs flavor. Reported-by: Heiko Carstens Signed-off-by: Ilya Leoshkevich Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220209021745.2215452-10-iii@linux.ibm.com Signed-off-by: Sasha Levin --- tools/lib/bpf/bpf_tracing.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/lib/bpf/bpf_tracing.h b/tools/lib/bpf/bpf_tracing.h index d40b87c0e4b9..ad62c17919cf 100644 --- a/tools/lib/bpf/bpf_tracing.h +++ b/tools/lib/bpf/bpf_tracing.h @@ -140,6 +140,10 @@ #elif defined(bpf_target_arm64) +struct pt_regs___arm64 { + unsigned long orig_x0; +}; + /* arm64 provides struct user_pt_regs instead of struct pt_regs to userspace */ #define __PT_REGS_CAST(x) ((const struct user_pt_regs *)(x)) #define __PT_PARM1_REG regs[0] @@ -152,6 +156,8 @@ #define __PT_RC_REG regs[0] #define __PT_SP_REG sp #define __PT_IP_REG pc +#define PT_REGS_PARM1_SYSCALL(x) ({ _Pragma("GCC error \"use PT_REGS_PARM1_CORE_SYSCALL() instead\""); 0l; }) +#define PT_REGS_PARM1_CORE_SYSCALL(x) BPF_CORE_READ((const struct pt_regs___arm64 *)(x), orig_x0) #elif defined(bpf_target_mips) -- 2.34.1