Re: [PATCH 3/5] fix exception message format for 64-bit userspace

2023-04-19 Thread Flávio Cruz
Hi Lucas, On Wed, Apr 19, 2023 at 3:47 PM Luca Dariz wrote: > * kern/exception.c: message fields need to be aligned to 8 bytes for a > 64-bit userspace, so add the required padding if needed, as done by > MIG. > --- > kern/exception.c | 6 ++ > 1 file changed, 6 insertions(+) > > diff -

Re: [RFC PATCH v2 4/7] csu: Fix standard fds' mode

2023-04-19 Thread Sergey Bugaev
On Wed, Apr 19, 2023 at 11:45 PM Adhemerval Zanella Netto wrote: > > I might be missing something, but why statically linked only? I don't > > see anything like that in elf/Makefile (but maybe I don't know where > > to look, please tell me!), and also the same behavior is certainly > > exhibited b

Re: [PATCH 5/5] add setting gs/fsbase

2023-04-19 Thread Sergey Bugaev
On Wed, Apr 19, 2023 at 10:48 PM Luca Dariz wrote: > * i386/i386/pcb.c: switch FSBASE/GSBASE on context switch and > implement accessors in thread setstatus/getstatus > * i386/i386/thread.h: add new state to thread saved state > * kern/thread.c: add i386_FSGS_BASE_STATE handler Hi Luca -- this

Re: [RFC PATCH v2 4/7] csu: Fix standard fds' mode

2023-04-19 Thread Adhemerval Zanella Netto
On 19/04/23 16:40, Sergey Bugaev wrote: > On Wed, Apr 19, 2023, 22:13 Cristian Rodríguez > wrote: >> Im a little bit lost on what it was supposed to do in this old form.. as >> the open flags are all wrong.. >> >> Changelog says: >> >> (__libc_check_standard_fds): Reverse modes so that comm

[PATCH 4/5 (v4)] x86_64: add 64-bit syscall entry point

2023-04-19 Thread Luca Dariz
While theoretically we could still use the same call gate as for 32-bit userspace, it doesn't seem very common, and gcc seems to not encode properly the instruction. Instead we use syscall/sysret as other kernels (e.g. XNU,Linux). This version still has some limitations, but should be enough to sta

[PATCH 2/5] fix copyoutmsg for 64-bit userspace

2023-04-19 Thread Luca Dariz
* x86_64/copy_user.c: use the correct user/kernel msg structure --- x86_64/copy_user.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/x86_64/copy_user.c b/x86_64/copy_user.c index b5084996..f76e44c9 100644 --- a/x86_64/copy_user.c +++ b/x86_64/copy_user.c @@ -430,7 +430,7

[PATCH 3/5] fix exception message format for 64-bit userspace

2023-04-19 Thread Luca Dariz
* kern/exception.c: message fields need to be aligned to 8 bytes for a 64-bit userspace, so add the required padding if needed, as done by MIG. --- kern/exception.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/kern/exception.c b/kern/exception.c index 10435b5c..757f793e 100644 ---

[PATCH 5/5] add setting gs/fsbase

2023-04-19 Thread Luca Dariz
* i386/i386/i386asm.sym: add offsets for asm * i386/i386/pcb.c: switch FSBASE/GSBASE on context switch and implement accessors in thread setstatus/getstatus * i386/i386/thread.h: add new state to thread saved state * kern/thread.c: add i386_FSGS_BASE_STATE handler * x86_64/locore.S: fix fs/gs han

[PATCH 1/5] fix address fault for 32-on-64-bit syscall

2023-04-19 Thread Luca Dariz
* x86_64/locore.S: the faulty address is found in %rbp and not in %rsi, so copy that in CR2 --- x86_64/locore.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x86_64/locore.S b/x86_64/locore.S index 47d9085c..ea5c71d6 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -12

Re: [RFC PATCH v2 4/7] csu: Fix standard fds' mode

