Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 28 Nov 2017 13:23:15 +0000
From: Nicholas Wilson <nicholas.wilson@...lvnc.com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: Re: [PATCH] Wasm support patch 2 (static syscalls)

That suggestion is exactly what I'm trying to avoid!

With a jump table like that, you can't get static linkage. The compiler will link in *every* syscall. I don't think it's reasonable for the Wasm hosting environment to provide emulation for every syscall.

So then comes the impossible task of pleasing everyone: someone will say, "my application wants emulation for all 100 syscalls", and someone else will say, "I don't want to link in emulation for 100 syscalls when my application only uses one". There's just nowhere to draw the line - endless arguments over *which* syscalls are worthy in inclusion in your big jump table.

The patch I've proposed is really as minimal as things can get. Apart from the change to "__setxid", the rest of Musl is completely undisturbed.

Nick

________________________________________
From: Szabolcs Nagy <nsz@...t70.net>
Sent: 28 November 2017 12:59:48
To: musl@...ts.openwall.com
Subject: Re: [musl] [PATCH] Wasm support patch 2 (static syscalls)

* Nicholas Wilson <nicholas.wilson@...lvnc.com> [2017-11-28 12:31:18 +0000]:
> Imagine an application that calls "getpid()".  This will cause "getpid.o" to be linked in, to provide the C API:
>
> pid_t getpid(void)
> {
>       return __syscall(SYS_getpid);
> }
>
> On all of Musl's existing archs, the syscalls are implemented via a seven generic "__syscallN" functions. The assumption is that the kernel provides all syscalls.
>
> For Wasm, what I've done is made it so that the interpreter environment instead provides *named* syscall functions, in this case, a "__syscall_getpid" function. Then, at link-time, when the linker links against libc.a it's able to link in to the application only the syscalls that are actually used.

we may change the syscall abstraction at some point, but
to do what you want, there is no need for intrusive changes.
just have

static inline long __syscall0(long n)
{
        switch (n) {
        ...
        case SYS_getpid: return __syscall_getpid();
        ...
        }
}

in arc/wasm/syscall_arch.h and the compiler will do the
right thing without any change to generic musl code.

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