* [PATCH 01/23] y2038: remove CONFIG_64BIT_TIME
2019-11-08 21:02 [PATCH 00/23] y2038 cleanups Arnd Bergmann
@ 2019-11-08 21:07 ` Arnd Bergmann
2019-11-20 22:28 ` [Y2038] " Ben Hutchings
2019-11-08 21:12 ` [PATCH 13/23] y2038: socket: remove timespec reference in timestamping Arnd Bergmann
2019-11-13 21:40 ` [PATCH 00/23] y2038 cleanups Arnd Bergmann
2 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2019-11-08 21:07 UTC (permalink / raw)
To: y2038, Thomas Gleixner, John Stultz
Cc: linux-kernel, Arnd Bergmann, Alexander Viro, Benjamin LaHaise,
Stephen Boyd, David S. Miller, linux-fsdevel, linux-aio, netdev
The CONFIG_64BIT_TIME option is defined on all architectures, and can
be removed for simplicity now.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
arch/Kconfig | 8 --------
fs/aio.c | 2 +-
ipc/syscall.c | 2 +-
kernel/time/hrtimer.c | 2 +-
kernel/time/time.c | 4 ++--
net/socket.c | 2 +-
6 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 5f8a5d84dbbe..0e1fded2940e 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -796,14 +796,6 @@ config OLD_SIGACTION
config COMPAT_OLD_SIGACTION
bool
-config 64BIT_TIME
- def_bool y
- help
- This should be selected by all architectures that need to support
- new system calls with a 64-bit time_t. This is relevant on all 32-bit
- architectures, and 64-bit architectures as part of compat syscall
- handling.
-
config COMPAT_32BIT_TIME
def_bool !64BIT || COMPAT
help
diff --git a/fs/aio.c b/fs/aio.c
index 01e0fb9ae45a..447e3a0c572c 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -2056,7 +2056,7 @@ static long do_io_getevents(aio_context_t ctx_id,
* specifies an infinite timeout. Note that the timeout pointed to by
* timeout is relative. Will fail with -ENOSYS if not implemented.
*/
-#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
+#ifdef CONFIG_64BIT
SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id,
long, min_nr,
diff --git a/ipc/syscall.c b/ipc/syscall.c
index 581bdff4e7c5..dfb0e988d542 100644
--- a/ipc/syscall.c
+++ b/ipc/syscall.c
@@ -30,7 +30,7 @@ int ksys_ipc(unsigned int call, int first, unsigned long second,
return ksys_semtimedop(first, (struct sembuf __user *)ptr,
second, NULL);
case SEMTIMEDOP:
- if (IS_ENABLED(CONFIG_64BIT) || !IS_ENABLED(CONFIG_64BIT_TIME))
+ if (IS_ENABLED(CONFIG_64BIT))
return ksys_semtimedop(first, ptr, second,
(const struct __kernel_timespec __user *)fifth);
else if (IS_ENABLED(CONFIG_COMPAT_32BIT_TIME))
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 65605530ee34..9e20873148c6 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -1940,7 +1940,7 @@ long hrtimer_nanosleep(const struct timespec64 *rqtp,
return ret;
}
-#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
+#ifdef CONFIG_64BIT
SYSCALL_DEFINE2(nanosleep, struct __kernel_timespec __user *, rqtp,
struct __kernel_timespec __user *, rmtp)
diff --git a/kernel/time/time.c b/kernel/time/time.c
index 45a358953f09..ddbddf504c23 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -267,7 +267,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv,
}
#endif
-#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
+#ifdef CONFIG_64BIT
SYSCALL_DEFINE1(adjtimex, struct __kernel_timex __user *, txc_p)
{
struct __kernel_timex txc; /* Local copy of parameter */
@@ -884,7 +884,7 @@ int get_timespec64(struct timespec64 *ts,
ts->tv_sec = kts.tv_sec;
/* Zero out the padding for 32 bit systems or in compat mode */
- if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall())
+ if (in_compat_syscall())
kts.tv_nsec &= 0xFFFFFFFFUL;
ts->tv_nsec = kts.tv_nsec;
diff --git a/net/socket.c b/net/socket.c
index 6a9ab7a8b1d2..98f6544b0096 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2833,7 +2833,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
a[2], true);
break;
case SYS_RECVMMSG:
- if (IS_ENABLED(CONFIG_64BIT) || !IS_ENABLED(CONFIG_64BIT_TIME))
+ if (IS_ENABLED(CONFIG_64BIT))
err = __sys_recvmmsg(a0, (struct mmsghdr __user *)a1,
a[2], a[3],
(struct __kernel_timespec __user *)a[4],
--
2.20.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Y2038] [PATCH 01/23] y2038: remove CONFIG_64BIT_TIME
2019-11-08 21:07 ` [PATCH 01/23] y2038: remove CONFIG_64BIT_TIME Arnd Bergmann
@ 2019-11-20 22:28 ` Ben Hutchings
2019-11-20 22:58 ` Dmitry Safonov
0 siblings, 1 reply; 8+ messages in thread
From: Ben Hutchings @ 2019-11-20 22:28 UTC (permalink / raw)
To: Arnd Bergmann, y2038, Thomas Gleixner, John Stultz
Cc: linux-aio, Stephen Boyd, netdev, linux-kernel, Benjamin LaHaise,
Alexander Viro, linux-fsdevel, David S. Miller, Dmitry Safonov
On Fri, 2019-11-08 at 22:07 +0100, Arnd Bergmann wrote:
[...]
> --- a/kernel/time/time.c
> +++ b/kernel/time/time.c
> @@ -267,7 +267,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv,
> }
> #endif
>
> -#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
> +#ifdef CONFIG_64BIT
> SYSCALL_DEFINE1(adjtimex, struct __kernel_timex __user *, txc_p)
> {
> struct __kernel_timex txc; /* Local copy of parameter */
> @@ -884,7 +884,7 @@ int get_timespec64(struct timespec64 *ts,
> ts->tv_sec = kts.tv_sec;
>
> /* Zero out the padding for 32 bit systems or in compat mode */
> - if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall())
> + if (in_compat_syscall())
> kts.tv_nsec &= 0xFFFFFFFFUL;
>
> ts->tv_nsec = kts.tv_nsec;
[...]
It's not a problem with this patch, but I noticed that this condition
doesn't match what the comment says. It looks like it was broken by:
commit 98f76206b33504b934209d16196477dfa519a807
Author: Dmitry Safonov <dima@arista.com>
Date: Fri Oct 12 14:42:53 2018 +0100
compat: Cleanup in_compat_syscall() callers
Ben.
--
Ben Hutchings, Software Developer Codethink Ltd
https://www.codethink.co.uk/ Dale House, 35 Dale Street
Manchester, M1 2HF, United Kingdom
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Y2038] [PATCH 01/23] y2038: remove CONFIG_64BIT_TIME
2019-11-20 22:28 ` [Y2038] " Ben Hutchings
@ 2019-11-20 22:58 ` Dmitry Safonov
0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Safonov @ 2019-11-20 22:58 UTC (permalink / raw)
To: Ben Hutchings, Arnd Bergmann, y2038, Thomas Gleixner, John Stultz
Cc: linux-aio, Stephen Boyd, netdev, linux-kernel, Benjamin LaHaise,
Alexander Viro, linux-fsdevel, David S. Miller
On 11/20/19 10:28 PM, Ben Hutchings wrote:
> On Fri, 2019-11-08 at 22:07 +0100, Arnd Bergmann wrote:
> [...]
>> --- a/kernel/time/time.c
>> +++ b/kernel/time/time.c
>> @@ -267,7 +267,7 @@ COMPAT_SYSCALL_DEFINE2(settimeofday, struct old_timeval32 __user *, tv,
>> }
>> #endif
>>
>> -#if !defined(CONFIG_64BIT_TIME) || defined(CONFIG_64BIT)
>> +#ifdef CONFIG_64BIT
>> SYSCALL_DEFINE1(adjtimex, struct __kernel_timex __user *, txc_p)
>> {
>> struct __kernel_timex txc; /* Local copy of parameter */
>> @@ -884,7 +884,7 @@ int get_timespec64(struct timespec64 *ts,
>> ts->tv_sec = kts.tv_sec;
>>
>> /* Zero out the padding for 32 bit systems or in compat mode */
>> - if (IS_ENABLED(CONFIG_64BIT_TIME) && in_compat_syscall())
>> + if (in_compat_syscall())
>> kts.tv_nsec &= 0xFFFFFFFFUL;
>>
>> ts->tv_nsec = kts.tv_nsec;
> [...]
>
> It's not a problem with this patch, but I noticed that this condition
> doesn't match what the comment says. It looks like it was broken by:
>
> commit 98f76206b33504b934209d16196477dfa519a807
> Author: Dmitry Safonov <dima@arista.com>
> Date: Fri Oct 12 14:42:53 2018 +0100
>
> compat: Cleanup in_compat_syscall() callers
>
Ugh, you right. I've failed to read the condition and thought it's
related to CONFIG_COMPAT :(
I'll send a fix shortly, thanks for spotting this!
--
Dmitry
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 13/23] y2038: socket: remove timespec reference in timestamping
2019-11-08 21:02 [PATCH 00/23] y2038 cleanups Arnd Bergmann
2019-11-08 21:07 ` [PATCH 01/23] y2038: remove CONFIG_64BIT_TIME Arnd Bergmann
@ 2019-11-08 21:12 ` Arnd Bergmann
2019-11-09 19:03 ` Deepa Dinamani
2019-11-11 20:24 ` Arnd Bergmann
2019-11-13 21:40 ` [PATCH 00/23] y2038 cleanups Arnd Bergmann
2 siblings, 2 replies; 8+ messages in thread
From: Arnd Bergmann @ 2019-11-08 21:12 UTC (permalink / raw)
To: y2038, David S. Miller
Cc: linux-kernel, Arnd Bergmann, Deepa Dinamani, Willem de Bruijn,
Thomas Gleixner, netdev
In order to remove the 'struct timespec' definition and the
timespec64_to_timespec() helper function, change over the in-kernel
definition of 'struct scm_timestamping' to use the __kernel_old_timespec
replacement and open-code the assignment.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/uapi/linux/errqueue.h | 7 +++++++
net/core/scm.c | 6 ++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h
index 28491dac074b..0cca19670fd2 100644
--- a/include/uapi/linux/errqueue.h
+++ b/include/uapi/linux/errqueue.h
@@ -37,9 +37,16 @@ struct sock_extended_err {
* The timestamping interfaces SO_TIMESTAMPING, MSG_TSTAMP_*
* communicate network timestamps by passing this struct in a cmsg with
* recvmsg(). See Documentation/networking/timestamping.txt for details.
+ * User space sees a timespec definition that matches either
+ * __kernel_timespec or __kernel_old_timespec, in the kernel we
+ * require two structure definitions to provide both.
*/
struct scm_timestamping {
+#ifdef __KERNEL__
+ struct __kernel_old_timespec ts[3];
+#else
struct timespec ts[3];
+#endif
};
struct scm_timestamping64 {
diff --git a/net/core/scm.c b/net/core/scm.c
index 31a38239c92f..dc6fed1f221c 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -268,8 +268,10 @@ void put_cmsg_scm_timestamping(struct msghdr *msg, struct scm_timestamping_inter
struct scm_timestamping tss;
int i;
- for (i = 0; i < ARRAY_SIZE(tss.ts); i++)
- tss.ts[i] = timespec64_to_timespec(tss_internal->ts[i]);
+ for (i = 0; i < ARRAY_SIZE(tss.ts); i++) {
+ tss.ts[i].tv_sec = tss_internal->ts[i].tv_sec;
+ tss.ts[i].tv_nsec = tss_internal->ts[i].tv_nsec;
+ }
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMPING_OLD, sizeof(tss), &tss);
}
--
2.20.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 13/23] y2038: socket: remove timespec reference in timestamping
2019-11-08 21:12 ` [PATCH 13/23] y2038: socket: remove timespec reference in timestamping Arnd Bergmann
@ 2019-11-09 19:03 ` Deepa Dinamani
2019-11-11 20:24 ` Arnd Bergmann
1 sibling, 0 replies; 8+ messages in thread
From: Deepa Dinamani @ 2019-11-09 19:03 UTC (permalink / raw)
To: Arnd Bergmann
Cc: y2038 Mailman List, David S. Miller, Linux Kernel Mailing List,
Willem de Bruijn, Thomas Gleixner,
Linux Network Devel Mailing List
Acked-by: Deepa Dinamani <deepa.kernel@gmail.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 13/23] y2038: socket: remove timespec reference in timestamping
2019-11-08 21:12 ` [PATCH 13/23] y2038: socket: remove timespec reference in timestamping Arnd Bergmann
2019-11-09 19:03 ` Deepa Dinamani
@ 2019-11-11 20:24 ` Arnd Bergmann
1 sibling, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2019-11-11 20:24 UTC (permalink / raw)
To: y2038 Mailman List, David S. Miller
Cc: linux-kernel, Deepa Dinamani, Willem de Bruijn, Thomas Gleixner,
Networking
On Fri, Nov 8, 2019 at 10:15 PM Arnd Bergmann <arnd@arndb.de> wrote:
> diff --git a/include/uapi/linux/errqueue.h b/include/uapi/linux/errqueue.h
> index 28491dac074b..0cca19670fd2 100644
> --- a/include/uapi/linux/errqueue.h
> +++ b/include/uapi/linux/errqueue.h
> @@ -37,9 +37,16 @@ struct sock_extended_err {
> * The timestamping interfaces SO_TIMESTAMPING, MSG_TSTAMP_*
> * communicate network timestamps by passing this struct in a cmsg with
> * recvmsg(). See Documentation/networking/timestamping.txt for details.
> + * User space sees a timespec definition that matches either
> + * __kernel_timespec or __kernel_old_timespec, in the kernel we
> + * require two structure definitions to provide both.
> */
> struct scm_timestamping {
> +#ifdef __KERNEL__
> + struct __kernel_old_timespec ts[3];
> +#else
> struct timespec ts[3];
> +#endif
> };
The kbuild bot pointed out that the way I sent this series, the use of
__kernel_old_timespec
causes a build failure, because I introduce this in a separate submission. I'm
moving this patch over to the other series, and changing the subject to
y2038: socket: use __kernel_old_timespec instead of timespec
With the expectation of merging it along with the other core patches.
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 00/23] y2038 cleanups
2019-11-08 21:02 [PATCH 00/23] y2038 cleanups Arnd Bergmann
2019-11-08 21:07 ` [PATCH 01/23] y2038: remove CONFIG_64BIT_TIME Arnd Bergmann
2019-11-08 21:12 ` [PATCH 13/23] y2038: socket: remove timespec reference in timestamping Arnd Bergmann
@ 2019-11-13 21:40 ` Arnd Bergmann
2 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2019-11-13 21:40 UTC (permalink / raw)
To: y2038 Mailman List
Cc: linux-kernel, Richard Henderson, Tony Luck, Paul Burton,
Greentime Hu, Helge Deller, Michael Ellerman, David Miller,
Thomas Gleixner, the arch/x86 maintainers, Jeff Dike,
Richard Weinberger, Al Viro, Benjamin LaHaise, John Stultz,
Stephen Boyd, Steven Rostedt, Vincenzo Frascino, Paul Moore,
Stephen Smalley, Eric Paris, Peter Zijlstra, Will Deacon,
Deepa Dinamani, Christian Brauner, Heiko Carstens,
christophe leroy, Eric W . Biederman, alpha, linux-ia64,
linux-mips, Parisc List, linuxppc-dev, sparclinux, linux-um,
Linux FS-devel Mailing List, linux-aio, Linux API, linux-arch,
Networking, SElinux list
On Fri, Nov 8, 2019 at 10:04 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> This is a series of cleanups for the y2038 work, mostly intended
> for namespace cleaning: the kernel defines the traditional
> time_t, timeval and timespec types that often lead to y2038-unsafe
> code. Even though the unsafe usage is mostly gone from the kernel,
> having the types and associated functions around means that we
> can still grow new users, and that we may be missing conversions
> to safe types that actually matter.
>
> As there is no rush on any of these patches, I would either
> queue them up in linux-next through my y2038 branch, or
> Thomas could add them to the tip tree if he wants.
>
> As mentioned in another series, this is part of a larger
> effort to fix all the remaining bits and pieces that are
> not completed yet from the y2038 conversion, and the full
> set can be found at:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/log/?h=y2038-endgame
>
> Maintainers, please review and provide Acks.
>
> Let me know if you have any opinion on whether we should do
> the include last two patches of this series or not.
>
> Arnd
>
> Arnd Bergmann (23):
> y2038: remove CONFIG_64BIT_TIME
> y2038: add __kernel_old_timespec and __kernel_old_time_t
> y2038: vdso: change timeval to __kernel_old_timeval
> y2038: vdso: change timespec to __kernel_old_timespec
> y2038: vdso: change time_t to __kernel_old_time_t
> y2038: vdso: nds32: open-code timespec_add_ns()
> y2038: vdso: powerpc: avoid timespec references
> y2038: ipc: remove __kernel_time_t reference from headers
> y2038: stat: avoid 'time_t' in 'struct stat'
> y2038: uapi: change __kernel_time_t to __kernel_old_time_t
> y2038: rusage: use __kernel_old_timeval
> y2038: syscalls: change remaining timeval to __kernel_old_timeval
> y2038: socket: remove timespec reference in timestamping
> y2038: make ns_to_compat_timeval use __kernel_old_timeval
> y2038: elfcore: Use __kernel_old_timeval for process times
> y2038: timerfd: Use timespec64 internally
> y2038: time: avoid timespec usage in settimeofday()
> y2038: itimer: compat handling to itimer.c
> y2038: use compat_{get,set}_itimer on alpha
> y2038: move itimer reset into itimer.c
> y2038: itimer: change implementation to timespec64
> [RFC] y2038: itimer: use ktime_t internally
> y2038: allow disabling time32 system calls
I've dropped the "[RFC] y2038: itimer: use ktime_t internally" patch
for the moment,
and added two other patches from other series:
y2038: remove CONFIG_64BIT_TIME
y2038: socket: use __kernel_old_timespec instead of timespec
Tentatively pushed out the patches with the Acks I have received so
far to my y2038 branch on git.kernel.org so it gets included in linux-next.
If I hear no complaints, I'll send a pull request for the merge window,
along with the compat-ioctl series I have already queued up in the same
branch.
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread