From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b5-smtp.messagingengine.com (fout-b5-smtp.messagingengine.com [202.12.124.148]) (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 69E44346E6A for ; Fri, 27 Feb 2026 09:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.148 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772183161; cv=none; b=qcarhLspN2BIy+hMJrVJYfdKd6IKJr3bJmRUABKT7OSGVwDmImHATMm5+AxfxofG1ATz2oWSnwifp+jzTEAZRAgwgmmge8Qf6n0G0lPXI/V1a4dJopVdz5Nmgfsqe0lgc0RgZcvnuGVOv3dE94Y433DyfmeOwPTd5vxkiei9uaA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772183161; c=relaxed/simple; bh=7hj28TPPtALLPeIpuRdCU5v2A+whIiEF18i+L0wNUKA=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=g5iVcB+zhc5jqo6yVqGYf2wrcLZFLLWfybur5QEb7v514QkBcSO+fRqC0bvu+Cz1SwkXF/9Jn/CJt93kJldlQYXJCxL1OyDEBx8f8I+hDkxQiG4y/0dH77SlK2U6DuAXE1k4EP3wRc8YLtdSYaaXCe6dtSGSoeSc1od/aZvhLao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=bV8ljcB3; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=JoHtplEl; arc=none smtp.client-ip=202.12.124.148 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="bV8ljcB3"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="JoHtplEl" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id B97131D00214; Fri, 27 Feb 2026 04:05:59 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Fri, 27 Feb 2026 04:05:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1772183159; x=1772269559; bh=Tc4YCKeDyuZQPJ9005ZA2jKuhIVgP9U4FQ49NUwyCkM=; b= bV8ljcB3AqvbMXzjzJFPu9LTeptCg1nzNulPtlZe3IN6486cVNMGtm7KEPpoVS6s AHEMvT5nd/g5i/LggREaH4zk8eWLuDwrrFnf2XnAbsoMrlizCxOvYxCHOJAkZge3 Do7hkp9GPmrYIrP794EaZepbjM3sCXC+TGd9TaNSjPk4PPcYAUEPBlCjtivO9T+K Kx/3aiLE8h8RbelNq9YQAUIJynyecJWr/8sF5VT3Qu5r8QsNhVtrxKUDRFDI21BQ A4rFUPxewlX3/6kgyaRzHCXsYAnq/7o+9kj4tB+TmXO7Qvmr1qPZ4KneNn+Lh6yw Knymf67wmwzMMtzxQ/5wUw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1772183159; x= 1772269559; bh=Tc4YCKeDyuZQPJ9005ZA2jKuhIVgP9U4FQ49NUwyCkM=; b=J oHtplElfx1wvSZ2b6xPb15P/+LvbIE9HWUqg2Hr6dB4v96o4wiYAqplwE6e2P4ry 4Mi+pSRzt7m21hTr6w9EggfUXcnJiCZCsVA5RyuIYGXKEB59eh+GAVqQK2X5MYuC MbM39m1rEKBIO8ESA+Q4EnVHd2QRDjWmiLtWmPcHqwDlZLUPryQDUWBrD+eVgdxw 5YxvQkSS/+mebBFjPjgTaxJVrLNO8KbEYmlhNeglQ8CE9VnZsqTCOgej4nvGTXhY 1kMH2HPxu95JFcJn4LPxwmyOSbpP2lu6BFwTj5VESpwma/7Ic5ovg+kunVUDTrwl ZV64OhKhfQm0RGiN13Ijg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeekiedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefoggffhffvvefkjghfufgtgfesthhqre dtredtjeenucfhrhhomhepfdetrhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghr nhgusgdruggvqeenucggtffrrghtthgvrhhnpedvhfdvkeeuudevfffftefgvdevfedvle ehvddvgeejvdefhedtgeegveehfeeljeenucevlhhushhtvghrufhiiigvpedtnecurfgr rhgrmhepmhgrihhlfhhrohhmpegrrhhnugesrghrnhgusgdruggvpdhnsggprhgtphhtth hopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopeguvggvphgrrdhkvghrnhgv lhesghhmrghilhdrtghomhdprhgtphhtthhopehthhhomhgrshdrfigvihhsshhstghhuh hhsehlihhnuhhtrhhonhhigidruggvpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghl sehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 6148B70006D; Fri, 27 Feb 2026 04:05:59 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: A_S8qXcwy76B Date: Fri, 27 Feb 2026 10:05:25 +0100 From: "Arnd Bergmann" To: =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , "Deepa Dinamani" Cc: linux-kernel@vger.kernel.org Message-Id: In-Reply-To: <20260227-timespec-x32-v1-1-00b227168034@linutronix.de> References: <20260227-timespec-x32-v1-1-00b227168034@linutronix.de> Subject: Re: [PATCH] y2038: uapi: use 64-bit __kernel_old_timespec::tv_nsec on x32 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Feb 27, 2026, at 08:18, Thomas Wei=C3=9Fschuh wrote: > 'struct __kernel_old_timespec' represents the 'native' time ABI of the > kernel. On 32-bit systems it uses 32-bit fields and on 64-bit systems > it uses 64-bit fields. > However the x86 x32 ABI uses the 64-bit time ABI natively. > This is correctly handled for the 'tv_sec' fields, through the typedefs > of '__kernel_old_time_t' -> '__kernel_long_t' -> 'long long'. The same > treatment was missed for 'tv_nsec'. Not sure about this patch, the choice of 'long' was clearly deliberate here because that is what POSIX mandates for 'struct timespec', and what glibc uses as well. Any access to an actual userspec timespec is supposed to go through get_timespec64(), which handles the padding like this int get_timespec64(struct timespec64 *ts, const struct __kernel_timespec __user *uts) { struct __kernel_timespec kts; int ret; ret =3D copy_from_user(&kts, uts, sizeof(kts)); if (ret) return -EFAULT; ts->tv_sec =3D kts.tv_sec; /* Zero out the padding in compat mode */ if (in_compat_syscall()) kts.tv_nsec &=3D 0xFFFFFFFFUL; /* In 32-bit mode, this drops the padding */ ts->tv_nsec =3D kts.tv_nsec; return 0; } If there are any code paths that are missing this, they are likely also broken for all other compat tasks in the time64 syscalls > @@ -30,7 +30,7 @@ struct __kernel_old_timeval { >=20 > struct __kernel_old_timespec { > __kernel_old_time_t tv_sec; /* seconds */ > - long tv_nsec; /* nanoseconds */ > + __kernel_long_t tv_nsec; /* nanoseconds */ > }; I think the hidden padding is an actual problem here, but I would address that with extra padding, similar to what glibc has, e.g. struct __kernel_old_timespec { __kernel_old_time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ #if defined(__x86_64__) && defined(__ILP32__) long :32; /* pad to alignment */ #endif }; It may be better to duplicate the structure definition and keep the x32 hack in arch/x86/uapi/asm/posix_types.h, the same way we do for the sparc64 __kernel_old_timeval, which has a very similar issue. Arnd