Commit Graph

225 Commits

Author SHA1 Message Date
Michael Kerrisk e8426ca2b4 getent.1, localedef.1, accept.2, arch_prctl.2, clock_getres.2, clock_nanosleep.2, connect.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, execve.2, getitimer.2, getsockopt.2, gettid.2, inotify_add_watch.2, inotify_init.2, io_submit.2, ioctl.2, lseek.2, madvise.2, mlock.2, mmap.2, mprotect.2, msgctl.2, msgop.2, open_by_handle_at.2, openat2.2, pidfd_open.2, poll.2, prctl.2, quotactl.2, s390_sthyi.2, select.2, select_tut.2, semctl.2, semget.2, semop.2, setns.2, shmctl.2, shmget.2, shmop.2, sigaction.2, stat.2, statx.2, syscalls.2, timer_create.2, timerfd_create.2, unshare.2, wait.2, CPU_SET.3, aio_init.3, atoi.3, des_crypt.3, dirfd.3, fmemopen.3, fopencookie.3, ftok.3, fts.3, getaddrinfo.3, getifaddrs.3, getrpcent.3, gsignal.3, lio_listio.3, nl_langinfo.3, posix_memalign.3, posix_openpt.3, posix_spawn.3, scanf.3, sem_init.3, sem_post.3, shm_open.3, strcmp.3, strftime.3, st.4, elf.5, group.5, proc.5, services.5, aio.7, cgroups.7, feature_test_macros.7, keyrings.7, man-pages.7, namespaces.7, path_resolution.7, sigevent.7, signal.7, socket.7, sysvipc.7, time.7, udp.7: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-04-11 22:07:24 +02:00
Michael Kerrisk a2d56dbbe3 mmap.2: Add a subhead for the 'flags' argument
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-02-23 09:58:23 +01:00
Michael Kerrisk dd6ceee6f7 mmap.2: Move some text hidden at the end of DESCRIPTION to NOTES
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-02-23 09:58:23 +01:00
Michael Kerrisk efc7fb935e mmap.2: tfix
Reported-by: Marko Myllynen <myllynen@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-11-16 23:35:14 +01:00
Michael Kerrisk 91243dad42 mmap.2: Some rewording of the description of MAP_STACK
Reword a little to allow for the fact that there are now
*two* reasons to consider using this flag.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-11-14 22:24:52 +01:00
Michael Kerrisk d3d881232b mmap.2: Note that MAP_STACK exists on some other systems
As noted in man-pages commit 99c3a00027,
MAP_STACK exists on at least OpenBSD and FreeBSD.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-11-14 22:24:52 +01:00
Michael Kerrisk 867c9b3408 localedef.1, close.2, copy_file_range.2, execve.2, get_robust_list.2, getdomainname.2, gethostname.2, inotify_add_watch.2, io_submit.2, ioctl_fideduperange.2, kcmp.2, kill.2, mmap.2, move_pages.2, perf_event_open.2, ptrace.2, rt_sigqueueinfo.2, sched_setaffinity.2, sched_setparam.2, setns.2, sigaction.2, signalfd.2, statx.2, syscall.2, syscalls.2, uname.2, write.2, errno.3, fexecve.3, getauxval.3, printf.3, pthread_mutex_consistent.3, pthread_mutexattr_init.3, pthread_mutexattr_setrobust.3, pthread_setcancelstate.3, regex.3, strtok.3, strtol.3, ttyname.3, smartpqi.4, core.5, resolv.conf.5, man-pages.7, mq_overview.7, operator.7, pthreads.7, signal-safety.7, sysvipc.7: Update timestamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-11 10:45:02 +02:00
Nikola Forró c4f0c33fb6 mmap.2: Fix EINVAL conditions
Since introduction of MAP_SHARED_VALIDATE, in case flags contain
both MAP_PRIVATE and MAP_SHARED, mmap() doesn't fail with EINVAL,
it succeeds.

The reason for that is that MAP_SHARED_VALIDATE is in fact equal
to MAP_PRIVATE | MAP_SHARED.

