From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9BE7289832; Mon, 5 May 2025 23:14:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746486862; cv=none; b=THElrhW6oAJQ4OGH0LjbOiokAkgyR9AUOFSCiLeI9e0FoSdtyLOMbT+OKnK8t9LjDn7eKZQG9N4s3G5tB3K+hFS2TgUydc8H0MfEvf1a9jn0n50B4FYOSc2TiQzA5i0gAL0cH1E9DCTt3tgrKhP3o6EWgZl5o9Dlmmk8YTta1E8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746486862; c=relaxed/simple; bh=o6vPQm8ORAMEIjP7fhptjMtwSNq9nMRVlWGY99NWjZw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QtjxyEitVYT5nVXt4RAptYd7V1x72bQx38cy1HoyaaT3NVn8a5cGYfAdiy68P3UcqmgZFvyNFA8OSO5k7WkXPo7u9k65YK5L33MDuWP4Rogmidb7xXOgrbtoLTWAvNO5C50LjCSECJlbydAhtYU1ubuXZ496bfAgYKEbvxRaTnM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=U55h8hDe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="U55h8hDe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48837C4CEE4; Mon, 5 May 2025 23:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746486862; bh=o6vPQm8ORAMEIjP7fhptjMtwSNq9nMRVlWGY99NWjZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U55h8hDeHjc+mM7wHRvh/7REqfjnz8BOK9ZzwcPoILbgqSzg85Omgx3lamDwou017 ad4vNvbrMoG4rMfVdSEQxnLDaTV//0vgl1SsF6uteiG4tQUXWFRdKO4vXloBghgGN7 UPrloEz9S0J5eYvXjhvB11az2Axkya+3MnzQXUQXTA2zDEWBNoYTRhuSGWlEHvIJEg SAexkoOSabmPFXwrhNTdp9TWXNieBgO6Lt6CRTeSLs5UrZBUHMoBvmBTDg4F4O9hwe ntkd0pssFLVePBKj9T1VOWAE2ZcakTqeOWJ3oMNeTsFJr2mh9Y7TTHndEZHBDRTqfK SksTvQ/fLFetg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Benjamin Berg , Johannes Berg , Sasha Levin , richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, linux-um@lists.infradead.org Subject: [PATCH AUTOSEL 5.15 031/153] um: Store full CSGSFS and SS register from mcontext Date: Mon, 5 May 2025 19:11:18 -0400 Message-Id: <20250505231320.2695319-31-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250505231320.2695319-1-sashal@kernel.org> References: <20250505231320.2695319-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.181 Content-Transfer-Encoding: 8bit From: Benjamin Berg [ Upstream commit cef721e0d53d2b64f2ba177c63a0dfdd7c0daf17 ] Doing this allows using registers as retrieved from an mcontext to be pushed to a process using PTRACE_SETREGS. It is not entirely clear to me why CSGSFS was masked. Doing so creates issues when using the mcontext as process state in seccomp and simply copying the register appears to work perfectly fine for ptrace. Signed-off-by: Benjamin Berg Link: https://patch.msgid.link/20250224181827.647129-2-benjamin@sipsolutions.net Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- arch/x86/um/os-Linux/mcontext.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/um/os-Linux/mcontext.c b/arch/x86/um/os-Linux/mcontext.c index 49c3744cac371..81b9d1f9f4e68 100644 --- a/arch/x86/um/os-Linux/mcontext.c +++ b/arch/x86/um/os-Linux/mcontext.c @@ -26,7 +26,6 @@ void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc) COPY(RIP); COPY2(EFLAGS, EFL); COPY2(CS, CSGSFS); - regs->gp[CS / sizeof(unsigned long)] &= 0xffff; - regs->gp[CS / sizeof(unsigned long)] |= 3; + regs->gp[SS / sizeof(unsigned long)] = mc->gregs[REG_CSGSFS] >> 48; #endif } -- 2.39.5