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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 732EBE77188 for ; Sun, 12 Jan 2025 10:42:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD5716B0096; Sun, 12 Jan 2025 05:42:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C854B6B0098; Sun, 12 Jan 2025 05:42:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4CBB6B0099; Sun, 12 Jan 2025 05:42:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 96AAA6B0096 for ; Sun, 12 Jan 2025 05:42:06 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1AA39C1682 for ; Sun, 12 Jan 2025 10:42:06 +0000 (UTC) X-FDA: 82998459852.08.D5FA1FC Received: from flow-b2-smtp.messagingengine.com (flow-b2-smtp.messagingengine.com [202.12.124.137]) by imf02.hostedemail.com (Postfix) with ESMTP id D1C8180009 for ; Sun, 12 Jan 2025 10:42:03 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=coelacanthus.name header.s=fm3 header.b=ph2OkD71; dkim=pass header.d=messagingengine.com header.s=fm2 header.b="q 1z/HPf"; spf=pass (imf02.hostedemail.com: domain of uwu@coelacanthus.name designates 202.12.124.137 as permitted sender) smtp.mailfrom=uwu@coelacanthus.name; dmarc=pass (policy=quarantine) header.from=coelacanthus.name ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736678524; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oaDf/Ac90EbejoB/UI1UVChf0YVbXYbpJL+sA5TcwZA=; b=zkzpufXJkzMrLFQUbTrL7FmaeN0D99mHTRCouCSUgb0uI8pNxht5p6oO79QruepI+baT1c 3kdlVAbb6j/4wC5SHTkCbh33n3iieFoxZmwz8GRTYxE9u8oFC3CzDgqFhun3R+CBfNv8a5 xUM1xXf5B5TIZ/r6Ier1jCRqidv894w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736678524; a=rsa-sha256; cv=none; b=7wSN9q7nMtR66VMTGJ+vdHjTVKOAr/dfz1M38F5AJ9fQJT4HV6j6zb1XRnW1+ALCBbs5uj GtxSn03SJ19AVrIX5VkUsjKiL1aJ50jOB+de4aIEpejJ23ablnJrLSQkJo30u1nmLsWyTz bZWzF+ZlNTuyrJ6NHspXmKObGkCDJlY= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=coelacanthus.name header.s=fm3 header.b=ph2OkD71; dkim=pass header.d=messagingengine.com header.s=fm2 header.b="q 1z/HPf"; spf=pass (imf02.hostedemail.com: domain of uwu@coelacanthus.name designates 202.12.124.137 as permitted sender) smtp.mailfrom=uwu@coelacanthus.name; dmarc=pass (policy=quarantine) header.from=coelacanthus.name Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailflow.stl.internal (Postfix) with ESMTP id 4F0DF1D40AA4; Sun, 12 Jan 2025 05:42:02 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Sun, 12 Jan 2025 05:42:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= coelacanthus.name; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1736678522; x=1736685722; bh=oaDf/Ac90E bejoB/UI1UVChf0YVbXYbpJL+sA5TcwZA=; b=ph2OkD71U6adFSgvCCpweFwQ1u ksLpq9skHD0NkR8SWwZaDBvVR/1bzMZbCtABSHPQOQ5F7X5nnDU2x6Sd24UxW0Hv F8Of8CWWpECV4frNAjMiwr/MQm2dsxKP4aPwHyds+qdXSfZias6aAk2l8FV/fy+l AM0FfqCqzCmTxRFd9ldYQNdRB73BDrjPkSD7qVtKsXTjmSLzA9PT0rcErWBIdhnY olz/EhS7L4XICp/7nzhz55P2mEmcV3gKPdTKjtNu4iag1nI+rRK7UKEplugCnoBi b6BnWypqnUvztKn/IS5RmncLM+n5KHyV1lYWfLjX+SYxn1Uo7qOTifESXGJQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1736678522; x= 1736685722; bh=oaDf/Ac90EbejoB/UI1UVChf0YVbXYbpJL+sA5TcwZA=; b=q 1z/HPfC5wlgKu1dvVWJdLaRsgHPdXHotzZJ5o1fB8vAVQ+h9V2BDjngziPYn1VNt 84c/qZLWkCKSqbQfKV/dWei8IHTEZfF5f+3sVKQwG+9gz75ig/T3weSknkMmtuDr 2mDuIYlK2H5Hbmv6YxvZiva+B5tKPK0AD3peJDbUVem5ef53Hwt2wgMnfvMLoVGP O9tI6YrZgITmi9E7moVRtzAgb3p8cgoA+t08IMfVt0yD1jbsjRc2AmaorIVUu5W0 HRuRc7+RxB+ROWZJ+IJj3iSydC9j5OgwcvzfglRqyuW2E/dC8Xd7+zTeWAlMFLyE 4ZKkRVIkGDu25EFvwewVQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddrudehvddgudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdej necuhfhrohhmpeevvghlvghsthgvucfnihhuuceouhifuhestghovghlrggtrghnthhhuh hsrdhnrghmvgeqnecuggftrfgrthhtvghrnhepfefhfeefteekgedvfeehhfefvedutedt fefhkeeileehgefgveffvdffudehhfeknecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomhepuhifuhestghovghlrggtrghnthhhuhhsrdhnrghmvgdp nhgspghrtghpthhtohepvdefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegthh grrhhlihgvsehrihhvohhsihhntgdrtghomhdprhgtphhtthhopehlughvsehsthhrrggt vgdrihhopdhrtghpthhtohepohhlvghgsehrvgguhhgrthdrtghomhdprhgtphhtthhope hprghulhdrfigrlhhmshhlvgihsehsihhfihhvvgdrtghomhdprhgtphhtthhopehprghl mhgvrhesuggrsggsvghlthdrtghomhdprhgtphhtthhopegvsghivgguvghrmhesgihmih hsshhiohhnrdgtohhmpdhrtghpthhtohepkhgvvghssehkvghrnhgvlhdrohhrghdprhgt phhtthhopehshhhurghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopegrohhusegvvg gtshdrsggvrhhkvghlvgihrdgvughu X-ME-Proxy: Feedback-ID: i95c648bc:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 12 Jan 2025 05:41:52 -0500 (EST) Message-ID: <0b538b70-bc14-4038-a1b2-428192d6f51b@coelacanthus.name> Date: Sun, 12 Jan 2025 18:41:48 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/2] riscv: selftests: Add a ptrace test to verify syscall parameter modification To: Charlie Jenkins Cc: "Dmitry V. Levin" , Oleg Nesterov , Paul Walmsley , Palmer Dabbelt , Eric Biederman , Kees Cook , Shuah Khan , Albert Ou , Alexandre Ghiti , Andrea Bolognani , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Thomas Gleixner , Ron Economos , Andrew Jones , Quan Zhou , Guo Ren , Eugene Syromyatnikov , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= References: <20241226-riscv-new-regset-v4-0-4496a29d0436@coelacanthus.name> <20241226-riscv-new-regset-v4-2-4496a29d0436@coelacanthus.name> <20241226133459.GA30481@strace.io> <2e09aedc-44ba-40e3-ae93-1d6dc21b5eb1@coelacanthus.name> Content-Language: en-GB-large From: Celeste Liu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D1C8180009 X-Stat-Signature: k57e3tcnfby7mqwwueui3gjir1hf441d X-Rspam-User: X-HE-Tag: 1736678523-979590 X-HE-Meta: U2FsdGVkX181VcqjoF99us8bwMYJsbQE1FysHOTRMEX1cFKZnHlGdsS30yMMOPYdkHrts6tq6mJ24fbTJ9WRWHONhrKK9IiUx4jA+Yqa4yLSV0X82Nciz2ksVCJmIFdXULH8gWL+Vzpqoe1hGxdhalzDEzkiTK9fZieSk+NfyR1y8YTEOjTtbyJXoUqGmEUDB6iuZupZpc+e7BFNTTz955wj2fGmlbIEcxaS9UCdDqQOkA9iYrapWRRqwWkVHG5Btl4rWOzWmYNNqnLUd/hH22PCLjEgqf3Em+2Uq2MFr6pyK7gasv0gDPa6G5rrS5Jamr/5JOXUQJDbBYOSKd7kCAF7s/Zj1fuxDBHKXeZyS3GslaK8o6U2y/TbAUm6owIdBCEz5ECJKeNc83viyc+/oY770rZV6VRv35RTIrrMtZzZzqWnCrMGE9x3VZNrLGMhiWiRSpKF3lGkLpUVSdJ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1oLG5YItRebiINE9RtrMln2aAp4UrbvLJ9UH0nFUaM2Q/6y X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2025-01-10 11:34, Charlie Jenkins wrote: > On Thu, Dec 26, 2024 at 11:21:59PM +0800, Celeste Liu wrote: >> >> On 2024-12-26 21:35, Dmitry V. Levin wrote: >>> On Thu, Dec 26, 2024 at 06:52:52PM +0800, Celeste Liu wrote: >>>> This test checks that orig_a0 allows a syscall argument to be modified, >>>> and that changing a0 does not change the syscall argument. >>>> >>>> Co-developed-by: Quan Zhou >>>> Signed-off-by: Quan Zhou >>>> Co-developed-by: Charlie Jenkins >>>> Signed-off-by: Charlie Jenkins >>>> Reviewed-by: Björn Töpel >>>> Signed-off-by: Celeste Liu >>> [...] >>>> diff --git a/tools/testing/selftests/riscv/abi/ptrace.c b/tools/testing/selftests/riscv/abi/ptrace.c >>>> new file mode 100644 >>>> index 0000000000000000000000000000000000000000..023695352215bb5de3f91c1a6f5ea3b4f9373ff9 >>>> --- /dev/null >>>> +++ b/tools/testing/selftests/riscv/abi/ptrace.c >>> [...] >>>> + if (ptrace(PTRACE_GET_SYSCALL_INFO, pid, PTRACE_SYSCALL_INFO_ENTRY, &syscall_info_entry)) >>>> + perr_and_exit("failed to get syscall info of entry\n"); >>>> + result->orig_a0 = syscall_info_entry->entry.args[0]; >>>> + if (ptrace(PTRACE_GET_SYSCALL_INFO, pid, PTRACE_SYSCALL_INFO_EXIT, &syscall_info_exit)) >>>> + perr_and_exit("failed to get syscall info of exit\n"); >>>> + result->a0 = syscall_info_exit->exit.rval; >>> >>> I'm sorry but this is not how PTRACE_GET_SYSCALL_INFO should be used. >>> >>> PTRACE_GET_SYSCALL_INFO operation takes a pointer and a size, >>> and in this example instead of size you pass constants 1 and 2, which >>> essentially means that both syscall_info_entry->entry.args[0] and >>> syscall_info_exit->exit.rval are not going to be assigned >>> and would just contain some garbage from the stack. >>> >>> Also, PTRACE_GET_SYSCALL_INFO operation returns the number of bytes >>> available to be written by the kernel, which is always nonzero on any >>> PTRACE_GET_SYSCALL_INFO-capable kernel. In other words, this example >>> will always end up with perr_and_exit() call. >>> >>> I wonder how this test was tested before the submission. >> >> Oops... It seems I forget sync the code to test board so it runs with the old code... >> The code is completely not tested... >> I'm so sorry for my mistake. >> >> I will correct it and test it carefully later... > > It would be great to get this into 6.14. Let me know if you would like > any help! Sorry, delayed due to personal reasons. I have returned to this job recently. The update patchset will be sent tomorrow. > > - Charlie > >> >>> >>> >>