From patchwork Thu Oct 10 11:33:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13829989 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57DC3CF11D0 for ; Thu, 10 Oct 2024 11:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R4LTFu04v+ewJrCMf1qStO/yKKemj/dlkSOHqQ2h8u0=; b=bNpigo2A2PJPAbumph2KQ1E7Q+ rB3qAglz8m6ccp9h1T3XjrmqnNsZ9a/rIr4gAkcI5TYl4jzTRyjaiQdwQxQEKIrNgibs1cUxp4ou8 JPEW574EGoO7hVJhj84l3MzERND88/vaXpe+B/FwUnC70sP7AGyyjFHbbmM4NJyS15SR8RsiZMlrq 45qCGhX5X9l7YwVS7IorCQFFFqh83MN1MKH8j/i0xyQS5TS2vKV+Uh1si1LA0XSybmipHyrwwBPsg nPV4Ze6LCgaz4aw6OeEFn4i8vMNkct8UtQI5szX30rsRdI51TXYoVyt4IvK7iyYeXAPwUd8SAFuFt ql2yNo+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1syrVA-0000000CZaK-20n1; Thu, 10 Oct 2024 11:38:40 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1syrQR-0000000CY9e-3J26 for linux-arm-kernel@lists.infradead.org; Thu, 10 Oct 2024 11:33:51 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a994ecf79e7so133828166b.0 for ; Thu, 10 Oct 2024 04:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728560026; x=1729164826; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=R4LTFu04v+ewJrCMf1qStO/yKKemj/dlkSOHqQ2h8u0=; b=xI+boc9EMzHnIBxaHgisioCvUTZcyKlgAsrSigIWi0VMcAbnmTrH3nK6GtLeqOUt1v IWTgKQNbDDv7TAz8VqxWDSIbGroif4R3jNjKeX9UpaNh7n5SL7vOXCL+ywOLGLEHbefq LrtyiLElVR7O6MZZBBGltyvEgF/60WLCDiRR6cvNZDRxkR/mU+GHEQE0E4Qv7ZFGjiRd maUH6sF0E/CQZK+HpgEWsWCTsf2j6Jzk1p2P8VGuUIkx/gQn+pIitC4N88MS8cIUKjE2 HkuQydcX/nS6+h/A/XInlc3jFgOWks4AoUAlGLdVMLtqLNxup00JbVZHBLqSnwzU9rcn DxIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728560026; x=1729164826; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R4LTFu04v+ewJrCMf1qStO/yKKemj/dlkSOHqQ2h8u0=; b=qqv9fTiDwurRug8l03Ys61YJabp6RfXvs+m8zuhcjzi+ztIBajETAcljDg4RKfeont q0Ir/kkIxluqc0/qFysqoeMHUfmh1TWS9gk9SErQ0B/6fke7BrkutlXn7hRBdwA+XJdQ gqwVUzw6UduswpGRztkXH/7S6mu1JnGkThl9jU0KMI8vu5DJEjrYwg68C9spUQnWw0t6 9okExad19gNLS8CzCfOf6eq1INS1GdLEEykq1csfO+OCJixd3Yi2XDjqyv72k8FOmlCn 8kkv5NSSzcJfpejvd7+gtJBQ4IAXeoJvf+AJxAJhUpOKvrQD6tPrhKFZREL/Q9rSt2YS rKJg== X-Gm-Message-State: AOJu0YxBbIXpVkMxsios2rEsLkYiXaQxdtJ6psqWySF2Q85eLqAUT4qJ X1LKGIYS6NCVYM4xYhR8yN2emqODbsXhvDDlRxVWT0h6LQBIibGhxQnK8cIhZnI= X-Google-Smtp-Source: AGHT+IF/7BdKriGHfpakAch78gEDyPg7g4F5Squ3DH3oytxrvyGsFjm+zrnSb3mJBDsLPEmr+DbRWQ== X-Received: by 2002:a17:907:7e84:b0:a99:62a4:3fc1 with SMTP id a640c23a62f3a-a998d315001mr502326466b.49.1728560026025; Thu, 10 Oct 2024 04:33:46 -0700 (PDT) Received: from lino.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a7f25406sm77619066b.69.2024.10.10.04.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 04:33:44 -0700 (PDT) From: Linus Walleij Date: Thu, 10 Oct 2024 13:33:40 +0200 Subject: [PATCH RFC 02/28] ARM: ptrace: Split report_syscall() MIME-Version: 1.0 Message-Id: <20241010-arm-generic-entry-v1-2-b94f451d087b@linaro.org> References: <20241010-arm-generic-entry-v1-0-b94f451d087b@linaro.org> In-Reply-To: <20241010-arm-generic-entry-v1-0-b94f451d087b@linaro.org> To: Oleg Nesterov , Russell King , Kees Cook , Andy Lutomirski , Will Drewry , Frederic Weisbecker , "Paul E. McKenney" , Jinjie Ruan , Arnd Bergmann , Ard Biesheuvel , Al Viro Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.14.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_043347_861481_B6A8684A X-CRM114-Status: GOOD ( 14.33 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The generic entry code requires that report_syscall() be provided in two parts: report_syscall_enter() and report_syscall_exit() so split the combined function in two. Signed-off-by: Linus Walleij --- arch/arm/kernel/ptrace.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index c421a899fc84..07b0daf47441 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -827,31 +827,45 @@ enum ptrace_syscall_dir { PTRACE_SYSCALL_EXIT, }; -static void report_syscall(struct pt_regs *regs, enum ptrace_syscall_dir dir) +static void report_syscall_enter(struct pt_regs *regs) { unsigned long ip; /* * IP is used to denote syscall entry/exit: - * IP = 0 -> entry, =1 -> exit + * IP = 0 -> entry */ ip = regs->ARM_ip; - regs->ARM_ip = dir; + regs->ARM_ip = PTRACE_SYSCALL_ENTER; - if (dir == PTRACE_SYSCALL_EXIT) - ptrace_report_syscall_exit(regs, 0); - else if (ptrace_report_syscall_entry(regs)) + if (ptrace_report_syscall_entry(regs)) current_thread_info()->abi_syscall = -1; regs->ARM_ip = ip; } +static void report_syscall_exit(struct pt_regs *regs) +{ + unsigned long ip; + + /* + * IP is used to denote syscall entry/exit: + * IP = 1 -> exit + */ + ip = regs->ARM_ip; + regs->ARM_ip = PTRACE_SYSCALL_EXIT; + + ptrace_report_syscall_exit(regs, 0); + + regs->ARM_ip = ip; +} + asmlinkage int syscall_trace_enter(struct pt_regs *regs) { int scno; if (test_thread_flag(TIF_SYSCALL_TRACE)) - report_syscall(regs, PTRACE_SYSCALL_ENTER); + report_syscall_enter(regs); /* Do seccomp after ptrace; syscall may have changed. */ #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER @@ -892,5 +906,5 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs) trace_sys_exit(regs, regs_return_value(regs)); if (test_thread_flag(TIF_SYSCALL_TRACE)) - report_syscall(regs, PTRACE_SYSCALL_EXIT); + report_syscall_exit(regs); }