From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 390D9C433DB for ; Mon, 22 Mar 2021 22:55:15 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF4BE61984 for ; Mon, 22 Mar 2021 22:55:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF4BE61984 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=YrOAOyyZdt7fBBJTCg/WbvNeD47ndmOUQDSyKM7AWms=; b=iH7I/cWSE9O7gGK5WlyMx5Y3SJ BSKHykZDI5+P2O3Svbvo1T1D0A9nXc0A3T/xyAsry2w8bE9NX3rq+GIUKiobAV96fICFiYkwL3Ero nsjiTrVC/iYpUGG6hzrrdMRwFnclW5UeOcnJX0Mys7uhBWtnMAYVCdJHlQAs2vnc5mRghQFvuEinP bzj/pNxVaE0/VBGcWLfhffpap2DRW3hJjDiTmO8Im8ZlsXXOtpv6lFsDT6Xy0WoUIrb1NfsCAtC0V u5OS8VQ8sTDMx6EFoWGGQx9BDCYCT/+dl20rq/Z5MZXdHNNOw/TYyCV6Sh1mhxl8SHY/pTTLOgx4Q aOAfT27w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOTQI-00ClAt-HZ; Mon, 22 Mar 2021 22:53:22 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOTQC-00Cl90-QB for linux-arm-kernel@lists.infradead.org; Mon, 22 Mar 2021 22:53:18 +0000 Received: by mail-pg1-x532.google.com with SMTP id f10so2717733pgl.9 for ; Mon, 22 Mar 2021 15:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IMWkzrSo5KuqOR1bhr2dUZDy4tkfAgiPa5VKDqfy5u0=; b=WA3OUblmI3H2wHub1+U+W1gxJ7eS8+MyEgC07bP784ezCamg3DDr9UyT3patqJtzKi FRrTrvJdOBnVyFmoJlht1WV211XeoWCQF4/BzAPXG4nuCWObGLApOnhnK4Ya9PwevUvv 9DxQ+Tjezp236sO1u5oSqf76vyQmfiRi42Biv23aQj5fDaP2FB34WaferzvI7Sdqkxos G483XQ4fR1DZRWcaxPa0twXSG4VrTgBlCVmCyBhba1grLMlmy3BIEOEomF8Z4jKRCsFF 8sEWXGZCaUYTpg9raL/59E5pzuGos9qQJJ5MDocLzITxY/nacGeKugSfVBZGLe62NjnM JWww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=IMWkzrSo5KuqOR1bhr2dUZDy4tkfAgiPa5VKDqfy5u0=; b=pCo1vRg5MyVcFwhx0c9pANB9tJKEAJ8DX8mHEKJL6pkDJrkU+9QfE71XwfRc1A7SAT s+/nDdUq/ON7SlJZOZh5GGQ4nHoVSCQIzW0QSnBX6j8tCH6in608Hk3mCLS8gs3oV2jG QiHQSPomMqB14K6MGd5/YiZd6ai4p2lhYgN3aVJ07+tUDi1AxgDgVs0Dzr8C2He7psJr Q8cnKHUDmrxHmHbsgOFyVkky7LbNPEzbzKq13buS3MqIYfn/V/jAgSjCdYiXRkpjwT// wiO6FKqxWdZCefdivRFE5IXyv/jqdXjYKUmHKEggnr7pH1kapp8egz6Y8smTZb7s/IV6 9nXg== X-Gm-Message-State: AOAM532AX0NOf7j53PFuX/epc9m03symh57N0j7Y+eKj7URuHzPmGNtO tueZUXaYbfxqy7GB414fqO4= X-Google-Smtp-Source: ABdhPJwZY1xe6/n+orT2rrli45SQZaJCH8VwdAdujySIDUQ2TjlZsLNwqHO6Rie3+LAV6U01+x8qNw== X-Received: by 2002:a05:6a00:1595:b029:217:49e9:2429 with SMTP id u21-20020a056a001595b029021749e92429mr2008514pfk.80.1616453594251; Mon, 22 Mar 2021 15:53:14 -0700 (PDT) Received: from laptop.hsd1.wa.comcast.net ([2601:600:8500:5f14:d627:c51e:516e:a105]) by smtp.gmail.com with ESMTPSA id j13sm8878211pfn.103.2021.03.22.15.53.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 15:53:13 -0700 (PDT) From: Andrei Vagin To: Will Deacon , Catalin Marinas Cc: Oleg Nesterov , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrei Vagin , Dave Martin , Keno Fischer Subject: [PATCH 0/4 v3] arm64/ptrace: allow to get all registers on syscall traps Date: Mon, 22 Mar 2021 15:50:49 -0700 Message-Id: <20210322225053.428615-1-avagin@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210322_225316_934408_2DA7C2B9 X-CRM114-Status: GOOD ( 19.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Here are two known problems with registers when a tracee is stopped in syscall traps. The first problem is about the x7 register that is used to indicate whether or not the stop has been signalled from syscall entry or syscall exit. This means that: - Any writes by the tracer to this register during the stop are ignored/discarded. - The actual value of the register is not available during the stop, so the tracer cannot save it and restore it later. For applications like the user-mode Linux or gVisor, it is critical to have access to the full set of registers in any moment. For example, they need to change values of all registers to emulate rt_sigreturn or execve and they need to have the full set of registers to build a signal frame. The second problem is that orig_x0 isn't exposed to user-space. orig_x0 is recorded at the start of the syscall entry and then it is used for resetting the argument back to its original value during syscall restarts. This series extends the user_pt_regs structure with orig_x0 and orig_x7. This doesn't break the backward compatibility. There are two interfaces how user-space can receive user_pt_regs from the kernel. The first one is PTRACE_{GET,SET}REGSET. In this case, the user-space provides a buffer and its size and the kernel fills only the part that fits the size. The second interface is a core dump file where registers are written in a separate note and the user-space can parse only the part that it knows. Cc: Catalin Marinas Cc: Dave Martin Cc: Keno Fischer Cc: Oleg Nesterov Cc: Will Deacon Andrei Vagin (4): arm64: expose orig_x0 in the user_pt_regs structure arm64/ptrace: introduce orig_x7 in the user_pt_regs structure selftest/arm64/ptrace: add a test for orig_x0 selftest/arm64/ptrace: add a test for orig_x7 v2: use the ptrace option instead of adding a new regset. v3: append orig_x0 and orig_x7 to the user_pt_regs. arch/arm64/include/asm/ptrace.h | 5 + arch/arm64/kernel/ptrace.c | 130 +++++++++++----- include/uapi/linux/elf.h | 1 + tools/testing/selftests/arm64/Makefile | 2 +- tools/testing/selftests/arm64/ptrace/Makefile | 6 + .../arm64/ptrace/ptrace_syscall_regs_test.c | 142 ++++++++++++++++++ 6 files changed, 246 insertions(+), 40 deletions(-) create mode 100644 tools/testing/selftests/arm64/ptrace/Makefile create mode 100644 tools/testing/selftests/arm64/ptrace/ptrace_syscall_regs_test.c -- 2.29.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel