Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1707745/?format=api
{ "id": 1707745, "url": "http://patchwork.ozlabs.org/api/patches/1707745/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-um/patch/20221122100759.208290-12-benjamin@sipsolutions.net/", "project": { "id": 60, "url": "http://patchwork.ozlabs.org/api/projects/60/?format=api", "name": "User-mode Linux Development", "link_name": "linux-um", "list_id": "linux-um.lists.infradead.org", "list_email": "linux-um@lists.infradead.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20221122100759.208290-12-benjamin@sipsolutions.net>", "list_archive_url": null, "date": "2022-11-22T10:07:42", "name": "[v2,11/28] um: Rely on PTRACE_SETREGSET to set FS/GS base registers", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "55d3f8a5bed5c2c10166d78fd7219529a5052c1f", "submitter": { "id": 67525, "url": "http://patchwork.ozlabs.org/api/people/67525/?format=api", "name": "Benjamin Berg", "email": "benjamin@sipsolutions.net" }, "delegate": { "id": 54851, "url": "http://patchwork.ozlabs.org/api/users/54851/?format=api", "username": "rw", "first_name": "Richard", "last_name": "Weinberger", "email": "richard@nod.at" }, "mbox": "http://patchwork.ozlabs.org/project/linux-um/patch/20221122100759.208290-12-benjamin@sipsolutions.net/mbox/", "series": [ { "id": 329466, "url": "http://patchwork.ozlabs.org/api/series/329466/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-um/list/?series=329466", "date": "2022-11-22T10:07:37", "name": "Implement SECCOMP based userland", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/329466/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1707745/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1707745/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=<UNKNOWN>)", "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=23fHYO2E;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n secure) header.d=sipsolutions.net header.i=@sipsolutions.net\n header.a=rsa-sha256 header.s=mail header.b=a2/kI4s3;\n\tdkim-atps=neutral" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4NGg5Y55mDz23nm\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 22 Nov 2022 21:11:29 +1100 (AEDT)", "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))\n\tid 1oxQFO-007g0C-9K; Tue, 22 Nov 2022 10:11:22 +0000", "from s3.sipsolutions.net ([2a01:4f8:191:4433::2]\n helo=sipsolutions.net)\n\tby bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))\n\tid 1oxQF1-007feU-7e\n\tfor linux-um@lists.infradead.org; Tue, 22 Nov 2022 10:11:07 +0000", "by sipsolutions.net with esmtpsa\n (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)\n\t(Exim 4.96)\n\t(envelope-from <benjamin@sipsolutions.net>)\n\tid 1oxQEp-006IGn-0e;\n\tTue, 22 Nov 2022 11:10:47 +0100" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=RE+ap2HEmuKbJucEGdTqlEXDDwiQF+5G//ib+awQZMg=; b=23fHYO2EdSCZsq\n\tZAiCPo423Tig1C0N8GSVACjXXjb1Ck7Pt/jtnx1aYa8WZndw8L0xAuUFis3AbSba4O9GBwlx5vQP+\n\tBV7yBanjriXgBl8cg50Tx9rHeMpDpbUuVEHSn9xAop9aIdq8W/nyBc4B0G4/Q5Q8cd78GL5dmLNbN\n\tX3o3xBwZd9xrl3Itxe/GmKkTHUwKeIy96welgT7B7z4si5/TZOjaRLYLuByhclE9lDfB3DuVcLBpz\n\tlp6HoEWGfxeWjiqTiUIeJD2NpWisowux1O2Y5f16dTeuWkMX306jTTsLo157ZoJx/Ipwm93zAbyXN\n\tgMq/BdScPVZPa12JNzHg==;", "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version:\n\tReferences:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender\n\t:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To:\n\tResent-Cc:Resent-Message-ID; bh=bl09+7qb9QLgVQS3yUfD8lsFAj/H068ZRSWIURWdnvQ=;\n\tt=1669111859; x=1670321459; b=a2/kI4s3FSTNqE3C6dlUCieK86AyQF9+iZPz9u7bGX816la\n\tbOfYpMC8HNW5xEmnWCf5otORDwWLqZzuJZj6Q3q9SIUVpgumD7OtN7+I3gt+DU0Tck5qGnPY1tLTS\n\t6UsltUrdW1f/cB/VTP3KjLi8Fq/M/tEjwoKCfAupz4tW0yVJRA/jxiFB8o4acdsUSrFiMfb4ZungR\n\tA/DwEtM6+dVyUPAEMEAUnSQSD2ieP/PDfb4W2S9xSobk6lJ1p4yD/G4/pdg1GHy4wWEEtDhq+jOwC\n\tfkbWQGQclabxbOklDPqOejbIPZaTd+K2E7mgbApMBCwcURj81lSmODGPvyX5aGaQ==;" ], "From": "benjamin@sipsolutions.net", "To": "linux-um@lists.infradead.org", "Cc": "Benjamin Berg <benjamin@sipsolutions.net>", "Subject": "[PATCH v2 11/28] um: Rely on PTRACE_SETREGSET to set FS/GS base\n registers", "Date": "Tue, 22 Nov 2022 11:07:42 +0100", "Message-Id": "<20221122100759.208290-12-benjamin@sipsolutions.net>", "X-Mailer": "git-send-email 2.38.1", "In-Reply-To": "<20221122100759.208290-1-benjamin@sipsolutions.net>", "References": "<20221122100759.208290-1-benjamin@sipsolutions.net>", "MIME-Version": "1.0", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20221122_021059_562369_5905A1E3 ", "X-CRM114-Status": "GOOD ( 25.51 )", "X-Spam-Score": "-0.2 (/)", "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam. The original\n message has been attached to this so you can view it or label\n similar future email. If you have any questions, see\n the administrator of that system for details.\n Content preview: From: Benjamin Berg <benjamin@sipsolutions.net> These\n registers\n are saved/restored together with the other general registers using ptrace.\n In arch_set_tls we then just need to set the register and it will be\n synced\n back normally.\n Content analysis details: (-0.2 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n -0.0 SPF_PASS SPF: sender matches SPF record\n -0.0 SPF_HELO_PASS SPF: HELO matches SPF record\n -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n author's domain\n -0.1 DKIM_VALID Message has at least one valid DKIM or DK\n signature\n 0.1 DKIM_SIGNED Message has a DKIM or DK signature,\n not necessarily\n valid\n -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from\n envelope-from domain", "X-BeenThere": "linux-um@lists.infradead.org", "X-Mailman-Version": "2.1.34", "Precedence": "list", "List-Id": "<linux-um.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/linux-um>,\n <mailto:linux-um-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/linux-um/>", "List-Post": "<mailto:linux-um@lists.infradead.org>", "List-Help": "<mailto:linux-um-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/linux-um>,\n <mailto:linux-um-request@lists.infradead.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"linux-um\" <linux-um-bounces@lists.infradead.org>", "Errors-To": "linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "From: Benjamin Berg <benjamin@sipsolutions.net>\n\nThese registers are saved/restored together with the other general\nregisters using ptrace. In arch_set_tls we then just need to set the\nregister and it will be synced back normally.\n\nMost of this logic was introduced in commit f355559cf7845 (\"[PATCH] uml:\nx86_64 thread fixes\"). However, at least today we can rely on ptrace to\nrestore the base registers for us. As such, only the part of the patch\nthat tracks the FS register for use as thread local storage is actually\nneeded.\n\nSigned-off-by: Benjamin Berg <benjamin@sipsolutions.net>\n---\n arch/um/include/shared/os.h | 3 --\n arch/x86/um/asm/elf.h | 4 +--\n arch/x86/um/asm/processor_64.h | 3 --\n arch/x86/um/os-Linux/Makefile | 1 -\n arch/x86/um/os-Linux/prctl.c | 12 -------\n arch/x86/um/syscalls_64.c | 62 +++++++---------------------------\n arch/x86/um/tls_64.c | 2 +-\n 7 files changed, 16 insertions(+), 71 deletions(-)\n delete mode 100644 arch/x86/um/os-Linux/prctl.c", "diff": "diff --git a/arch/um/include/shared/os.h b/arch/um/include/shared/os.h\nindex 0df646c6651e..aff8906304ea 100644\n--- a/arch/um/include/shared/os.h\n+++ b/arch/um/include/shared/os.h\n@@ -323,9 +323,6 @@ extern void sigio_broken(int fd);\n extern int __add_sigio_fd(int fd);\n extern int __ignore_sigio_fd(int fd);\n \n-/* prctl.c */\n-extern int os_arch_prctl(int pid, int option, unsigned long *arg2);\n-\n /* tty.c */\n extern int get_pty(void);\n \ndiff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h\nindex dcaf3b38a9e0..994bb0d5c1eb 100644\n--- a/arch/x86/um/asm/elf.h\n+++ b/arch/x86/um/asm/elf.h\n@@ -168,8 +168,8 @@ do {\t\t\t\t\t\t\t\t\\\n \t(pr_reg)[18] = (_regs)->regs.gp[18];\t\t\t\\\n \t(pr_reg)[19] = (_regs)->regs.gp[19];\t\t\t\\\n \t(pr_reg)[20] = (_regs)->regs.gp[20];\t\t\t\\\n-\t(pr_reg)[21] = current->thread.arch.fs;\t\t\t\\\n-\t(pr_reg)[22] = 0;\t\t\t\t\t\\\n+\t(pr_reg)[21] = (_regs)->regs.gp[21];\t\t\t\\\n+\t(pr_reg)[22] = (_regs)->regs.gp[22];\t\t\t\\\n \t(pr_reg)[23] = 0;\t\t\t\t\t\\\n \t(pr_reg)[24] = 0;\t\t\t\t\t\\\n \t(pr_reg)[25] = 0;\t\t\t\t\t\\\ndiff --git a/arch/x86/um/asm/processor_64.h b/arch/x86/um/asm/processor_64.h\nindex 1ef9c21877bc..f90159508936 100644\n--- a/arch/x86/um/asm/processor_64.h\n+++ b/arch/x86/um/asm/processor_64.h\n@@ -10,13 +10,11 @@\n struct arch_thread {\n unsigned long debugregs[8];\n int debugregs_seq;\n- unsigned long fs;\n struct faultinfo faultinfo;\n };\n \n #define INIT_ARCH_THREAD { .debugregs \t\t= { [ 0 ... 7 ] = 0 }, \\\n \t\t\t .debugregs_seq\t= 0, \\\n-\t\t\t .fs\t\t\t= 0, \\\n \t\t\t .faultinfo\t\t= { 0, 0, 0 } }\n \n #define STACKSLOTS_PER_LINE 4\n@@ -28,7 +26,6 @@ static inline void arch_flush_thread(struct arch_thread *thread)\n static inline void arch_copy_thread(struct arch_thread *from,\n struct arch_thread *to)\n {\n-\tto->fs = from->fs;\n }\n \n #define current_sp() ({ void *sp; __asm__(\"movq %%rsp, %0\" : \"=r\" (sp) : ); sp; })\ndiff --git a/arch/x86/um/os-Linux/Makefile b/arch/x86/um/os-Linux/Makefile\nindex 253bfb8cb702..2859bbf0f3db 100644\n--- a/arch/x86/um/os-Linux/Makefile\n+++ b/arch/x86/um/os-Linux/Makefile\n@@ -6,7 +6,6 @@\n obj-y = registers.o task_size.o mcontext.o\n \n obj-$(CONFIG_X86_32) += tls.o\n-obj-$(CONFIG_64BIT) += prctl.o\n \n USER_OBJS := $(obj-y)\n \ndiff --git a/arch/x86/um/os-Linux/prctl.c b/arch/x86/um/os-Linux/prctl.c\ndeleted file mode 100644\nindex 8431e87ac333..000000000000\n--- a/arch/x86/um/os-Linux/prctl.c\n+++ /dev/null\n@@ -1,12 +0,0 @@\n-/*\n- * Copyright (C) 2007 Jeff Dike (jdike@{addtoit.com,linux.intel.com})\n- * Licensed under the GPL\n- */\n-\n-#include <sys/ptrace.h>\n-#include <asm/ptrace.h>\n-\n-int os_arch_prctl(int pid, int option, unsigned long *arg2)\n-{\n-\treturn ptrace(PTRACE_ARCH_PRCTL, pid, (unsigned long) arg2, option);\n-}\ndiff --git a/arch/x86/um/syscalls_64.c b/arch/x86/um/syscalls_64.c\nindex 27b29ae6c471..6a00a28c9cca 100644\n--- a/arch/x86/um/syscalls_64.c\n+++ b/arch/x86/um/syscalls_64.c\n@@ -16,60 +16,24 @@\n long arch_prctl(struct task_struct *task, int option,\n \t\tunsigned long __user *arg2)\n {\n-\tunsigned long *ptr = arg2, tmp;\n-\tlong ret;\n-\tint pid = task->mm->context.id.u.pid;\n-\n-\t/*\n-\t * With ARCH_SET_FS (and ARCH_SET_GS is treated similarly to\n-\t * be safe), we need to call arch_prctl on the host because\n-\t * setting %fs may result in something else happening (like a\n-\t * GDT or thread.fs being set instead). So, we let the host\n-\t * fiddle the registers and thread struct and restore the\n-\t * registers afterwards.\n-\t *\n-\t * So, the saved registers are stored to the process (this\n-\t * needed because a stub may have been the last thing to run),\n-\t * arch_prctl is run on the host, then the registers are read\n-\t * back.\n-\t */\n-\tswitch (option) {\n-\tcase ARCH_SET_FS:\n-\tcase ARCH_SET_GS:\n-\t\tret = restore_pid_registers(pid, ¤t->thread.regs.regs);\n-\t\tif (ret)\n-\t\t\treturn ret;\n-\t\tbreak;\n-\tcase ARCH_GET_FS:\n-\tcase ARCH_GET_GS:\n-\t\t/*\n-\t\t * With these two, we read to a local pointer and\n-\t\t * put_user it to the userspace pointer that we were\n-\t\t * given. If addr isn't valid (because it hasn't been\n-\t\t * faulted in or is just bogus), we want put_user to\n-\t\t * fault it in (or return -EFAULT) instead of having\n-\t\t * the host return -EFAULT.\n-\t\t */\n-\t\tptr = &tmp;\n-\t}\n-\n-\tret = os_arch_prctl(pid, option, ptr);\n-\tif (ret)\n-\t\treturn ret;\n+\tlong ret = -EINVAL;\n \n \tswitch (option) {\n \tcase ARCH_SET_FS:\n-\t\tcurrent->thread.arch.fs = (unsigned long) ptr;\n-\t\tret = save_registers(pid, ¤t->thread.regs.regs);\n+\t\tcurrent->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)] =\n+\t\t\t(unsigned long) arg2;\n+\t\tret = 0;\n \t\tbreak;\n \tcase ARCH_SET_GS:\n-\t\tret = save_registers(pid, ¤t->thread.regs.regs);\n+\t\tcurrent->thread.regs.regs.gp[GS_BASE / sizeof(unsigned long)] =\n+\t\t\t(unsigned long) arg2;\n+\t\tret = 0;\n \t\tbreak;\n \tcase ARCH_GET_FS:\n-\t\tret = put_user(tmp, arg2);\n+\t\tret = put_user(current->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)], arg2);\n \t\tbreak;\n \tcase ARCH_GET_GS:\n-\t\tret = put_user(tmp, arg2);\n+\t\tret = put_user(current->thread.regs.regs.gp[GS_BASE / sizeof(unsigned long)], arg2);\n \t\tbreak;\n \t}\n \n@@ -83,10 +47,10 @@ SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)\n \n void arch_switch_to(struct task_struct *to)\n {\n-\tif ((to->thread.arch.fs == 0) || (to->mm == NULL))\n-\t\treturn;\n-\n-\tarch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);\n+\t/*\n+\t * Nothing needs to be done on x86_64.\n+\t * The FS_BASE/GS_BASE registers are saved in the ptrace register set.\n+\t */\n }\n \n SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,\ndiff --git a/arch/x86/um/tls_64.c b/arch/x86/um/tls_64.c\nindex ebd3855d9b13..c51a613f6f5c 100644\n--- a/arch/x86/um/tls_64.c\n+++ b/arch/x86/um/tls_64.c\n@@ -12,7 +12,7 @@ int arch_set_tls(struct task_struct *t, unsigned long tls)\n \t * If CLONE_SETTLS is set, we need to save the thread id\n \t * so it can be set during context switches.\n \t */\n-\tt->thread.arch.fs = tls;\n+\tt->thread.regs.regs.gp[FS_BASE / sizeof(unsigned long)] = tls;\n \n \treturn 0;\n }\n", "prefixes": [ "v2", "11/28" ] }