I have a program that calls mmap() on /dev/zero to make some new private pages. It works fine if I use PROT_READ|PROT_WRITE but if I use PROT_EXEC instead of write, it always gets operation not permitted (errno 1). This has worked forever, it works on even newer kernel versions in fedora, but in ubuntu 20.04 with kernel 5.4.0-26-generic (x86_64) is always gives the error.
There must be some way to mmap read/execute pages since the dynamic loader still works.
Anyone know what magic new thing I need to do to make the map work again?
Found it! In ubuntu 20.04 the /dev filesystem is mounted with the noexec flag and mmap refuses to map a page exec from a noexec filesystem. Fortunately MAP_ANONYMOUS does work, so I can use that (with some logic to detect a working anonymous map since this program runs on zillions of different distros and antique kernels).