2023-04-19 Thread Sergey Bugaev
On Wed, Apr 19, 2023, 22:13 Cristian Rodríguez wrote: > Im a little bit lost on what it was supposed to do in this old form.. as the > open flags are all wrong.. > > Changelog says: > > (__libc_check_standard_fds): Reverse modes so that common operations on > the descriptors fail. > > S

Re: [RFC PATCH v2 4/7] csu: Fix standard fds' mode

2023-04-19 Thread Cristian Rodríguez
On Wed, Apr 19, 2023 at 12:02 PM Sergey Bugaev wrote: > stdin is supposed to be readable, stdout and stderr writable. Otherwise, > we get this: > > index de6dd716..ca4812cd 100644 > --- a/csu/check_fds.c > +++ b/csu/check_fds.c > @@ -90,7 +90,7 @@ __libc_check_standard_fds (void) > is reall

[RFC PATCH v2 0/7] O_IGNORE_CTTY everywhere & misc fixes

2023-04-19 Thread Sergey Bugaev
Changes since v1: * Addressed nits * Made improvements to daemon () as discussed * Fixed std{in,out,err} mode in csu/check_fds.c * Tweaked the comment on O_IGNORE_CTTY But also, I found out that opening some internal files (specifically I have noticed this about nsswitch.conf) still triggers the t

[RFC PATCH v2 6/7] include/fcntl.h: Define O_IGNORE_CTTY

2023-04-19 Thread Sergey Bugaev
This internal definition makes it possible to use O_IGNORE_CTTY in the glibc codebase unconditionally, no matter whether the current port provides it or not (i.e. both on Hurd and on Linux). Along with the definition, this adds a small guide on when O_IGNORE_CTTY is to be used. The following commi

[RFC PATCH v2 3/7] Use O_CLOEXEC in more places (BZ #15722)

2023-04-19 Thread Sergey Bugaev
When opening a temporary file without O_CLOEXEC we risk leaking the file descriptor if another thread calls (fork and then) exec while we have the fd open. Fix this by consistently passing O_CLOEXEC everywhere where we open a file for internal use (and not to return it to the user, in which case th

[RFC PATCH v2 4/7] csu: Fix standard fds' mode

2023-04-19 Thread Sergey Bugaev
stdin is supposed to be readable, stdout and stderr writable. Otherwise, we get this: l-wx--. 1 root root 64 Apr 19 18:40 0 -> /dev/full lr-x--. 1 root root 64 Apr 19 18:40 1 -> /dev/null lr-x--. 1 root root 64 Apr 19 18:40 2 -> /dev/null Signed-off-by: Sergey Bugaev --- csu/check_f

[RFC PATCH v2 2/7] misc: Ignore SIGHUP in daemon () while forking

2023-04-19 Thread Sergey Bugaev
Under certain conditions, SIGHUP will be sent to the child process when the parent process (the one calling daemon ()) terminates -- namely, if the parent process was the session leader and the child process was in the same session (which will be the case after fork and until setsid) and in the for

[RFC PATCH v2 1/7] misc: Convert daemon () to GNU coding style

2023-04-19 Thread Sergey Bugaev
This is nicer, and is going to be required for the following changes to reasonably stay within the 79 column limit. No functional change. Signed-off-by: Sergey Bugaev --- misc/daemon.c | 88 --- 1 file changed, 49 insertions(+), 39 deletions(-) d

[RFC PATCH v2 5/7] hurd: Make dl-sysdep's open () cope with O_IGNORE_CTTY

2023-04-19 Thread Sergey Bugaev
Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/dl-sysdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 2d595d00..6e167e12 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysde

[RFC PATCH v2 7/7] Use O_IGNORE_CTTY where appropriate

2023-04-19 Thread Sergey Bugaev
* getpt, openpty: Opening an unused pty, which can't be our ctty * shm_open, sem_open: These don't work with ttys * opendir: Directories are unlikely to be ttys Signed-off-by: Sergey Bugaev --- catgets/open_catalog.c | 4 ++-- csu/check_fds.c | 6 +++--- elf/dl-load.c