This is intended behavior, see:
https://lwn.net/Articles/758594/
https://lwn.net/Articles/758598/

Signed-off-by: Nikola Forró <nforro@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-13 16:26:22 +02:00
Michael Kerrisk 0c479e1954 mmap.2: Bump timestamp for William Kucharski's review of "Fix description of treatment of the hint"
Reviewed-by: William Kucharski <william.kucharski@oracle.com>

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-27 15:38:35 +01:00
Michael Kerrisk d1a719857b locale.1, memusage.1, pldd.1, _syscall.2, add_key.2, bind.2, bpf.2, chown.2, clone.2, copy_file_range.2, eventfd.2, execve.2, futex.2, getdents.2, getrlimit.2, ioctl_fat.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, listxattr.2, lseek.2, membarrier.2, memfd_create.2, mmap.2, mprotect.2, msgop.2, open_by_handle_at.2, perf_event_open.2, pipe.2, readdir.2, readlink.2, readv.2, recvmmsg.2, request_key.2, sched_setaffinity.2, seccomp.2, select.2, select_tut.2, sendmmsg.2, setns.2, signalfd.2, spu_run.2, stat.2, sysctl.2, tee.2, timer_create.2, timerfd_create.2, truncate.2, uname.2, unshare.2, userfaultfd.2, ustat.2, wait.2, CPU_SET.3, __ppc_get_timebase.3, argz_add.3, asprintf.3, backtrace.3, basename.3, bswap.3, bzero.3, cacos.3, cacosh.3, catan.3, catanh.3, catgets.3, clock_getcpuclockid.3, confstr.3, ctime.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, fgetws.3, fmemopen.3, fopencookie.3, fputws.3, frexp.3, ftw.3, get_nprocs_conf.3, get_phys_pages.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrouplist.3, getifaddrs.3, getline.3, getlogin.3, getopt.3, getpass.3, getprotoent_r.3, getpwnam.3, getservent_r.3, getsubopt.3, glob.3, gnu_get_libc_version.3, hsearch.3, if_nameindex.3, index.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, iswblank.3, iswspace.3, makecontext.3, mallinfo.3, malloc_hook.3, malloc_info.3, mallopt.3, matherr.3, mbrtowc.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mcheck.3, memchr.3, mq_getattr.3, mq_notify.3, newlocale.3, nl_langinfo.3, offsetof.3, perror.3, posix_spawn.3, printf.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_mutexattr_setrobust.3, pthread_setaffinity_np.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, qsort.3, rand.3, readdir.3, regex.3, rpmatch.3, rtime.3, scanf.3, sem_wait.3, setaliasent.3, setbuf.3, stpcpy.3, stpncpy.3, strcat.3, strchr.3, strcpy.3, strdup.3, strerror.3, strfromd.3, strftime.3, strlen.3, strnlen.3, strsep.3, strstr.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, termios.3, tsearch.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscat.3, wcscpy.3, wcslen.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcsrtombs.3, wcsstr.3, wcstok.3, wcstombs.3, wcwidth.3, wprintf.3, console_codes.4, dsp56k.4, full.4, initrd.4, loop.4, vcs.4, charmap.5, core.5, elf.5, locale.5, proc.5, repertoiremap.5, sysfs.5, termcap.5, aio.7, bpf-helpers.7, cgroups.7, charsets.7, complex.7, fanotify.7, feature_test_macros.7, inotify.7, locale.7, man-pages.7, man.7, pkeys.7, pthreads.7, rtld-audit.7, sock_diag.7, unix.7, user_namespaces.7, utf-8.7: Use '\e' rather than '\\' to get a backslash
Quoting Branden:

*roff escape sequences may sometimes look like C escapes, but that
is misleading.  *roff is in part a macro language and that means
recursive expansion to arbitrary depths.

You can get away with "\\" in a context where no macro expansion
is taking place, but try to spell a literal backslash this way in
the argument to a macro and you will likely be unhappy with
results.

Try viewing the attached file with "man -l".

"\e" is the preferred and portable way to get a portable "escape
literal" going back to CSTR #54, the original Bell Labs troff
paper.

