]> sourceware.org Git - glibc.git/log
glibc.git
17 months agoUpdate syscall lists for Linux 6.3
Joseph Myers [Mon, 15 May 2023 22:26:56 +0000 (22:26 +0000)]
Update syscall lists for Linux 6.3

Linux 6.3 has no new syscalls.  Update the version number in
syscall-names.list to reflect that it is still current for 6.3.

Tested with build-many-glibcs.py.

17 months agohurd: rule out some mach headers when generating errno.h
Samuel Thibault [Wed, 10 May 2023 23:51:10 +0000 (01:51 +0200)]
hurd: rule out some mach headers when generating errno.h

While mach/kern_return.h happens to pull mach/machine/kern_return.h,
mach/machine/boolean.h, and mach/machine/vm_types.h (and realpath-ing them
exposes the machine-specific machine symlink content), those headers do not
actually define anything machine-specific for the content of errno.h.

So we can just rule out these machine-specific from the dependency
comment.

17 months agoStop checking if MiG supports retcode.
Flavio Cruz [Wed, 10 May 2023 05:20:34 +0000 (01:20 -0400)]
Stop checking if MiG supports retcode.

We already did the same change for Hurd
(https://git.savannah.gnu.org/cgit/hurd/hurd.git/commit/?id=ef5924402864ef049f40a39e73967628583bc1a4)

Due to MiG requiring the subsystem to be defined early in order to know the
size of a port, this was causing a division by zero error during ./configure.
We could have just move subsystem to the top of the snippet, however it is
simpler to just remove the check given that we have no plans to use some other
MiG anyway.

HAVE_MIG_RETCODE is removed completely since this will be a no-op either
way (compiling against old Hurd headers will work the same, new Hurd
headers will result in the same stubs since retcode is a no-op).
Message-Id: <ZFspor91aoMwbh9T@jupiter.tail36e24.ts.net>

17 months agoAdded Redirects to longdouble error functions [BZ #29033]
Sachin Monga [Wed, 10 May 2023 17:59:21 +0000 (13:59 -0400)]
Added Redirects to longdouble error functions [BZ #29033]

This patch redirects the error functions to the appropriate
longdouble variants which enables the compiler to optimize
for the abi ieeelongdouble.

Signed-off-by: Sachin Monga <smonga@linux.ibm.com>
17 months agonptl: Reformat Makefile.
Carlos O'Donell [Tue, 18 Apr 2023 15:02:09 +0000 (11:02 -0400)]
nptl: Reformat Makefile.

Reflow all long lines adding comment terminators.
Sort all reflowed text using scripts/sort-makefile-lines.py.

No code generation changes observed in binary artifacts.
No regressions on x86_64 and i686.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
17 months agoscripts: Add sort-makefile-lines.py to sort Makefile variables.
Carlos O'Donell [Tue, 18 Apr 2023 15:02:55 +0000 (11:02 -0400)]
scripts: Add sort-makefile-lines.py to sort Makefile variables.

The scripts/sort-makefile-lines.py script sorts Makefile variables
according to project expected order.

The script can be used like this:

$ scripts/sort-makefile-lines.py < elf/Makefile > elf/Makefile.tmp
$ mv elf/Makefile.tmp elf/Makefile

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
17 months agodlopen: skip debugger notification for DSO loaded from sprof (bug 30258)
Andreas Schwab [Thu, 23 Mar 2023 15:46:20 +0000 (16:46 +0100)]
dlopen: skip debugger notification for DSO loaded from sprof (bug 30258)

Avoid inconsistent state in the debugger interface.

18 months agoaligned_alloc: conform to C17
DJ Delorie [Tue, 21 Mar 2023 04:46:43 +0000 (00:46 -0400)]
aligned_alloc: conform to C17

This patch adds the strict checking for power-of-two alignments
in aligned_alloc(), and updates the manual accordingly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
18 months agotestsuite: stdlib/isomac.c: fix REQUIREMENTS
наб [Thu, 4 May 2023 20:25:57 +0000 (22:25 +0200)]
testsuite: stdlib/isomac.c: fix REQUIREMENTS

All of the mentioned variables are gone. gcc is just the default and
argv[1] can be used instead. /usr/include isn't hard-coded and you can
pass argv[2] with -I... to adjust.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
18 months agomanual: Remove unsupported line breaks in waiting-with-clock section
Florian Weimer [Mon, 8 May 2023 11:14:22 +0000 (13:14 +0200)]
manual: Remove unsupported line breaks in waiting-with-clock section

The argument to @deftypefun must be on a single line.
Also add the missing @safety for sem_clockwait.

Reported-by: Nilgün Belma Bugüner <nillguine@gmail.com>
18 months agoEnable new device_open_new RPC in libmachuser.
Flavio Cruz [Sun, 7 May 2023 17:13:23 +0000 (13:13 -0400)]
Enable new device_open_new RPC in libmachuser.

Message-Id: <ZFfcM3DP+x7VHpWA@jupiter.tail36e24.ts.net>

18 months agoRevert "riscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC."
Florian Weimer [Sun, 7 May 2023 12:16:03 +0000 (14:16 +0200)]
Revert "riscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC."

This reverts commit 117e8b341c5c0ace8d65feeef136fececb3fdc9c.

Reason for revert: Causes elf/tst-glibcelf and elf/tst-relro-*
to fail on all architectures.

18 months agoUpdate hurd/hurdselect.c to be more portable.
Flavio Cruz [Sat, 6 May 2023 20:55:10 +0000 (16:55 -0400)]
Update hurd/hurdselect.c to be more portable.

Summary of changes:
- Use BAD_TYPECHECK to perform type checking in a cleaner way.
  BAD_TYPECHECK is moved into sysdeps/mach/rpc.h to avoid duplication.
- Remove assertions for mach_msg_type_t since those won't work for
  x86_64.
- Update message structs to use mach_msg_type_t directly.
- Use designated initializers.
Message-Id: <ZFa+roan3ioo0ONM@jupiter.tail36e24.ts.net>

18 months agohurd: Fix ld.so name
Samuel Thibault [Sat, 6 May 2023 19:00:56 +0000 (21:00 +0200)]
hurd: Fix ld.so name

This was set to ld-x86-64.so.1 in gcc.

18 months agohurd: Add ioperm symbol on x86_64
Samuel Thibault [Sat, 6 May 2023 16:59:32 +0000 (18:59 +0200)]
hurd: Add ioperm symbol on x86_64

18 months agotime: Remove alloca() from getdate
Joe Simmons-Talbott [Wed, 3 May 2023 16:40:05 +0000 (12:40 -0400)]
time: Remove alloca() from getdate

Reduce the usage of alloca() to the bare minimum to avoid the potential
for stack overflow.  Use __strndup to simplify the code.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
18 months agoaarch64: More configure checks for libmvec
Szabolcs Nagy [Fri, 5 May 2023 08:01:58 +0000 (09:01 +0100)]
aarch64: More configure checks for libmvec

Check assembler and linker support too, not just SVE ACLE in the
compiler, since variant PCS requires at least binutils 2.32.1.

18 months agoaarch64: SVE ACLE configure test cleanups
Szabolcs Nagy [Thu, 4 May 2023 09:14:43 +0000 (10:14 +0100)]
aarch64: SVE ACLE configure test cleanups

Use more idiomatic configure test for better autoconf cache and logs.

18 months agohppa: Fix 'concurrency' typo in comment
Sam James [Fri, 5 May 2023 09:12:07 +0000 (10:12 +0100)]
hppa: Fix 'concurrency' typo in comment

Signed-off-by: Sam James <sam@gentoo.org>
18 months agoUpdate hurd/intr-msg.c to be more portable
Flavio Cruz [Thu, 4 May 2023 04:08:12 +0000 (00:08 -0400)]
Update hurd/intr-msg.c to be more portable

Summary of the changes:
- Introduce BAD_TYPECHECK from MiG to make it simpler to do type
  checking.
- Replace int type with mach_msg_type_t. This assumes that
  mach_msg_type_t is always the same size as int which is not true for
  x86_64.
- Calculate the size and align using PTR_ALIGN_UP, which is a bit
  cleaner and similar to what we do elsewhere.
- Define mach_msg_type_t to check using designated initializers.
Message-Id: <ZFMvrIkvoCSxqB/C@jupiter.tail36e24.ts.net>

18 months agoUpdate sysdeps/mach/hurd/ioctl.c to make it more portable
Flavio Cruz [Thu, 4 May 2023 04:06:46 +0000 (00:06 -0400)]
Update sysdeps/mach/hurd/ioctl.c to make it more portable

Summary of the changes:
- Update msg_align to use ALIGN_UP like we have done in previous
  patches. Use it below whenever necessary to avoid repeating the same
  alignment logic.
- Define BAD_TYPECHECK to make it easier to do type checking in a few
  places below.
- Update io2mach_type to use designated initializers.
- Make RetCodeType use mach_msg_type_t. mach_msg_type_t is 8 byte for
  x86_64, so this make it portable.
- Also call msg_align for _IOT_COUNT2/_IOT_TYPE2 since it is more
  correct.
Message-Id: <ZFMvVsuFKwIy2dUS@jupiter.tail36e24.ts.net>

18 months agoaarch64: fix SVE ACLE check for bootstrap glibc builds
Szabolcs Nagy [Thu, 4 May 2023 08:48:03 +0000 (09:48 +0100)]
aarch64: fix SVE ACLE check for bootstrap glibc builds

arm_sve.h depends on stdint.h but that relies on libc headers unless
compiled in freestanding mode.  Without this change a bootstrap glibc
build (that uses a compiler without installed libc headers) failed with

checking for availability of SVE ACLE... In file included from [...]/arm_sve.h:28,
                 from conftest.c:1:
[...]/stdint.h:9:16: fatal error: stdint.h: No such file or directory
    9 | # include_next <stdint.h>
      |                ^~~~~~~~~~
compilation terminated.
configure: error: mathvec is enabled but compiler does not have SVE ACLE. [...]

18 months agoEnable libmvec support for AArch64
Joe Ramsay [Wed, 12 Apr 2023 13:37:49 +0000 (14:37 +0100)]
Enable libmvec support for AArch64

This patch enables libmvec on AArch64. The proposed change is mainly
implementing build infrastructure to add the new routines to ABI,
tests and benchmarks. I have demonstrated how this all fits together
by adding implementations for vector cos, in both single and double
precision, targeting both Advanced SIMD and SVE.

The implementations of the routines themselves are just loops over the
scalar routine from libm for now, as we are more concerned with
getting the plumbing right at this point. We plan to contribute vector
routines from the Arm Optimized Routines repo that are compliant with
requirements described in the libmvec wiki.

Building libmvec requires minimum GCC 10 for SVE ACLE. To avoid raising
the minimum GCC by such a big jump, we allow users to disable libmvec
if their compiler is too old.

Note that at this point users have to manually call the vector math
functions. This seems to be acceptable to some downstream users.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
18 months agohurd: Enable x86_64 build script
Samuel Thibault [Tue, 2 May 2023 19:40:31 +0000 (21:40 +0200)]
hurd: Enable x86_64 build script

This now passes crossbuilds.

18 months agohurd 64bit: Make dev_t word type
Samuel Thibault [Tue, 2 May 2023 19:29:26 +0000 (21:29 +0200)]
hurd 64bit: Make dev_t word type

dev_t are 64bit on Linux ports, so better increase their size on 64bit
Hurd. It happens that this helps with BZ 23084 there: st_dev has type fsid_t
(quad) and is specified by POSIX to have type dev_t. Making dev_t 64bit
makes these match.

18 months agomalloc: Really fix tst-memalign-3 link against threads
Samuel Thibault [Tue, 2 May 2023 19:26:09 +0000 (21:26 +0200)]
malloc: Really fix tst-memalign-3 link against threads

All the tst malloc variants need the thread linking flags.

18 months agomalloc: Fix tst-memalign-3 link against threads
Samuel Thibault [Tue, 2 May 2023 19:07:31 +0000 (21:07 +0200)]
malloc: Fix tst-memalign-3 link against threads

18 months agoUse GCC 13 branch, Linux 6.3 in build-many-glibcs.py
Joseph Myers [Tue, 2 May 2023 13:57:58 +0000 (13:57 +0000)]
Use GCC 13 branch, Linux 6.3 in build-many-glibcs.py

This patch updates build-many-glibcs.py to use Linux 6.3 and GCC 13
branch by default.

Tested with build-many-glibcs.py (host-libraries, compilers and glibc
builds).

18 months agoMark various cold functions as __COLD
Sergey Bugaev [Sat, 29 Apr 2023 13:12:23 +0000 (16:12 +0300)]
Mark various cold functions as __COLD

GCC docs explicitly list perror () as a good candidate for using
__attribute__ ((cold)). So apply __COLD to perror () and similar
functions.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131223.2507236-3-bugaevc@gmail.com>

18 months agoFix regex type usage
наб [Sun, 23 Apr 2023 00:55:05 +0000 (02:55 +0200)]
Fix regex type usage

include/regex.h had not been updated during the int -> Idx transition,
and the prototypes don't matched the definitions in regexec.c.

In regcomp.c, most interfaces were updated for Idx, except for two ones
guarded by #if _LIBC.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
18 months agohurd 64bit: Fix struct msqid_ds and shmid_ds fields
Samuel Thibault [Mon, 1 May 2023 12:51:22 +0000 (14:51 +0200)]
hurd 64bit: Fix struct msqid_ds and shmid_ds fields

The standards want msg_lspid/msg_lrpid/shm_cpid/shm_lpid to be pid_t, see BZ
23083 and 23085.

We can leave them __rpc_pid_t on i386 for ABI compatibility, but avoid
hitting the issue on 64bit.

18 months agohurd 64bit: Fix ipc_perm fields types
Samuel Thibault [Mon, 1 May 2023 12:40:12 +0000 (14:40 +0200)]
hurd 64bit: Fix ipc_perm fields types

The standards want uid/cuid to be uid_t, gid/cgid to be gid_t and mode to be
mode_t, see BZ 23082.

We can leave them short ints on i386 for ABI compatibility, but avoid
hitting the issue on 64bit.

bits/ipc.h ends up being exactly the same in sysdeps/gnu/ and
sysdeps/unix/sysv/linux/, so remove the latter.

18 months agohurd 64bit: Fix flock fields types
Samuel Thibault [Mon, 1 May 2023 12:35:32 +0000 (14:35 +0200)]
hurd 64bit: Fix flock fields types

The standards want l_type and l_whence to be short ints, see BZ 23081.

We can leave them ints on i386 for ABI compatibility, but avoid hitting the
issue on 64bit.

18 months agohurd 64bit: Add data for check-c++-types
Samuel Thibault [Mon, 1 May 2023 12:27:48 +0000 (14:27 +0200)]
hurd 64bit: Add data for check-c++-types

18 months agohurd 64bit: Fix pthread_t/thread_t type to long
Samuel Thibault [Mon, 1 May 2023 12:22:31 +0000 (14:22 +0200)]
hurd 64bit: Fix pthread_t/thread_t type to long

So that they can be trivially cast to pointer type, like with nptl.

18 months agosocket: Fix tst-cmsghdr-skeleton.c use of cmsg_len
Samuel Thibault [Mon, 1 May 2023 12:48:06 +0000 (14:48 +0200)]
socket: Fix tst-cmsghdr-skeleton.c use of cmsg_len

cmsg_len is supposed to be socklen_t according to standards, but it was made
size_t on Linux, see BZ 16919. For ports that have it socklen_t, SIZE_MAX is
too large. We can however explicitly cast it to the type of cmsg_len so it
will fit according to that type.

18 months agohurd 64bit: Add missing data file for check-localplt test
Samuel Thibault [Mon, 1 May 2023 11:38:57 +0000 (13:38 +0200)]
hurd 64bit: Add missing data file for check-localplt test

18 months agohurd 64bit: Add missing libanl
Samuel Thibault [Mon, 1 May 2023 11:35:54 +0000 (13:35 +0200)]
hurd 64bit: Add missing libanl

The move of libanl to libc was in glibc 2.34 for nptl only.

18 months agohurd: Also XFAIL missing SA_NOCLDWAIT on 64bit
Samuel Thibault [Mon, 1 May 2023 11:01:46 +0000 (13:01 +0200)]
hurd: Also XFAIL missing SA_NOCLDWAIT on 64bit

18 months agohurd: Fix tst-writev test
Samuel Thibault [Mon, 1 May 2023 11:00:50 +0000 (13:00 +0200)]
hurd: Fix tst-writev test

There is no compile-time IOV_MAX constraint on GNU/Hurd

18 months agonptl: move tst-x86-64-tls-1 to nptl-only tests
Samuel Thibault [Mon, 1 May 2023 10:59:12 +0000 (12:59 +0200)]
nptl: move tst-x86-64-tls-1 to nptl-only tests

It is essentially nptl-only.

18 months agohurd: Add expected abilist files for x86_64
Sergey Bugaev [Sat, 29 Apr 2023 20:18:20 +0000 (23:18 +0300)]
hurd: Add expected abilist files for x86_64

These were created by creating stub files, running 'make update-abi',
and reviewing the results.

Also, set baseline ABI to GLIBC_2.38, the (upcoming) first glibc
release to first have x86_64-gnu support.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agohurd: Replace reply port with a dead name on failed interruption
Sergey Bugaev [Sat, 29 Apr 2023 20:18:19 +0000 (23:18 +0300)]
hurd: Replace reply port with a dead name on failed interruption

If we're trying to interrupt an interruptible RPC, but the server fails
to respond to our __interrupt_operation () call, we instead destroy the
reply port we were expecting the reply to the RPC on.

Instead of deallocating the name completely, replace it with a dead
name, so the name won't get reused for some other right, and deallocate
it in _hurd_intr_rpc_mach_msg once we return from the signal handler.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429201822.2605207-4-bugaevc@gmail.com>

18 months agoDefine __mig_strlen to support dynamically sized strings in hurd RPCs
Flavio Cruz [Mon, 1 May 2023 00:09:49 +0000 (20:09 -0400)]
Define __mig_strlen to support dynamically sized strings in hurd RPCs

We make lib{mach,hurd}user.so only call __mig_strlen which can be
relocated before libc.so is relocated, similar to what is done with
__mig_memcpy.
Message-Id: <ZE8DTRDpY2hpPZlJ@jupiter.tail36e24.ts.net>

18 months agomach: Disable 32bit compatibility mode
Samuel Thibault [Mon, 1 May 2023 00:20:59 +0000 (02:20 +0200)]
mach: Disable 32bit compatibility mode

32bit compatibility is the default for now with 64bit gnumach, until 64bit
userland is ready.  Here we however want native 64bit userland anyway.

18 months agohurd: Make it possible to call memcpy very early
Sergey Bugaev [Sat, 29 Apr 2023 20:18:21 +0000 (23:18 +0300)]
hurd: Make it possible to call memcpy very early

Normally, in static builds, the first code that runs is _start, in e.g.
sysdeps/x86_64/start.S, which quickly calls __libc_start_main, passing
it the argv etc. Among the first things __libc_start_main does is
initializing the tunables (based on env), then CPU features, and then
calls _dl_relocate_static_pie (). Specifically, this runs ifunc
resolvers to pick, based on the CPU features discovered earlier, the
most suitable implementation of "string" functions such as memcpy.

Before that point, calling memcpy (or other ifunc-resolved functions)
will not work.

In the Hurd port, things are more complex. In order to get argv/env for
our process, glibc normally needs to do an RPC to the exec server,
unless our args/env are already located on the stack (which is what
happens to bootstrap processes spawned by GNU Mach). Fetching our
argv/env from the exec server has to be done before the call to
__libc_start_main, since we need to know what our argv/env are to pass
them to __libc_start_main.

On the other hand, the implementation of the RPC (and other initial
setup needed on the Hurd before __libc_start_main can be run) is not
very trivial. In particular, it may (and on x86_64, will) use memcpy.
But as described above, calling memcpy before __libc_start_main can not
work, since the GOT entry for it is not yet initialized at that point.

Work around this by pre-filling the GOT entry with the baseline version
of memcpy, __memcpy_sse2_unaligned. This makes it possible for early
calls to memcpy to just work. The initial value of the GOT entry is
unused on x86_64, and changing it won't interfere with the relocation
being performed later: once _dl_relocate_static_pie () is called, the
baseline version will get replaced with the most suitable one, and that
is what subsequent calls of memcpy are going to call.

Checked on x86_64-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429201822.2605207-6-bugaevc@gmail.com>

18 months agohurd: Implement longjmp for x86_64
Sergey Bugaev [Sat, 29 Apr 2023 20:18:18 +0000 (23:18 +0300)]
hurd: Implement longjmp for x86_64

Checked on x86_64-gnu.

[samuel.thibault@ens-lyon.org: Restored same comments as on i386]
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429201822.2605207-3-bugaevc@gmail.com>

18 months agohurd: Implement sigreturn for x86_64
Sergey Bugaev [Sat, 29 Apr 2023 20:18:17 +0000 (23:18 +0300)]
hurd: Implement sigreturn for x86_64

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429201822.2605207-2-bugaevc@gmail.com>

18 months agoMake __mach_msg_destroy portable for x86_64
Flavio Cruz [Sun, 30 Apr 2023 03:02:20 +0000 (23:02 -0400)]
Make __mach_msg_destroy portable for x86_64

We need to align on uintptr_t to make this work for x86_64,
otherwise things will go wrong when RPCs return errors.
Message-Id: <ZE3aPH7uCEDti47H@jupiter.tail36e24.ts.net>

18 months agohurd: Mark error functions as __COLD
Sergey Bugaev [Sat, 29 Apr 2023 13:12:22 +0000 (16:12 +0300)]
hurd: Mark error functions as __COLD

This should hopefully hint the compiler that they are unlikely
to be called.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131223.2507236-2-bugaevc@gmail.com>

18 months agocdefs.h: Define __COLD
Sergey Bugaev [Thu, 27 Apr 2023 14:42:11 +0000 (17:42 +0300)]
cdefs.h: Define __COLD

This expands to __attribute__ ((cold)) when supported. It should be
used to mark up functions that are invoked rarely.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agohurd: Fix FS_RETRY_MAGICAL "machtype" handling
Sergey Bugaev [Sat, 29 Apr 2023 13:13:54 +0000 (16:13 +0300)]
hurd: Fix FS_RETRY_MAGICAL "machtype" handling

We need to set file_name, not update retryname. This is what the other
branches do.

Before this change, any attempt to access such a file would segfault due
to file_name being unset:

$ settrans -ac /tmp/my-machtype /hurd/magic machtype
$ cat /tmp/my-machtype
Segmentation fault

Checked on i686-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-7-bugaevc@gmail.com>

18 months agohurd: Respect existing FD_CLOEXEC in S_msg_set_fd
Sergey Bugaev [Sat, 29 Apr 2023 13:13:53 +0000 (16:13 +0300)]
hurd: Respect existing FD_CLOEXEC in S_msg_set_fd

If the process has set the close-on-exec flag for the file descriptor,
it expects the file descriptor to get closed on exec, even if we replace
what the file descriptor refers to.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-6-bugaevc@gmail.com>

18 months agohurd: Don't leak the auth port in msg* RPCs
Sergey Bugaev [Sat, 29 Apr 2023 13:13:52 +0000 (16:13 +0300)]
hurd: Don't leak the auth port in msg* RPCs

The leak can be easily reproduced (and observed) using the portinfo
tool:

$ portinfo -v $$ | grep task
    36: send task(1577)(self) (refs: 127)
$ portinfo -v $$ | grep task
    36: send task(1577)(self) (refs: 253)
$ portinfo -v $$ | grep task
    36: send task(1577)(self) (refs: 379)
$ portinfo -v $$ | grep task
    36: send task(1577)(self) (refs: 505)
$ portinfo -v $$ | grep task
    36: send task(1577)(self) (refs: 631)

Checked on i686-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-5-bugaevc@gmail.com>

18 months agohurd: Make _exit work during early boot-up
Sergey Bugaev [Sat, 29 Apr 2023 13:13:51 +0000 (16:13 +0300)]
hurd: Make _exit work during early boot-up

If any of the early boot-up tasks calls exit () or returns from main (),
terminate it properly instead of crashing on trying to dereference
_hurd_ports and getting forcibly terminated by the kernel.

We sadly cannot make the __USEPORT macro do the check for _hurd_ports
being unset, because it evaluates to the value of the expression
provided as the second argument, and that can be of any type; so there
is no single suitable fallback value for the macro to evaluate to in
case _hurd_ports is unset. Instead, each use site that wants to care for
this case will have to do its own checking.

Checked on x86_64-gnu.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-4-bugaevc@gmail.com>

18 months agohurd: Mark various conditions as unlikely
Sergey Bugaev [Sat, 29 Apr 2023 13:13:50 +0000 (16:13 +0300)]
hurd: Mark various conditions as unlikely

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-3-bugaevc@gmail.com>

18 months agohurd: Move libc_hidden_def's around
Sergey Bugaev [Sat, 29 Apr 2023 13:13:49 +0000 (16:13 +0300)]
hurd: Move libc_hidden_def's around

Each libc_hidden_def should be placed immediately next to its function,
not in some random unrelated place.

No functional change.

Fixes: 653d74f12abea144219af00400ed1f1ac5dfa79f
"hurd: Global signal disposition"

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-2-bugaevc@gmail.com>

18 months agohurd: Simplify _hurd_critical_section_lock a bit
Sergey Bugaev [Sat, 29 Apr 2023 13:13:48 +0000 (16:13 +0300)]
hurd: Simplify _hurd_critical_section_lock a bit

This block of code was doing exactly what _hurd_self_sigstate does; so
just call that and let it do its job.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230429131354.2507443-1-bugaevc@gmail.com>

18 months ago__check_pf: Add a cancellation cleanup handler [BZ #20975]
H.J. Lu [Thu, 27 Apr 2023 20:06:15 +0000 (13:06 -0700)]
__check_pf: Add a cancellation cleanup handler [BZ #20975]

There are reports for hang in __check_pf:

https://github.com/JoeDog/siege/issues/4

It is reproducible only under specific configurations:

1. Large number of cores (>= 64) and large number of threads (> 3X of
the number of cores) with long lived socket connection.
2. Low power (frequency) mode.
3. Power management is enabled.

While holding lock, __check_pf calls make_request which calls __sendto
and __recvmsg.  Since __sendto and __recvmsg are cancellation points,
lock held by __check_pf won't be released and can cause deadlock when
thread cancellation happens in __sendto or __recvmsg.  Add a cancellation
cleanup handler for __check_pf to unlock the lock when cancelled by
another thread.  This fixes BZ #20975 and the siege hang issue.

18 months agoRemap __GLIBC_FLT_EVAL_METHOD to 0 if __FLT_EVAL_METHOD__ is -1
Kito Cheng [Tue, 14 Mar 2023 15:19:48 +0000 (23:19 +0800)]
Remap __GLIBC_FLT_EVAL_METHOD to 0 if __FLT_EVAL_METHOD__ is -1

__GLIBC_FLT_EVAL_METHOD will effect the definition of float_t and
double_t, currently we'll set __GLIBC_FLT_EVAL_METHOD to 2 when
__FLT_EVAL_METHOD__ is -1, that means we'll define float_t and double_t
to long double.

However some target isn't natively (HW) support long double like AArch64 and
RISC-V, they defined long double as 128-bits IEEE 754 floating point type.

That means setting __GLIBC_FLT_EVAL_METHOD to 2 will cause very inefficient
code gen for those target who didn't provide native support for long
double, and that's violate the spirit float_t and double_t - most efficient
types at least as wide as float and double.

So this patch propose to remap __GLIBC_FLT_EVAL_METHOD to 0 rather than
2 when __FLT_EVAL_METHOD__ is -1, which means we'll use float/double
rather than long double for float_t and double_t.

Note: __FLT_EVAL_METHOD__ == -1 means the precision is indeterminable,
      which means compiler might using indeterminable precision during
      optimization/code gen, clang will set this value to -1 when fast
      math is enabled.

Note: Default definition float_t and double_t in current glibc:
      |  __GLIBC_FLT_EVAL_METHOD | float_t     | double_t
      |               0 or 16    | float       | double
      |               1          | double      | doulbe
      |               2          | long double | long double
      More complete list see math/math.h

Note: RISC-V has defined ISA extension to support 128-bits IEEE 754
      floating point operations, but only rare RISC-V core will implement that.

Related link:

[1] LLVM issue (__FLT_EVAL_METHOD__ is set to -1 with Ofast. #60781):
    https://github.com/llvm/llvm-project/issues/60781
[2] Last version of this patch: https://sourceware.org/pipermail/libc-alpha/2023-February/145622.html

Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
Reviewed-by: Wilco Dijkstra  <Wilco.Dijkstra@arm.com>
Link: https://inbox.sourceware.org/libc-alpha/20230314151948.12892-1-kito.cheng@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
18 months agoriscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC.
Hsiangkai Wang [Tue, 14 Mar 2023 16:25:12 +0000 (00:25 +0800)]
riscv: Resolve symbols directly for symbols with STO_RISCV_VARIANT_CC.

In some cases, we do not want to go through the resolver for function
calls. For example, functions with vector arguments will use vector
registers to pass arguments. In the resolver, we do not save/restore the
vector argument registers for lazy binding efficiency. To avoid ruining
the vector arguments, functions with vector arguments will not go
through the resolver.

To achieve the goal, we will annotate the function symbols with
STO_RISCV_VARIANT_CC flag and add DT_RISCV_VARIANT_CC tag in the dynamic
section. In the first pass on PLT relocations, we do not set up to call
_dl_runtime_resolve. Instead, we resolve the functions directly.

Signed-off-by: Hsiangkai Wang <kai.wang@sifive.com>
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
Link: https://inbox.sourceware.org/libc-alpha/20230314162512.35802-1-kito.cheng@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
18 months agoelf.h: add PT_GNU_SFRAME
Indu Bhagat [Fri, 28 Apr 2023 08:53:05 +0000 (10:53 +0200)]
elf.h: add PT_GNU_SFRAME

Support for SFrame format is available in Binutils 2.40.  The GNU ld merges
the input .sframe sections and creates an output .sframe section in a
segment PT_GNU_SFRAME.

18 months agoFix Hurd getcwd build with GCC >= 13
Joseph Myers [Wed, 26 Apr 2023 17:14:18 +0000 (17:14 +0000)]
Fix Hurd getcwd build with GCC >= 13

The build of glibc for i686-gnu has been failing for a while with GCC
mainline / GCC 13:

../sysdeps/mach/hurd/getcwd.c: In function '__hurd_canonicalize_directory_name_internal':
../sysdeps/mach/hurd/getcwd.c:242:48: error: pointer 'file_name' may be used after 'realloc' [-Werror=use-after-free]
  242 |                   file_namep = &buf[file_namep - file_name + size / 2];
      |                                     ~~~~~~~~~~~^~~~~~~~~~~
../sysdeps/mach/hurd/getcwd.c:236:25: note: call to 'realloc' here
  236 |                   buf = realloc (file_name, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~

Fix by doing the subtraction before the reallocation.

Tested with build-many-glibcs.py for i686-gnu.

[samuel.thibault@ens-lyon.rg: Removed mention of this being a bug]

Message-Id: <18587337-7815-4056-ebd0-724df262d591@codesourcery.com>

18 months agoRegenerate sysdeps/mach/hurd/bits/errno.h
Joseph Myers [Wed, 26 Apr 2023 17:11:41 +0000 (17:11 +0000)]
Regenerate sysdeps/mach/hurd/bits/errno.h

This file was out of date, as shown by build-many-glibcs.py runs
resulting in a modified source directory.

18 months agolocale/programs/locarchive.c: Remove unnecessary check in add_locale_archive
Frédéric Bérat [Wed, 26 Apr 2023 12:30:58 +0000 (08:30 -0400)]
locale/programs/locarchive.c: Remove unnecessary check in add_locale_archive

Since asprintf is called "if (mask & XPG_NORM_CODESET)" there is no
point in checking the mask again within the asprintf call.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
18 months agomanual: document posix_openpt (bug 17010)
Gavin Smith [Wed, 12 Apr 2023 12:45:07 +0000 (13:45 +0100)]
manual: document posix_openpt (bug 17010)

State that getpt is similar to posix_openpt.  Use posix_openpt
instead of getpt in example.

Signed-off-by: Gavin Smith <gavinsmith0123@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agoif_index: Remove unneeded alloca.h include
Joe Simmons-Talbott [Tue, 25 Apr 2023 14:26:54 +0000 (10:26 -0400)]
if_index: Remove unneeded alloca.h include

Nothing is being used from this header.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
18 months agogethostid: Do not include alloca.h
Joe Simmons-Talbott [Mon, 24 Apr 2023 19:30:58 +0000 (15:30 -0400)]
gethostid: Do not include alloca.h

Nothing from alloca.h is being used here.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
18 months agosocket: Add a test for MSG_CMSG_CLOEXEC
Sergey Bugaev [Sun, 23 Apr 2023 16:05:48 +0000 (19:05 +0300)]
socket: Add a test for MSG_CMSG_CLOEXEC

This checks that:
* We can send and receive fds over Unix domain sockets using SCM_RIGHTS;
* msg_controllen, cmsg_level, cmsg_type, cmsg_len are all filled in
  correctly on receive;
* Most importantly, the received fd has or has not the close-on-exec
  flag set depending on whether we pass MSG_CMSG_CLOEXEC to recvmsg ().

Checked on i686-gnu and x86_64-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230423160548.126576-4-bugaevc@gmail.com>

18 months agohurd: Do not take any flag from the CMSG_DATA
Samuel Thibault [Mon, 24 Apr 2023 22:14:58 +0000 (00:14 +0200)]
hurd: Do not take any flag from the CMSG_DATA

As fixed in 0822e3552a78 ("hurd: Don't pass FD_CLOEXEC in CMSG_DATA"),
senders currently don't have any flag to pass.  We shouldn't blindly take
random flags that senders could be erroneously giving us.

18 months agohurd: Implement MSG_CMSG_CLOEXEC
Sergey Bugaev [Sun, 23 Apr 2023 16:05:46 +0000 (19:05 +0300)]
hurd: Implement MSG_CMSG_CLOEXEC

This is a new flag that can be passed to recvmsg () to make it
atomically set the CLOEXEC flag on all the file descriptors received
using the SCM_RIGHTS mechanism. This is useful for all the same reasons
that the other XXX_CLOEXEC flags are useful: namely, it provides
atomicity with respect to another thread of the same process calling
(fork and then) exec at the same time.

This flag is already supported on Linux and FreeBSD. The flag's value,
0x40000, is choosen to match FreeBSD's.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230423160548.126576-2-bugaevc@gmail.com>

18 months agohurd: Don't pass FD_CLOEXEC in CMSG_DATA
Samuel Thibault [Mon, 24 Apr 2023 21:05:15 +0000 (23:05 +0200)]
hurd: Don't pass FD_CLOEXEC in CMSG_DATA

The flags are used by _hurd_intern_fd, which takes O_* flags, not FD_*.

Also, it is of no concern to the receiving process whether or not
the sender process wants to close its copy of sent file descriptor
upon exec, and it should not influence whether or not the received
file descriptor gets the FD_CLOEXEC flag set in the receiving process.

The latter should in fact be dependent on the MSG_CMSG_CLOEXEC flag
being passed to the recvmsg () call, which is going to be implemented
in the following commit.

Fixes 344e755248ce02c0f8d095d11cc49e340703d926
"hurd: Support sending file descriptors over Unix sockets"

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agohurd: Implement prefer_map_32bit_exec tunable
Sergey Bugaev [Sun, 23 Apr 2023 21:55:26 +0000 (00:55 +0300)]
hurd: Implement prefer_map_32bit_exec tunable

This makes the prefer_map_32bit_exec tunable no longer Linux-specific.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230423215526.346009-4-bugaevc@gmail.com>

18 months agohurd: Don't attempt to deallocate MACH_PORT_DEAD
Sergey Bugaev [Sun, 23 Apr 2023 21:55:24 +0000 (00:55 +0300)]
hurd: Don't attempt to deallocate MACH_PORT_DEAD

...in some more places.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230423215526.346009-2-bugaevc@gmail.com>

18 months agohurd: Only deallocate addrport when it's valid
Sergey Bugaev [Sun, 23 Apr 2023 16:05:47 +0000 (19:05 +0300)]
hurd: Only deallocate addrport when it's valid

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230423160548.126576-3-bugaevc@gmail.com>

18 months agohurd: Implement MAP_32BIT
Sergey Bugaev [Sun, 23 Apr 2023 21:55:23 +0000 (00:55 +0300)]
hurd: Implement MAP_32BIT

This is a flag that can be passed to mmap () to request that the mapping
being established should be located in the lower 2 GB area of the
address space, so only the lower 31 (not 32) bits can be set in its
address, and the address can be represented as a 32-bit integer without
truncating it.

This flag is intended to be compatible with Linux, FreeBSD, and Darwin
flags of the same name. Out of those systems, it appears Linux and
FreeBSD take MAP_32BIT to mean "map 31 bit", whereas Darwin allows the
32nd bit to be set in the address as well. The Hurd follows Linux and
FreeBSD behavior.

Unlike on those systems, on the Hurd MAP_32BIT is defined on all
supported architectures (which currently are only i386 and x86_64).

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230423215526.346009-1-bugaevc@gmail.com>

18 months agoUse O_CLOEXEC in more places (BZ #15722)
Sergey Bugaev [Wed, 19 Apr 2023 16:02:03 +0000 (19:02 +0300)]
Use O_CLOEXEC in more places (BZ #15722)

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 the API defines whether or not the close-on-exec flag
shall be set on the returned fd).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230419160207.65988-4-bugaevc@gmail.com>

18 months agomisc: Convert daemon () to GNU coding style
Sergey Bugaev [Wed, 19 Apr 2023 16:02:01 +0000 (19:02 +0300)]
misc: Convert daemon () to GNU coding style

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 <bugaevc@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Message-Id: <20230419160207.65988-2-bugaevc@gmail.com>

18 months agowcsmbs: Add wcsdup() tests. (BZ #30266)
Joe Simmons-Talbott [Fri, 21 Apr 2023 13:24:25 +0000 (09:24 -0400)]
wcsmbs: Add wcsdup() tests. (BZ #30266)

Enable wide character testcases for wcsdup().

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agostring: Add tests for strndup (BZ #30266)
Joe Simmons-Talbott [Fri, 21 Apr 2023 13:24:24 +0000 (09:24 -0400)]
string: Add tests for strndup (BZ #30266)

Copy strncpy tests for strndup.  Covers some basic testcases with random
strings.  Remove tests that set the destination's bytes and checked the
resulting buffer's bytes.  Remove wide character test support since
wcsndup() doesn't exist.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agostring: Add tests for strdup (BZ #30266)
Joe Simmons-Talbott [Fri, 21 Apr 2023 13:24:23 +0000 (09:24 -0400)]
string: Add tests for strdup (BZ #30266)

Copy strcpy tests for strdup.  Covers some basic testcases with random
strings.  Add a zero-length string testcase.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agostring: Allow use of test-string.h for non-ifunc implementations.
Joe Simmons-Talbott [Fri, 21 Apr 2023 13:24:22 +0000 (09:24 -0400)]
string: Allow use of test-string.h for non-ifunc implementations.

Mark two variables as unused to silence warning when using
test-string.h for non-ifunc implementations.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agohurd: Don't migrate reply port into __init1_tcbhead
Sergey Bugaev [Thu, 20 Apr 2023 18:42:19 +0000 (21:42 +0300)]
hurd: Don't migrate reply port into __init1_tcbhead

Properly differentiate between setting up the real TLS with
TLS_INIT_TP, and setting up the early TLS (__init1_tcbhead) in static
builds. In the latter case, don't yet migrate the reply port into the
TCB, and don't yet set __libc_tls_initialized to 1.

This also lets us move the __init1_desc assignment inside
_hurd_tls_init ().

Fixes cd019ddd892e182277fadd6aedccc57fa3923c8d
"hurd: Don't leak __hurd_reply_port0"

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agohurd: Make dl-sysdep's open () cope with O_IGNORE_CTTY
Sergey Bugaev [Wed, 19 Apr 2023 16:02:05 +0000 (19:02 +0300)]
hurd: Make dl-sysdep's open () cope with O_IGNORE_CTTY

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
Message-Id: <20230419160207.65988-6-bugaevc@gmail.com>

18 months agoCreated tunable to force small pages on stack allocation.
Cupertino Miranda [Fri, 14 Apr 2023 15:12:20 +0000 (16:12 +0100)]
Created tunable to force small pages on stack allocation.

Created tunable glibc.pthread.stack_hugetlb to control when hugepages
can be used for stack allocation.
In case THP are enabled and glibc.pthread.stack_hugetlb is set to
0, glibc will madvise the kernel not to use allow hugepages for stack
allocations.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agomalloc: Add missing shared thread library flags
Adhemerval Zanella [Wed, 19 Apr 2023 21:17:20 +0000 (18:17 -0300)]
malloc: Add missing shared thread library flags

So tst-memalign-3 builds on Hurd.

18 months agolinux: Re-flow and sort multiline Makefile definitions
Adhemerval Zanella [Wed, 19 Apr 2023 21:18:15 +0000 (18:18 -0300)]
linux: Re-flow and sort multiline Makefile definitions

18 months agoposix: Re-flow and sort multiline Makefile definitions
Adhemerval Zanella [Tue, 18 Apr 2023 16:58:18 +0000 (13:58 -0300)]
posix: Re-flow and sort multiline Makefile definitions

18 months agobuild-many-glibcs.py: --disable-gcov for gcc-first
Jan-Benedict Glaw [Sat, 1 Apr 2023 19:09:19 +0000 (21:09 +0200)]
build-many-glibcs.py: --disable-gcov for gcc-first

This is also being tracked n GCC [1].

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100289

18 months agomalloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101)
DJ Delorie [Mon, 3 Apr 2023 21:33:03 +0000 (17:33 -0400)]
malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101)

Based on these comments in malloc.c:

   size field is or'ed with NON_MAIN_ARENA if the chunk was obtained
   from a non-main arena.  This is only set immediately before handing
   the chunk to the user, if necessary.

   The NON_MAIN_ARENA flag is never set for unsorted chunks, so it
   does not have to be taken into account in size comparisons.

When we pull a chunk off the unsorted list (or any list) we need to
make sure that flag is set properly before returning the chunk.

Use the rounded-up size for chunk_ok_for_memalign()

Do not scan the arena for reusable chunks if there's no arena.

Account for chunk overhead when determining if a chunk is a reuse
candidate.

mcheck interferes with memalign, so skip mcheck variants of
memalign tests.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
18 months agohurd: Microoptimize sigreturn
Sergey Bugaev [Fri, 14 Apr 2023 13:32:45 +0000 (16:32 +0300)]
hurd: Microoptimize sigreturn

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agorcmd.c: Fix indentation in last commit
Siddhesh Poyarekar [Tue, 18 Apr 2023 13:47:40 +0000 (09:47 -0400)]
rcmd.c: Fix indentation in last commit

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
18 months agoinet/rcmd.c: fix warn unused result
Frédéric Bérat [Tue, 18 Apr 2023 13:01:00 +0000 (09:01 -0400)]
inet/rcmd.c: fix warn unused result

Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in
glibc.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
18 months agohurd: Avoid leaking task & thread ports
Sergey Bugaev [Fri, 14 Apr 2023 19:37:00 +0000 (22:37 +0300)]
hurd: Avoid leaking task & thread ports

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agohurd: Simplify _S_catch_exception_raise
Sergey Bugaev [Fri, 14 Apr 2023 19:36:59 +0000 (22:36 +0300)]
hurd: Simplify _S_catch_exception_raise

_hurd_thread_sigstate () already handles finding an existing sigstate
before allocating a new one, so just use that. Bonus: this will only
lock the _hurd_siglock once.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agohurd: Run init_pids () before init_dtable ()
Sergey Bugaev [Sat, 15 Apr 2023 19:08:56 +0000 (22:08 +0300)]
hurd: Run init_pids () before init_dtable ()

Much as the comment says, things on _hurd_subinit assume that _hurd_pid
is already initialized by the time _hurd_subinit is run, so
_hurd_proc_subinit has to run before it. Specifically, init_dtable ()
calls _hurd_port2fd (), which uses _hurd_pid and _hurd_pgrp to set up
ctty handling. With _hurd_subinit running before _hurd_proc_subinit,
ctty setup was broken:

  13<--33(pid1255)->term_getctty () = 0    4<--39(pid1255)
task16(pid1255)->mach_port_deallocate (pn{ 10}) = 0
  13<--33(pid1255)->term_open_ctty (0 0) = 0x40000016 (Invalid argument)

Fix this by running the _hurd_proc_subinit hook in the correct place --
just after _hurd_portarray is set up (so the proc server port is
available in its usual place) and just before running _hurd_subinit.

Fixes 1ccbb9258eed0f667edf459a28ba23a805549b36
("hurd: Notify the proc server later during initialization").

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agohurd: Fix restoring reply port in sigreturn
Sergey Bugaev [Fri, 14 Apr 2023 19:36:56 +0000 (22:36 +0300)]
hurd: Fix restoring reply port in sigreturn

We must not use the user's reply port (scp->sc_reply_port) for any of
our own RPCs, otherwise various things break. So, use MACH_PORT_DEAD as
a reply port when destroying our reply port, and make sure to do this
after _hurd_sigstate_unlock (), which may do a gsync_wake () RPC.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
18 months agowcsmbs: Re-flow and sort routines, tests variables in Makefile
Florian Weimer [Mon, 17 Apr 2023 13:41:08 +0000 (15:41 +0200)]
wcsmbs: Re-flow and sort routines, tests variables in Makefile

Eliminate strop-tests because it does not seem to be a simplification.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agodebug: Re-flow and sort routines variable in Makefile
Florian Weimer [Mon, 17 Apr 2023 13:41:08 +0000 (15:41 +0200)]
debug: Re-flow and sort routines variable in Makefile

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
18 months agohurd: Avoid extra ctty RPCs in init_dtable ()
Sergey Bugaev [Sat, 15 Apr 2023 16:17:18 +0000 (19:17 +0300)]
hurd: Avoid extra ctty RPCs in init_dtable ()

It is common to have (some of) stdin, stdout and stderr point to the
very same port. We were making the ctty RPCs that _hurd_port2fd () does
for each one of them separately:

1. term_getctty ()
2. mach_port_deallocate ()
3. term_open_ctty ()

Instead, let's detect this case and duplicate the ctty port we already
have. This means we do 1 RPC instead of 3 (and create a single protid
on the server side) if the file is our ctty, and no RPCs instead of 1
if it's not. A clear win!

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
This page took 0.092365 seconds and 5 git commands to generate.