golang/go

x/sys/unix: OpenBSD mmap syscall number (unix.SYS_MMAP) obsolete

Open

#59,661 opened on Apr 16, 2023

View on GitHub
 (8 comments) (0 reactions) (0 assignees)Go (19,008 forks)batch import
NeedsInvestigationOS-OpenBSDhelp wanted

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

On 2021-12-23, a new syscall for mmap was introduced:

49	STD NOLOCK	{ void *sys_mmap(void *addr, size_t len, int prot, \
			    int flags, int fd, off_t pos); }

At the same time, the existing mmap syscall was renamed from sys_mmap to sys_pad_mmap (since it contains a now-obsolete argument for padding).

See sys/kern/syscalls.master:

https://github.com/openbsd/src/commit/1d60349d0b961891264d426ffe1c0ced24b2374c#diff-e8c6a075c6e1240e27216779540b66f3db43b14a3b3615c2ecb7a111faa54504

On 2023-02-11, the original mmap syscall was retired entirely:

https://github.com/openbsd/src/commit/8c7f5cc47d34f1bd83a08278dad544a34184dabf

With the release of OpenBSD 7.3 on 2023-04-10, any go program that uses mmap on OpenBSD will crash with SIGSYS.

For example, here's a snippet from kdump of a failing run of gotosocial:

 83839 gotosocial CALL  (via syscall) #197 (obsolete pad_mmap)()
 83839 gotosocial PSIG  SIGSYS caught handler=0x4682c0 mask=0<>
 83839 gotosocial RET   #197 (obsolete pad_mmap) -1 errno 78 Function not implemented

This is a bug both in this project and in modernc.org/libc. Here, the constant unix.SYS_MMAP needs to be changed from 197 to 49. I'll also file a bug in that project for them to switch both the number and how they're invoking syscall.

Contributor guide