From: Satadru Pramanik <satadru@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: Fwd: [musl] Re: musl getaddr info breakage on older kernels
Date: Thu, 17 Feb 2022 20:25:01 -0500 [thread overview]
Message-ID: <CAFrh3J9--m0jur1AEFoQ2QpmJTpcsFNA_03nHr1+3B1xm0pOFw@mail.gmail.com> (raw)
In-Reply-To: <20220217224845.GU7074@brightrain.aerifal.cx>
[-- Attachment #1.1: Type: text/plain, Size: 3157 bytes --]
I have attached the working patch I have ended up using, which has added
only a definition for ENOSYS.
Thanks again. It's nice to be offering software for these machines with
working, current libc. :)
Satadru
On Thu, Feb 17, 2022 at 5:48 PM Rich Felker <dalias@libc.org> wrote:
> On Thu, Feb 17, 2022 at 04:43:51PM -0500, Satadru Pramanik wrote:
> > > issues in userspace to maintain some functionality for any users who
> may
> > > > still be using the device.
> > > >
> > > > The simplest workaround possible would be ideal.
> > >
> > > If you're shipping binaries specifically for these devices, the
> > > simplest fix is just to emulate the failure that should happen in the
> > > kernel in userspace, using the attached patch. DO NOT deploy this
> > > patch in binaries meant to be used on modern systems, since they will
> > > break when Y2038 rolls around. (Your old Chromebooks will break then
> > > too.)
> > >
> > I'll let the next generation of preservationists worry about the Y2038
> > issues. Thanks for the patch. I'll build that now with the
> >
> https://git.musl-libc.org/cgit/musl/patch/?id=c2feda4e2ea61f4da73f2f38b2be5e327a7d1a91
> > reversal patch for the i686 machines, and see if that fixes the issue. If
>
> That reversal should no longer be needed with the other patch, which
> is a much bigger hammer. Reversing that just got rid of using the new
> socket-related syscalls; the new hack patch gets rid of using all new
> syscalls.
>
> > so, we can consider the matter closed, unless you want to suggest a
> > modification of the syscall patch to handle older working kernels which
> > might avoid the need for the patch when used with older systems.
>
> The patch is fine for older broken or older working systems. It just
> suppresses the ability to use any syscall added after Linux 3.8, so
> it's a bad idea to use on *newer* systems.
>
> > > It is interesting though
> > > > that the sample program works fine when built against near-stock
> glibc
> > > > 2.23, no?
> > >
> > > No. If your kernel has a bug that makes something behave wildly wrong,
> > > whether you do or don't see that as visible breakage with a particular
> > > piece of software is not particularly interesting.
> > >
> > > I'm pretty sure, however, that you just haven't tested enough to see
> > > any failures. glibc 2.23 is from 2016, so any functionality in it
> > > using syscalls added after 2011 (3.8 kernel) is going to blow up
> > > badly, thinking the syscall succeeded and returned some positive value
> > > when actually the kernel lacks it.
> > >
> > > In the particular case of clock_gettime, it's just that your glibc
> > > 2.23 has a hard Y2038 EOL and does not use/support the missing time64
> > > syscalls.
> > >
> > >
> > Duly noted.
> >
> > Thanks so much for being patient while I got you enough information to
> fix
> > this!
> >
> > On behalf of the entire Chromebrew community, thank you!
>
> And thanks for reporting, running tests, and following through on
> this. It will be useful to know this is an issue others might hit, and
> to be able to check other old systems that might have backported the
> patch with the bug.
>
[-- Attachment #1.2: Type: text/html, Size: 4070 bytes --]
[-- Attachment #2: broken_chromeos_kernel_hack_2.diff --]
[-- Type: application/octet-stream, Size: 2653 bytes --]
--- a/arch/i386/syscall_arch.h 2022-02-17 16:45:37.398583011 -0500
+++ b/arch/i386/syscall_arch.h 2022-02-17 16:50:02.311265598 -0500
@@ -9,11 +9,21 @@
#define SYSCALL_INSNS "call *%%gs:16"
#endif
+/*
+ * * This error code is special: arch syscall entry code will return
+ * * -ENOSYS if users try to call a syscall that doesn't exist. To keep
+ * * failures of syscalls that really do exist distinguishable from
+ * * failures due to attempts to use a nonexistent syscall, syscall
+ * * implementations should refrain from returning -ENOSYS.
+ * */
+#define ENOSYS 38 /* Invalid system call number */
+
#define SYSCALL_INSNS_12 "xchg %%ebx,%%edx ; " SYSCALL_INSNS " ; xchg %%ebx,%%edx"
#define SYSCALL_INSNS_34 "xchg %%ebx,%%edi ; " SYSCALL_INSNS " ; xchg %%ebx,%%edi"
static inline long __syscall0(long n)
{
+ if (n>350) return -ENOSYS;
unsigned long __ret;
__asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n) : "memory");
return __ret;
@@ -21,6 +31,7 @@
static inline long __syscall1(long n, long a1)
{
+ if (n>350) return -ENOSYS;
unsigned long __ret;
__asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
return __ret;
@@ -28,6 +39,7 @@
static inline long __syscall2(long n, long a1, long a2)
{
+ if (n>350) return -ENOSYS;
unsigned long __ret;
__asm__ __volatile__ (SYSCALL_INSNS_12 : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
return __ret;
@@ -35,6 +47,7 @@
static inline long __syscall3(long n, long a1, long a2, long a3)
{
+ if (n>350) return -ENOSYS;
unsigned long __ret;
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
__asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3) : "memory");
@@ -46,6 +59,7 @@
static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
{
+ if (n>350) return -ENOSYS;
unsigned long __ret;
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
__asm__ __volatile__ (SYSCALL_INSNS : "=a"(__ret) : "a"(n), "b"(a1), "c"(a2), "d"(a3), "S"(a4) : "memory");
@@ -57,6 +71,7 @@
static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
{
+ if (n>350) return -ENOSYS;
unsigned long __ret;
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
__asm__ __volatile__ (SYSCALL_INSNS
@@ -70,6 +85,7 @@
static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
{
+ if (n>350) return -ENOSYS;
unsigned long __ret;
#if !defined(__PIC__) || !defined(BROKEN_EBX_ASM)
__asm__ __volatile__ ("pushl %7 ; push %%ebp ; mov 4(%%esp),%%ebp ; " SYSCALL_INSNS " ; pop %%ebp ; add $4,%%esp"
next prev parent reply other threads:[~2022-02-18 1:25 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAFrh3J9CK67S=Jn531zTK04QeR8yiZwro_ZThQD=3aUx5XghCA@mail.gmail.com>
2022-02-06 21:30 ` Rich Felker
2022-02-06 23:25 ` Satadru Pramanik
2022-02-06 23:44 ` Rich Felker
2022-02-07 1:29 ` Satadru Pramanik
2022-02-07 2:40 ` Rich Felker
2022-02-07 19:19 ` Satadru Pramanik
2022-02-07 21:02 ` Rich Felker
2022-02-14 17:24 ` Satadru Pramanik
2022-02-14 18:29 ` Rich Felker
2022-02-14 19:00 ` Satadru Pramanik
2022-02-14 22:00 ` Rich Felker
2022-02-15 16:59 ` Satadru Pramanik
2022-02-15 17:44 ` Rich Felker
2022-02-15 22:56 ` Satadru Pramanik
2022-02-16 1:41 ` Rich Felker
2022-02-16 18:37 ` Satadru Pramanik
2022-02-16 18:44 ` Satadru Pramanik
2022-02-16 21:33 ` Rich Felker
2022-02-16 21:53 ` Satadru Pramanik
2022-02-17 1:44 ` Satadru Pramanik
2022-02-17 4:14 ` Satadru Pramanik
2022-02-17 13:17 ` Satadru Pramanik
2022-02-17 13:24 ` Rich Felker
2022-02-17 13:30 ` Satadru Pramanik
2022-02-17 13:46 ` Rich Felker
2022-02-17 14:49 ` Satadru Pramanik
2022-02-17 15:53 ` Rich Felker
2022-02-17 16:05 ` Rich Felker
2022-02-17 16:36 ` Satadru Pramanik
2022-02-17 18:17 ` Rich Felker
2022-02-17 21:39 ` Satadru Pramanik
2022-02-17 21:42 ` Satadru Pramanik
[not found] ` <CAFrh3J9CBGagzmnn9E7W0H15iiOzZEtg4YKfJ1qRwCtrjnw6tA@mail.gmail.com>
2022-02-17 21:43 ` Fwd: " Satadru Pramanik
2022-02-17 22:48 ` Rich Felker
2022-02-18 1:25 ` Satadru Pramanik [this message]
2022-02-17 16:17 ` Satadru Pramanik
2022-02-07 5:35 ` Markus Wichmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAFrh3J9--m0jur1AEFoQ2QpmJTpcsFNA_03nHr1+3B1xm0pOFw@mail.gmail.com \
--to=satadru@gmail.com \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).