From patchwork Thu Oct 10 14:14:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1995479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=KfcsqAzk; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=EDRrVBYR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XPWwm4yGlz1xsc for ; Fri, 11 Oct 2024 01:14:48 +1100 (AEDT) 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:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=n5AusyZW+IWCDnypqEsptazQ7H9DSo8gfkV623p7nI0=; b=KfcsqAzk1wrWBdVySmqecG/eFF KOn4Ylcm1d3rY0wS/x9WTHIFTdXoqLHcs00XDClYv3szVpH93+yvWabXcjRZceDLH1x87M6e//uxn GJZIIORc3AFxW5uU5VWv/tdeB0aFoKTnMQP72yDdTQweZMlXciiIasogRZFZ+fAtFKcD3biW2vYHi sPFA+ULTNodhs4u0u9vQs90MM7eUeQQf+7Q3HXXvOF4JoPx7GRLFa9vbllykXDrtyq2hWXCdmUt61 ltaL4OHFpakZDQq+EN3Dxw//xARHaCiM7wBj0NrdZDs2hLyxkSqlvwhS0YDaBUP1FQMNl28xWQajO vNzABJ5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sytwD-0000000D3Qe-0GmX; Thu, 10 Oct 2024 14:14:45 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sytvl-0000000D3K9-2MuJ for linux-um@lists.infradead.org; Thu, 10 Oct 2024 14:14:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=n5AusyZW+IWCDnypqEsptazQ7H9DSo8gfkV623p7nI0=; t=1728569656; x=1729779256; b=EDRrVBYRrjlW94U9p0VztIiqoNXB7cOJYf/GnQ7VH08BLlaS3e6RMnGveo6J5zJICqcpkAZ6Kjh 0/GAiA/+cjJzMx35W1GgAOW8T4oiDBm+cZyHe0pxb6MxB+3cA4fQ3VdVuh15vpfbjGm5cEBO+bpAP 46CbCXstBjemH+G7/f7r8OsuLbASXCBtqXzIXQKC6CpAbykxlLO/uHjVNXK1d8seWXWbe/ZadU5VO IpWniTPYP8lPkG8bD4DfzUmjImCQ6nhXuflbfJvQul3g00kIlODkFkCTiCulK71HcpcfOTjBeqm4u x6SA8zrHITqiinCLNt6GRnzZ/YEIrz0tW1lQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.98) (envelope-from ) id 1sytvh-000000068Br-453A; Thu, 10 Oct 2024 16:14:14 +0200 From: Johannes Berg To: linux-um@lists.infradead.org Cc: Johannes Berg Subject: [PATCH] um: restore process name Date: Thu, 10 Oct 2024 16:14:12 +0200 Message-ID: <20241010161411.c576e2aeb3e5.I244d4f34b8a8555ee5bec0e1cf5027bce4cc491b@changeid> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241010_071417_756568_2668646E X-CRM114-Status: GOOD ( 11.66 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Johannes Berg After the execve() to disable ASLR, comm is now "exe", which is a bit confusing. Use readlink() to get this to the right name again. Disable stack frame size warnings on main.o since it's part of the initial userspace and can use larger stack. Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-um@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-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg After the execve() to disable ASLR, comm is now "exe", which is a bit confusing. Use readlink() to get this to the right name again. Disable stack frame size warnings on main.o since it's part of the initial userspace and can use larger stack. Fixes: 68b9883cc16e ("um: Discover host_task_size from envp") Signed-off-by: Johannes Berg --- arch/um/os-Linux/Makefile | 2 ++ arch/um/os-Linux/main.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile index 544e0b344c75..049dfa5bc9c6 100644 --- a/arch/um/os-Linux/Makefile +++ b/arch/um/os-Linux/Makefile @@ -12,6 +12,8 @@ obj-y = execvp.o file.o helper.o irq.o main.o mem.o process.o \ CFLAGS_signal.o += -Wframe-larger-than=4096 +CFLAGS_main.o += -Wno-frame-larger-than + obj-$(CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA) += elf_aux.o USER_OBJS := $(user-objs-y) elf_aux.o execvp.o file.o helper.o irq.o \ diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c index 8a52c49c5361..31dba0912a19 100644 --- a/arch/um/os-Linux/main.c +++ b/arch/um/os-Linux/main.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -112,8 +113,17 @@ int __init main(int argc, char **argv, char **envp) /* Disable randomization and re-exec if it was changed successfully */ ret = personality(PER_LINUX | ADDR_NO_RANDOMIZE); if (ret >= 0 && (ret & (PER_LINUX | ADDR_NO_RANDOMIZE)) != - (PER_LINUX | ADDR_NO_RANDOMIZE)) - execve("/proc/self/exe", argv, envp); + (PER_LINUX | ADDR_NO_RANDOMIZE)) { + char buf[PATH_MAX]; + ssize_t ret; + + ret = readlink("/proc/self/exe", buf, sizeof(buf)); + if (ret < 0 || ret >= sizeof(buf)) { + perror("readlink failure"); + exit(1); + } + execve(buf, argv, envp); + } set_stklim();