You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new to cpython and curious in having a look at this. I've managed to build cpython and ssl module on an i686 virtual machine (debian 11, linux kernel 5.10).
Could you clarify the following step a bit further? RFS built with "-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64" flags
I'm not sure if it's just python that needs to be built with these options (in make file CFLAGS or CPPFLAGS?), or both the kernel and user space binaries (i.e everything)? At present, I'm not able to set a system date later than 2038, nor using python datetime module in my 32 bit build:
tabland@debian:/opt/python/cpython$ sudo date --set "7 Apr 2039"
date: invalid date '7 Apr 2039'
tabland@debian:/opt/python/cpython$ ./python
>>> import datetime
>>> datetime.datetime.fromtimestamp(75 * 365 * 24 * 60 * 60)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: timestamp out of range for platform time_t
You have to use a 64 bits time ready libc (glibc >= 2.35, muslc, ...).
And yes, you have to rebuild all your userspace with "-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64" flags.
You also have to take care about your filesystem.
For example, with ext4, you need inode size >= 256 bytes.
Output of ./configure shows that a long is 4 bytes on i686, and 8 bytes on x64. The SSL_SESSION_get_time() function is part of the OpenSSL API, and the datatype is defined as long instead of time_t:
I'll try and draft a PR against the OpenSSL project soon and test it against this issue. The cpython fix for this issue will be dependant on the OpenSSL fix. As the fix for this issue will most likely extend their API, I'll probably have to add logic for cpython to fall back to the existing and older non-Y2038 compatible OpenSSL APIs where the extended functions using more appropriate data types are not available.
Potentially a slow-burner as the existing commentary in the associated openssl issue (openssl/openssl#16726) suggests that other parts of the library may also be affected by Y2038, which will also need to be discovered and patched (or proven to not be required).
I'll try and draft a better python patch soon, a rudimentary one for Yocto Kirkstone is available here: TabLand/poky@68e4af2
openssl 3.3.0 has been released. So now everything is ready to fix this in python (should be easy, use the new function subject to openssl version being at least 3.3.0).
This sounds like an issue on systems that force 32-bit time, where the final second that can be represented in 32 bits falls on January 19, 2038 as the initial second would have been on the beginning of January 1, 1970.
I understand that OpenSSL 3.3.0 is now available. However, many distributions of Linux have not yet packaged this new version of the software, so assuming you are on Ubuntu 22.04.1 LTS, you should expect to have OpenSSL version 3.0.2 installed on your system.
This sounds like an issue on systems that force 32-bit time, where the final second that can be represented in 32 bits falls on January 19, 2038 as the initial second would have been on the beginning of January 1, 1970.
This is not the case. The issue occurs on 32 bit systems with 64 bit time as well, and was traced to openssl incorrectly using long type for time in one of its public APIs.
I understand that OpenSSL 3.3.0 is now available. However, many distributions of Linux have not yet packaged this new version of the software, so assuming you are on Ubuntu 22.04.1 LTS, you should expect to have OpenSSL version 3.0.2 installed on your system.
Which is fine. Any prospective fix would be conditional on the openssl version, and remain compatible with older versions as well. There's a way to check what openssl version is used at build time.
The PR is merged.
The reproducer listed here is too complicated; see #107562 for that.
(You can view #107562 as either a follow-up or a duplicate; either way, this issue should be closed.)
Activity
sobolevn commentedon Feb 9, 2023
We have plenty of time to fix this one! (joking, sorry) 😆
TabLand commentedon Apr 7, 2023
Hi @blemouzy,
I'm new to cpython and curious in having a look at this. I've managed to build cpython and ssl module on an i686 virtual machine (debian 11, linux kernel 5.10).
Could you clarify the following step a bit further?
RFS built with "-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64" flagsI'm not sure if it's just python that needs to be built with these options (in make file CFLAGS or CPPFLAGS?), or both the kernel and user space binaries (i.e everything)? At present, I'm not able to set a system date later than 2038, nor using python datetime module in my 32 bit build:
blemouzy commentedon Apr 11, 2023
Hi,
Linux kernel supports 64 bits time syscalls since 5.1 (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=48166e6ea47d23984f0b481ca199250e1ce0730a) and is supposed to be fully usable since 5.6. So you have nothing to do with your current version.
You have to use a 64 bits time ready libc (glibc >= 2.35, muslc, ...).
And yes, you have to rebuild all your userspace with "-D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64" flags.
You also have to take care about your filesystem.
For example, with ext4, you need inode size >= 256 bytes.
You can, for example, find more information here: https://sourceware.org/glibc/wiki/Y2038ProofnessDesign
TabLand commentedon May 2, 2023
Hello again,
Good news. I've managed to reproduce this issue after building 32-bit Linux From Scratch using the 64-bit time flags you mentioned:
Issues encountered with other projects:
binutils-2.40does not compile with 64-bit time flagsp11-kit-0.24.1build withmeson-1.1.0andpython-3.11.2runs into a "value too large for defined" data type error inmesonbuild/msetup.pyI'll aim to inform relevant project's maintainers on the above 2x
TabLand commentedon May 10, 2023
I believe I've found the root cause of the issue here:
cpython/Modules/_ssl.c
Lines 5004 to 5007 in a33ce66
Output of
./configureshows that a long is 4 bytes on i686, and 8 bytes on x64. TheSSL_SESSION_get_time()function is part of the OpenSSL API, and the datatype is defined aslonginstead oftime_t:https://www.openssl.org/docs/manmaster/man3/SSL_SESSION_get_time.html
The OpenSSL team are aware of this:
openssl/openssl#16726
I'll try and draft a PR against the OpenSSL project soon and test it against this issue. The cpython fix for this issue will be dependant on the OpenSSL fix. As the fix for this issue will most likely extend their API, I'll probably have to add logic for cpython to fall back to the existing and older non-Y2038 compatible OpenSSL APIs where the extended functions using more appropriate data types are not available.
TabLand commentedon Jun 14, 2023
Hi Team,
I've just submitted the following draft PR to openssl:
openssl/openssl#21206
Potentially a slow-burner as the existing commentary in the associated openssl issue (openssl/openssl#16726) suggests that other parts of the library may also be affected by Y2038, which will also need to be discovered and patched (or proven to not be required).
I'll try and draft a better python patch soon, a rudimentary one for Yocto Kirkstone is available here:
TabLand/poky@68e4af2
kanavin commentedon Feb 21, 2024
The openssl fix has just landed and will be released in 3.3.0:
openssl/openssl@ffc853b
kanavin commentedon Apr 26, 2024
openssl 3.3.0 has been released. So now everything is ready to fix this in python (should be easy, use the new function subject to openssl version being at least 3.3.0).
novaTopFlex commentedon Apr 28, 2024
This sounds like an issue on systems that force 32-bit time, where the final second that can be represented in 32 bits falls on January 19, 2038 as the initial second would have been on the beginning of January 1, 1970.
novaTopFlex commentedon Apr 28, 2024
I understand that OpenSSL 3.3.0 is now available. However, many distributions of Linux have not yet packaged this new version of the software, so assuming you are on Ubuntu 22.04.1 LTS, you should expect to have OpenSSL version 3.0.2 installed on your system.
kanavin commentedon Apr 29, 2024
This is not the case. The issue occurs on 32 bit systems with 64 bit time as well, and was traced to openssl incorrectly using long type for time in one of its public APIs.
kanavin commentedon Apr 29, 2024
Which is fine. Any prospective fix would be conditional on the openssl version, and remain compatible with older versions as well. There's a way to check what openssl version is used at build time.
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…
gh-101732: Modules/_ssl.c: use Y2038 compatible openssl function when…
encukou commentedon May 6, 2024
The PR is merged.
The reproducer listed here is too complicated; see #107562 for that.
(You can view #107562 as either a follow-up or a duplicate; either way, this issue should be closed.)
pythongh-101732: Modules/_ssl.c: use Y2038 compatible openssl functio…