groff(7) discusses the issue:

  \\     reduces to a single backslash; useful to delay its
         interpretation as escape character in copy mode.  For a
         printable backslash, use \e, or even better \[rs], to be
         independent from the current escape character.

As of groff 1.22.4, groff_man(7) does as well:

  \e     Widely used in man pages to represent a backslash output
         glyph.  It works reliably as long as the .ec request is
         not used, which should never happen in man pages, and it
         is slightly more portable than the more exact ‘\(rs’
         (“reverse solidus”) escape sequence.

People not concerned with portability to extremely old troffs should
probably just use \(rs (or \[rs]), as it means "the backslash
glyph", not "the glyph corresponding to whatever the current escape
character is".

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-27 15:32:50 +01:00
Jann Horn f58e9ed092 mmap.2: Fix description of treatment of the hint
The current manpage reads to me as if the kernel will always pick
a free space close to the requested address, but that's not the
case:

mmap(0x600000000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x600000000000
mmap(0x600000000000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS,
-1, 0) = 0x7f5042859000

You can also see this in the various implementations of
->get_unmapped_area() - if the specified address isn't available,
the kernel basically ignores the hint (apart from the 5level
paging hack).

Clarify how this works a bit.

Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-25 15:56:54 +01:00
Mike Rapoport a2463bae6f ioctl_userfaultfd.2, madvise.2, memfd_create.2, migrate_pages.2, mmap.2, shmget.2, subpage_prot.2, userfaultfd.2, malloc.3, proc.5, sysfs.5, tmpfs.5: Update paths for in-kernel memory management documentation files
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-11-17 07:29:53 +01:00
Michael Kerrisk c3617f39b6 mmap.2: tfix
Reported-by: Thomas Posch <kernel.org@online.posch.name>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-11-01 18:23:33 +01:00
Michael Kerrisk fa38cc321f mmap.2: Minor rewording
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-08-26 13:29:58 +02:00
Elliott Hughes 3ee0a7f07e mmap.2: Explicitly state that the fd can be closed
I regularly see excessive fd usage bugs (or even leaks) caused by
people who think they need to keep the fd open as long as the
mapping exists.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-08-26 13:14:33 +02:00
Michael Kerrisk 09b8afdc04 execve.2, fallocate.2, getrlimit.2, io_submit.2, membarrier.2, mmap.2, msgget.2, open.2, ptrace.2, readv.2, semget.2, shmget.2, shutdown.2, syscall.2, wait.2, wait4.2, crypt.3, encrypt.3, fseek.3, getcwd.3, makedev.3, pthread_create.3, puts.3, tsearch.3, elf.5, filesystems.5, group.5, passwd.5, sysfs.5, mount_namespaces.7, posixoptions.7, time.7, unix.7, vdso.7, xattr.7, ld.so.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-30 17:41:31 +02:00
Michael Kerrisk 56f85b84df mmap.2: Minor wording improvements to text on MAP_FIXED hazard
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 09:39:10 +02:00
Michael Kerrisk 0949fa5efd mmap.2: Further tweaks to mention of MAP_FIXED_NOREPLACE in MAP_FIXED notes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 09:39:10 +02:00
Michael Kerrisk 49a8d3a176 mmap.2: Move the text on MAP_FIXED to NOTES
This text has become rather long, making it it somewhat
unwieldy in the discussion of the mmap() flags. Therefore,
move it to NOTES, with a pointer in DESCRIPTION referring
the reader to NOTES.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 09:39:10 +02:00
Michael Kerrisk 71c2db6a65 mmap.2: Further wording tweaks to the discussion of MAP_FIXED hazards
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 09:39:03 +02:00
Michael Kerrisk 2256fc0887 mmap.2: Minor wording fix
Change "extremely hazardous" to "hazardous". The former phrasing
is a little overwrought; on its own "hazardous" is enough to
convey the sense of danger.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 08:53:06 +02:00
Michael Kerrisk 56a033affa mmap.2: Minor wording fixes to to text describing MAP_FIXED hazards
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 08:50:38 +02:00
Michael Kerrisk fd859eb599 mmap.2: Simplify mention of MAP_FIXED_NOREPLACE in the discussion of MAP_FIXED
After discussions with Jann Horn and John Hubbard.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 08:44:24 +02:00
Michael Kerrisk 528cc762d9 mmap.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 08:38:50 +02:00
Michael Kerrisk a8fd340325 mmap.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 08:23:14 +02:00
Michael Kerrisk a6bf8e7e94 mmap.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 08:21:41 +02:00
Michael Kerrisk 08a239f387 mmap.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 08:21:41 +02:00
Jann Horn da6ad3cd89 mmap.2: MAP_FIXED is okay if the address range has been reserved
Clarify that MAP_FIXED is appropriate if the specified address
range has been reserved using an existing mapping, but shouldn't
be used otherwise.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 20:25:58 +02:00
Michael Kerrisk 5bc2d858e1 mmap.2: Clarify rationale of MAP_SYNC somewhat
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 20:18:58 +02:00
Michael Kerrisk 79da08c844 mmap.2: Minor tweaks to Jan Kara's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 14:55:43 +02:00
Michael Kerrisk b138773b1e mmap.2: srcfix: rewrap source lines
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 14:50:28 +02:00
Jan Kara d8aeb42ded mmap.2: Add description of MAP_SHARED_VALIDATE and MAP_SYNC
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 14:37:00 +02:00
Michael Kerrisk 95b9ecbf9d mmap.2: Explicitly mention MAP_FIXED_NOREPLACE in EEXIST description
Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:08:17 +02:00
Michael Kerrisk 421508eba8 mmap.2: Minor wording fix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michael Kerrisk a7a21482a1 mmap.2: Add a little historical detail on the obsolete MAP_DENYWRITE
In Linux 2..0, do_mmap() had the following check:

                if (flags & MAP_DENYWRITE) {
                        if (file->f_inode->i_writecount > 0)
                                return -ETXTBSY;
                }

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michael Kerrisk 0113b28739 mmap.2: Minor rewording of MAP_FIXED text
The paragraph break-up of the existing text was
somewhat unnatural.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michael Kerrisk 73cb50e21b mmap.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michael Kerrisk 3a548c59d9 mmap.2: Minor tweaks to Michal Hocko's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michael Kerrisk 509935b7de mmap.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michael Kerrisk 007d7833b0 mmap.2: srcfix: rewrap source lines
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michael Kerrisk 228d889fc7 mmap.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:03:04 +02:00
Michal Hocko c6a51c0645 mmap.2: Document new MAP_FIXED_NOREPLACE flag
4.17+ kernels offer a new MAP_FIXED_NOREPLACE flag which allows
the caller to atomically probe for a given address range.

[wording heavily updated by John Hubbard]

Cowritten-by: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 10:02:58 +02:00
Michael Kerrisk 365a54c70b mmap.2: Clarify that when addr==NULL, address chosen by kernel is page-aligned
Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-02-24 19:34:28 +01:00
Michael Kerrisk db4e8e25b4 mmap.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-12-19 06:34:57 +01:00
Michael Kerrisk c6bd0e7189 mmap.2: srcfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-12-19 06:33:09 +01:00
John Hubbard 3c778f69aa mmap.2: MAP_FIXED updated documentation
One last thing: reading through this, I think it might need a
wording fix (this is my fault), in order to avoid implying that
brk() or malloc() use dlopen().

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-12-19 06:31:11 +01:00
Michael Kerrisk 87c8ded551 mmap.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-12-18 20:10:04 +01:00
Michael Kerrisk 30c8dbeba4 mmap.2: Update timestamp for Michal Hocko's review of Hohn Hubbard's patch
Reviewed-by: Michal Hocko <mhocko@kernel.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-12-18 18:10:41 +01:00
Michael Kerrisk 33f01a061d mmap.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-12-18 18:08:47 +01:00
Michael Kerrisk 62d5de6594 mmap.2: Remove mention of MAP_FIXED_SAFE
Let's wait until MAP_FIXED_SAFE is merged.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-12-18 18:05:17 +01:00