Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5475853pxb; Mon, 7 Feb 2022 02:57:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNoXsQrrqadsCMWZxfawgFuS1uHUa/BZNRyGqhKZkTdd6DWQ3eO8JELhwXVit79tshohHk X-Received: by 2002:a05:6402:50d4:: with SMTP id h20mr13232551edb.90.1644231463875; Mon, 07 Feb 2022 02:57:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644231463; cv=none; d=google.com; s=arc-20160816; b=AxeDs90rXqPYOU8VuuLsfiTwrEM5CCbq5MRpTWCJ4LmSBNCtAchSYUG6w7LifUXIiT r88ER6e8Tsbh4LviWKxwAfsP9BY2+TJfsSzYmk49jBjnLi/gLYkeXqCfxf4DG3eZ005b 838u149mg3nPsMS6SWqxGONC9tKp2aq29aDjFqEtWfo/W+L32SLn8ZSlAEOLmxRN0C2r Gyt0LCEDoEFJ4K3+UzN+doUZjiv/w5Yf/OPjdsLeLWINry+mFhXTY2tH4BtZrzdJrS1B Iyr1znAXTGs9q5IhX1mvJoKAXFIB+A0ZPq6zl/xylf73+sg9kCO/AShK+9SmaCLawuUb diUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=lSf6rlv5YTtxyugVtc/cg07pk8VXyFLfTGMubGQ4FEk=; b=XViK+odlPRWZrllYjVSUgMzHmATkxgKl1ge4esojzLQOaaKQ8nHZPsjYjgQj6xvdId b3pDO68JD0GUIL++4x4uIy6JrIhFT/vYKAcjiRTCl1ypc5LXv4IOZxY5tXZu+Y0wEHUo HHiaOGOTRjgofMIHFcf34ZHffuhWo/9H4JPhwkPEZpyl18pCW5vWcGQ7sCyfBo/JivCX DzF24TZBIOgKH3kNCOprL3CN8z9EqNoxz4cJWORfOiIf8N2YgLB6uA75qfBDE9BGlXIa sm1ombCfM6zcxj1WmauS+smzGdD+6gnB4VTSLEsr2qNVxBCia/VXLvsJUvIUp3RgMww8 /rxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VypHDqB7; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id en20si2606009edb.445.2022.02.07.02.57.19; Mon, 07 Feb 2022 02:57:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VypHDqB7; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351820AbiBCOg2 (ORCPT + 99 others); Thu, 3 Feb 2022 09:36:28 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:53620 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351401AbiBCOdx (ORCPT ); Thu, 3 Feb 2022 09:33:53 -0500 Date: Thu, 03 Feb 2022 14:33:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1643898832; h=from:from:sender:sender:reply-to: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; bh=lSf6rlv5YTtxyugVtc/cg07pk8VXyFLfTGMubGQ4FEk=; b=VypHDqB7gElwSvCHZ2S14/9QY4LD++9r+bXWMpboG4WHGlFPoJ0qPH40jUqqNc/Lod/hfI QFN2S2EmSZDQX6XjoxADWy5rIoz49WHBJNVq4uphZbSUCsW1I/Kz1ArZoeSmR2Hs0dKQb5 Q66X+eXnaDncqVz4Qvh0Yoz1S/0M4Ckh4PQ1DHBsXELg/yHm4FTa6/lT/Ns2oncabi+61J q7Jc2VlrdogxCAk7HLiZhex5B++HLHSWtv5sh9RMuhg5xpXJuR/1cuICKHI94gFzFGj2Kg bVrZda/tYHD64Ef6Hze4/nn+Pz2JU9MX1y7d1q/QzSkZTLHSqcvNh0Y1UKBXMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1643898832; h=from:from:sender:sender:reply-to: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; bh=lSf6rlv5YTtxyugVtc/cg07pk8VXyFLfTGMubGQ4FEk=; b=NNHPUW+fR7ecl1hdBuBTXRTExrSofR/AeS+64/AG8XK6FjiRpp4tb8uOPv/4ncZwBScMw1 AeeFtYoVP4ifOjAA== From: "tip-bot2 for Mathieu Desnoyers" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] rseq: Remove broken uapi field layout on 32-bit little endian Cc: Mathieu Desnoyers , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220127152720.25898-1-mathieu.desnoyers@efficios.com> References: <20220127152720.25898-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Message-ID: <164389883175.16921.4926542633767739124.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: bfdf4e6208051ed7165b2e92035b4bf11f43eb63 Gitweb: https://git.kernel.org/tip/bfdf4e6208051ed7165b2e92035b4bf11f43eb63 Author: Mathieu Desnoyers AuthorDate: Thu, 27 Jan 2022 10:27:20 -05:00 Committer: Peter Zijlstra CommitterDate: Wed, 02 Feb 2022 13:11:34 +01:00 rseq: Remove broken uapi field layout on 32-bit little endian The rseq rseq_cs.ptr.{ptr32,padding} uapi endianness handling is entirely wrong on 32-bit little endian: a preprocessor logic mistake wrongly uses the big endian field layout on 32-bit little endian architectures. Fortunately, those ptr32 accessors were never used within the kernel, and only meant as a convenience for user-space. Remove those and replace the whole rseq_cs union by a __u64 type, as this is the only thing really needed to express the ABI. Document how 32-bit architectures are meant to interact with this field. Fixes: ec9c82e03a74 ("rseq: uapi: Declare rseq_cs field as union, update includes") Signed-off-by: Mathieu Desnoyers Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220127152720.25898-1-mathieu.desnoyers@efficios.com --- include/uapi/linux/rseq.h | 20 ++++---------------- kernel/rseq.c | 8 ++++---- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/include/uapi/linux/rseq.h b/include/uapi/linux/rseq.h index 9a402fd..77ee207 100644 --- a/include/uapi/linux/rseq.h +++ b/include/uapi/linux/rseq.h @@ -105,23 +105,11 @@ struct rseq { * Read and set by the kernel. Set by user-space with single-copy * atomicity semantics. This field should only be updated by the * thread which registered this data structure. Aligned on 64-bit. + * + * 32-bit architectures should update the low order bits of the + * rseq_cs field, leaving the high order bits initialized to 0. */ - union { - __u64 ptr64; -#ifdef __LP64__ - __u64 ptr; -#else - struct { -#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(__BIG_ENDIAN) - __u32 padding; /* Initialized to zero. */ - __u32 ptr32; -#else /* LITTLE */ - __u32 ptr32; - __u32 padding; /* Initialized to zero. */ -#endif /* ENDIAN */ - } ptr; -#endif - } rseq_cs; + __u64 rseq_cs; /* * Restartable sequences flags field. diff --git a/kernel/rseq.c b/kernel/rseq.c index 6d45ac3..97ac20b 100644 --- a/kernel/rseq.c +++ b/kernel/rseq.c @@ -128,10 +128,10 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs) int ret; #ifdef CONFIG_64BIT - if (get_user(ptr, &t->rseq->rseq_cs.ptr64)) + if (get_user(ptr, &t->rseq->rseq_cs)) return -EFAULT; #else - if (copy_from_user(&ptr, &t->rseq->rseq_cs.ptr64, sizeof(ptr))) + if (copy_from_user(&ptr, &t->rseq->rseq_cs, sizeof(ptr))) return -EFAULT; #endif if (!ptr) { @@ -217,9 +217,9 @@ static int clear_rseq_cs(struct task_struct *t) * Set rseq_cs to NULL. */ #ifdef CONFIG_64BIT - return put_user(0UL, &t->rseq->rseq_cs.ptr64); + return put_user(0UL, &t->rseq->rseq_cs); #else - if (clear_user(&t->rseq->rseq_cs.ptr64, sizeof(t->rseq->rseq_cs.ptr64))) + if (clear_user(&t->rseq->rseq_cs, sizeof(t->rseq->rseq_cs))) return -EFAULT; return 0; #endif