简体   繁体   中英

What is the mincore syscall used for in userland applications?

What is Linux' mincore(2) useful for in userland applications? Why is it exposed to non-privileged users?

I can imagine some databases taking advantage of knowing which pages are cached but what are some other examples?

What is Linux mincore(2) useful for in userland applications?

I'd say that's most probably opinion based. Profiling, statistics, performance evaluation and stuff like that comes to mind. Other than that, I cannot think of other realistic legitimate use cases.

Here are some examples of programs I found that use mincore (as you can see, all profiling/statistics related):

Why is it exposed to non-privileged users?

This would have actually been a good question around one year ago , when the syscall's semantics weren't clearly defined, and the existence of such a syscall was rather questionable. Prior to kernel version 4.14.2 mincore could in fact have been abused to leak uninitialized kernel memory from user space (see CVE-2017-16994 and the relative Project Zero bug report ).

Since then the syscall has been patched and its semantics updated. The only thing that a process can do by invoking it is to query information about its virtual memory map. Nothing harmful really, just self-inspection, hence the availability to unprivileged processes. There's no real reason to make it a privileged syscall, which if done could be also considered an API breakage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM