sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget+/translations/zh_CN/process/adding-syscallsmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/zh_TW/process/adding-syscallsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/it_IT/process/adding-syscallsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/ja_JP/process/adding-syscallsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/ko_KR/process/adding-syscallsmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget+/translations/sp_SP/process/adding-syscallsmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhtarget)}(h.. _addsyscalls:h]h}(h]h ]h"]h$]h&]refid addsyscallsuh1hhKhhhhhE/var/lib/git/docbuild/linux/Documentation/process/adding-syscalls.rstubhsection)}(hhh](htitle)}(hAdding a New System Callh]hAdding a New System Call}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hThis document describes what's involved in adding a new system call to the Linux kernel, over and above the normal submission advice in :ref:`Documentation/process/submitting-patches.rst `.h](hThis document describes what’s involved in adding a new system call to the Linux kernel, over and above the normal submission advice in }(hhhhhNhNubh)}(hG:ref:`Documentation/process/submitting-patches.rst `h]hinline)}(hhh]h,Documentation/process/submitting-patches.rst}(hhhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1hhhubah}(h]h ]h"]h$]h&]refdocprocess/adding-syscalls refdomainhreftyperef refexplicitrefwarn reftargetsubmittingpatchesuh1hhhhKhhubh.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hSystem Call Alternativesh]hSystem Call Alternatives}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh)}(hX8The first thing to consider when adding a new system call is whether one of the alternatives might be suitable instead. Although system calls are the most traditional and most obvious interaction points between userspace and the kernel, there are other possibilities -- choose what fits best for your interface.h]hX8The first thing to consider when adding a new system call is whether one of the alternatives might be suitable instead. Although system calls are the most traditional and most obvious interaction points between userspace and the kernel, there are other possibilities -- choose what fits best for your interface.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh block_quote)}(hX!- If the operations involved can be made to look like a filesystem-like object, it may make more sense to create a new filesystem or device. This also makes it easier to encapsulate the new functionality in a kernel module rather than requiring it to be built into the main kernel. - If the new functionality involves operations where the kernel notifies userspace that something has happened, then returning a new file descriptor for the relevant object allows userspace to use ``poll``/``select``/``epoll`` to receive that notification. - However, operations that don't map to :manpage:`read(2)`/:manpage:`write(2)`-like operations have to be implemented as :manpage:`ioctl(2)` requests, which can lead to a somewhat opaque API. - If you're just exposing runtime system information, a new node in sysfs (see ``Documentation/filesystems/sysfs.rst``) or the ``/proc`` filesystem may be more appropriate. However, access to these mechanisms requires that the relevant filesystem is mounted, which might not always be the case (e.g. in a namespaced/sandboxed/chrooted environment). Avoid adding any API to debugfs, as this is not considered a 'production' interface to userspace. - If the operation is specific to a particular file or file descriptor, then an additional :manpage:`fcntl(2)` command option may be more appropriate. However, :manpage:`fcntl(2)` is a multiplexing system call that hides a lot of complexity, so this option is best for when the new function is closely analogous to existing :manpage:`fcntl(2)` functionality, or the new functionality is very simple (for example, getting/setting a simple flag related to a file descriptor). - If the operation is specific to a particular task or process, then an additional :manpage:`prctl(2)` command option may be more appropriate. As with :manpage:`fcntl(2)`, this system call is a complicated multiplexor so is best reserved for near-analogs of existing ``prctl()`` commands or getting/setting a simple flag related to a process. h]h bullet_list)}(hhh](h list_item)}(hXIf the operations involved can be made to look like a filesystem-like object, it may make more sense to create a new filesystem or device. This also makes it easier to encapsulate the new functionality in a kernel module rather than requiring it to be built into the main kernel. - If the new functionality involves operations where the kernel notifies userspace that something has happened, then returning a new file descriptor for the relevant object allows userspace to use ``poll``/``select``/``epoll`` to receive that notification. - However, operations that don't map to :manpage:`read(2)`/:manpage:`write(2)`-like operations have to be implemented as :manpage:`ioctl(2)` requests, which can lead to a somewhat opaque API. h](h)}(hXIf the operations involved can be made to look like a filesystem-like object, it may make more sense to create a new filesystem or device. This also makes it easier to encapsulate the new functionality in a kernel module rather than requiring it to be built into the main kernel.h]hXIf the operations involved can be made to look like a filesystem-like object, it may make more sense to create a new filesystem or device. This also makes it easier to encapsulate the new functionality in a kernel module rather than requiring it to be built into the main kernel.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj*ubj)}(hX- If the new functionality involves operations where the kernel notifies userspace that something has happened, then returning a new file descriptor for the relevant object allows userspace to use ``poll``/``select``/``epoll`` to receive that notification. - However, operations that don't map to :manpage:`read(2)`/:manpage:`write(2)`-like operations have to be implemented as :manpage:`ioctl(2)` requests, which can lead to a somewhat opaque API. h]j$)}(hhh](j))}(hIf the new functionality involves operations where the kernel notifies userspace that something has happened, then returning a new file descriptor for the relevant object allows userspace to use ``poll``/``select``/``epoll`` to receive that notification.h]h)}(hIf the new functionality involves operations where the kernel notifies userspace that something has happened, then returning a new file descriptor for the relevant object allows userspace to use ``poll``/``select``/``epoll`` to receive that notification.h](hIf the new functionality involves operations where the kernel notifies userspace that something has happened, then returning a new file descriptor for the relevant object allows userspace to use }(hjGhhhNhNubhliteral)}(h``poll``h]hpoll}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjGubh/}(hjGhhhNhNubjP)}(h ``select``h]hselect}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjGubh/}hjGsbjP)}(h ``epoll``h]hepoll}(hjuhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjGubh to receive that notification.}(hjGhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjCubah}(h]h ]h"]h$]h&]uh1j(hj@ubj))}(hHowever, operations that don't map to :manpage:`read(2)`/:manpage:`write(2)`-like operations have to be implemented as :manpage:`ioctl(2)` requests, which can lead to a somewhat opaque API. h]h)}(hHowever, operations that don't map to :manpage:`read(2)`/:manpage:`write(2)`-like operations have to be implemented as :manpage:`ioctl(2)` requests, which can lead to a somewhat opaque API.h](h(However, operations that don’t map to }(hjhhhNhNubhmanpage)}(h:manpage:`read(2)`h]hread(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&] xml:spacepreservepathread(2)pagereadsection2uh1jhjubh/}(hjhhhNhNubj)}(h:manpage:`write(2)`h]hwrite(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjwrite(2)jwritejjuh1jhjubh+-like operations have to be implemented as }(hjhhhNhNubj)}(h:manpage:`ioctl(2)`h]hioctl(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjioctl(2)jioctljjuh1jhjubh3 requests, which can lead to a somewhat opaque API.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j(hj@ubeh}(h]h ]h"]h$]h&]bullet-uh1j#hhhKhj<ubah}(h]h ]h"]h$]h&]uh1jhhhKhj*ubeh}(h]h ]h"]h$]h&]uh1j(hj%ubj))}(hXIf you're just exposing runtime system information, a new node in sysfs (see ``Documentation/filesystems/sysfs.rst``) or the ``/proc`` filesystem may be more appropriate. However, access to these mechanisms requires that the relevant filesystem is mounted, which might not always be the case (e.g. in a namespaced/sandboxed/chrooted environment). Avoid adding any API to debugfs, as this is not considered a 'production' interface to userspace.h]h)}(hXIf you're just exposing runtime system information, a new node in sysfs (see ``Documentation/filesystems/sysfs.rst``) or the ``/proc`` filesystem may be more appropriate. However, access to these mechanisms requires that the relevant filesystem is mounted, which might not always be the case (e.g. in a namespaced/sandboxed/chrooted environment). Avoid adding any API to debugfs, as this is not considered a 'production' interface to userspace.h](hOIf you’re just exposing runtime system information, a new node in sysfs (see }(hjhhhNhNubjP)}(h'``Documentation/filesystems/sysfs.rst``h]h#Documentation/filesystems/sysfs.rst}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh ) or the }(hjhhhNhNubjP)}(h ``/proc``h]h/proc}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubhX< filesystem may be more appropriate. However, access to these mechanisms requires that the relevant filesystem is mounted, which might not always be the case (e.g. in a namespaced/sandboxed/chrooted environment). Avoid adding any API to debugfs, as this is not considered a ‘production’ interface to userspace.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK#hjubah}(h]h ]h"]h$]h&]uh1j(hj%ubj))}(hXIf the operation is specific to a particular file or file descriptor, then an additional :manpage:`fcntl(2)` command option may be more appropriate. However, :manpage:`fcntl(2)` is a multiplexing system call that hides a lot of complexity, so this option is best for when the new function is closely analogous to existing :manpage:`fcntl(2)` functionality, or the new functionality is very simple (for example, getting/setting a simple flag related to a file descriptor).h]h)}(hXIf the operation is specific to a particular file or file descriptor, then an additional :manpage:`fcntl(2)` command option may be more appropriate. However, :manpage:`fcntl(2)` is a multiplexing system call that hides a lot of complexity, so this option is best for when the new function is closely analogous to existing :manpage:`fcntl(2)` functionality, or the new functionality is very simple (for example, getting/setting a simple flag related to a file descriptor).h](hYIf the operation is specific to a particular file or file descriptor, then an additional }(hjChhhNhNubj)}(h:manpage:`fcntl(2)`h]hfcntl(2)}(hjKhhhNhNubah}(h]h ]jah"]h$]h&]jjjfcntl(2)jfcntljjuh1jhjCubh3 command option may be more appropriate. However, }(hjChhhNhNubj)}(h:manpage:`fcntl(2)`h]hfcntl(2)}(hj_hhhNhNubah}(h]h ]jah"]h$]h&]jjjfcntl(2)jfcntljjuh1jhjCubh is a multiplexing system call that hides a lot of complexity, so this option is best for when the new function is closely analogous to existing }(hjChhhNhNubj)}(h:manpage:`fcntl(2)`h]hfcntl(2)}(hjshhhNhNubah}(h]h ]jah"]h$]h&]jjjfcntl(2)jfcntljjuh1jhjCubh functionality, or the new functionality is very simple (for example, getting/setting a simple flag related to a file descriptor).}(hjChhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK)hj?ubah}(h]h ]h"]h$]h&]uh1j(hj%ubj))}(hXWIf the operation is specific to a particular task or process, then an additional :manpage:`prctl(2)` command option may be more appropriate. As with :manpage:`fcntl(2)`, this system call is a complicated multiplexor so is best reserved for near-analogs of existing ``prctl()`` commands or getting/setting a simple flag related to a process. h]h)}(hXUIf the operation is specific to a particular task or process, then an additional :manpage:`prctl(2)` command option may be more appropriate. As with :manpage:`fcntl(2)`, this system call is a complicated multiplexor so is best reserved for near-analogs of existing ``prctl()`` commands or getting/setting a simple flag related to a process.h](hQIf the operation is specific to a particular task or process, then an additional }(hjhhhNhNubj)}(h:manpage:`prctl(2)`h]hprctl(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjprctl(2)jprctljjuh1jhjubh2 command option may be more appropriate. As with }(hjhhhNhNubj)}(h:manpage:`fcntl(2)`h]hfcntl(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjfcntl(2)jfcntljjuh1jhjubha, this system call is a complicated multiplexor so is best reserved for near-analogs of existing }(hjhhhNhNubjP)}(h ``prctl()``h]hprctl()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh@ commands or getting/setting a simple flag related to a process.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK/hjubah}(h]h ]h"]h$]h&]uh1j(hj%ubeh}(h]h ]h"]h$]h&]jjuh1j#hhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhhhhubeh}(h]system-call-alternativesah ]h"]system call alternativesah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(h)Designing the API: Planning for Extensionh]h)Designing the API: Planning for Extension}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK7ubh)}(hA new system call forms part of the API of the kernel, and has to be supported indefinitely. As such, it's a very good idea to explicitly discuss the interface on the kernel mailing list, and it's important to plan for future extensions of the interface.h]hXA new system call forms part of the API of the kernel, and has to be supported indefinitely. As such, it’s a very good idea to explicitly discuss the interface on the kernel mailing list, and it’s important to plan for future extensions of the interface.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hjhhubh)}(hX](The syscall table is littered with historical examples where this wasn't done, together with the corresponding follow-up system calls -- ``eventfd``/``eventfd2``, ``dup2``/``dup3``, ``inotify_init``/``inotify_init1``, ``pipe``/``pipe2``, ``renameat``/``renameat2`` -- so learn from the history of the kernel and plan for extensions from the start.)h](h(The syscall table is littered with historical examples where this wasn’t done, together with the corresponding follow-up system calls -- }(hjhhhNhNubjP)}(h ``eventfd``h]heventfd}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh/}(hjhhhNhNubjP)}(h ``eventfd2``h]heventfd2}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh, }(hjhhhNhNubjP)}(h``dup2``h]hdup2}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh/}hjsbjP)}(h``dup3``h]hdup3}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh, }hjsbjP)}(h``inotify_init``h]h inotify_init}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh/}hjsbjP)}(h``inotify_init1``h]h inotify_init1}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh, }(hjhhhNhNubjP)}(h``pipe``h]hpipe}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh/}hjsbjP)}(h ``pipe2``h]hpipe2}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh, }hjsbjP)}(h ``renameat``h]hrenameat}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh/}hjsbjP)}(h ``renameat2``h]h renameat2}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubhT -- so learn from the history of the kernel and plan for extensions from the start.)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK>hjhhubh)}(hXjFor simpler system calls that only take a couple of arguments, the preferred way to allow for future extensibility is to include a flags argument to the system call. To make sure that userspace programs can safely use flags between kernel versions, check whether the flags value holds any unknown flags, and reject the system call (with ``EINVAL``) if it does::h](hXRFor simpler system calls that only take a couple of arguments, the preferred way to allow for future extensibility is to include a flags argument to the system call. To make sure that userspace programs can safely use flags between kernel versions, check whether the flags value holds any unknown flags, and reject the system call (with }(hjhhhNhNubjP)}(h ``EINVAL``h]hEINVAL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh ) if it does:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKDhjhhubh literal_block)}(hKif (flags & ~(THING_FLAG1 | THING_FLAG2 | THING_FLAG3)) return -EINVAL;h]hKif (flags & ~(THING_FLAG1 | THING_FLAG2 | THING_FLAG3)) return -EINVAL;}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKJhjhhubh)}(hI(If no flags values are used yet, check that the flags argument is zero.)h]hI(If no flags values are used yet, check that the flags argument is zero.)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKMhjhhubh)}(hXFor more sophisticated system calls that involve a larger number of arguments, it's preferred to encapsulate the majority of the arguments into a structure that is passed in by pointer. Such a structure can cope with future extension by including a size argument in the structure::h]hXFor more sophisticated system calls that involve a larger number of arguments, it’s preferred to encapsulate the majority of the arguments into a structure that is passed in by pointer. Such a structure can cope with future extension by including a size argument in the structure:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKOhjhhubj)}(hstruct xyzzy_params { u32 size; /* userspace sets p->size = sizeof(struct xyzzy_params) */ u32 param_1; u64 param_2; u64 param_3; };h]hstruct xyzzy_params { u32 size; /* userspace sets p->size = sizeof(struct xyzzy_params) */ u32 param_1; u64 param_2; u64 param_3; };}hj&sbah}(h]h ]h"]h$]h&]jjuh1jhhhKThjhhubh)}(hAs long as any subsequently added field, say ``param_4``, is designed so that a zero value gives the previous behaviour, then this allows both directions of version mismatch:h](h-As long as any subsequently added field, say }(hj4hhhNhNubjP)}(h ``param_4``h]hparam_4}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj4ubhv, is designed so that a zero value gives the previous behaviour, then this allows both directions of version mismatch:}(hj4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK[hjhhubj)}(hX- To cope with a later userspace program calling an older kernel, the kernel code should check that any memory beyond the size of the structure that it expects is zero (effectively checking that ``param_4 == 0``). - To cope with an older userspace program calling a newer kernel, the kernel code can zero-extend a smaller instance of the structure (effectively setting ``param_4 = 0``). h]j$)}(hhh](j))}(hTo cope with a later userspace program calling an older kernel, the kernel code should check that any memory beyond the size of the structure that it expects is zero (effectively checking that ``param_4 == 0``).h]h)}(hTo cope with a later userspace program calling an older kernel, the kernel code should check that any memory beyond the size of the structure that it expects is zero (effectively checking that ``param_4 == 0``).h](hTo cope with a later userspace program calling an older kernel, the kernel code should check that any memory beyond the size of the structure that it expects is zero (effectively checking that }(hj_hhhNhNubjP)}(h``param_4 == 0``h]h param_4 == 0}(hjghhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj_ubh).}(hj_hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK_hj[ubah}(h]h ]h"]h$]h&]uh1j(hjXubj))}(hTo cope with an older userspace program calling a newer kernel, the kernel code can zero-extend a smaller instance of the structure (effectively setting ``param_4 = 0``). h]h)}(hTo cope with an older userspace program calling a newer kernel, the kernel code can zero-extend a smaller instance of the structure (effectively setting ``param_4 = 0``).h](hTo cope with an older userspace program calling a newer kernel, the kernel code can zero-extend a smaller instance of the structure (effectively setting }(hjhhhNhNubjP)}(h``param_4 = 0``h]h param_4 = 0}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKbhjubah}(h]h ]h"]h$]h&]uh1j(hjXubeh}(h]h ]h"]h$]h&]jjuh1j#hhhK_hjTubah}(h]h ]h"]h$]h&]uh1jhhhK_hjhhubh)}(hSee :manpage:`perf_event_open(2)` and the ``perf_copy_attr()`` function (in ``kernel/events/core.c``) for an example of this approach.h](hSee }(hjhhhNhNubj)}(h:manpage:`perf_event_open(2)`h]hperf_event_open(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjperf_event_open(2)jperf_event_openjjuh1jhjubh and the }(hjhhhNhNubjP)}(h``perf_copy_attr()``h]hperf_copy_attr()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh function (in }(hjhhhNhNubjP)}(h``kernel/events/core.c``h]hkernel/events/core.c}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh") for an example of this approach.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKfhjhhubeh}(h](designing-the-api-planning-for-extensionah ]h"])designing the api: planning for extensionah$]h&]uh1hhhhhhhhK7ubh)}(hhh](h)}(h'Designing the API: Other Considerationsh]h'Designing the API: Other Considerations}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhKkubh)}(hXIf your new system call allows userspace to refer to a kernel object, it should use a file descriptor as the handle for that object -- don't invent a new type of userspace object handle when the kernel already has mechanisms and well-defined semantics for using file descriptors.h]hXIf your new system call allows userspace to refer to a kernel object, it should use a file descriptor as the handle for that object -- don’t invent a new type of userspace object handle when the kernel already has mechanisms and well-defined semantics for using file descriptors.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKmhj hhubh)}(hXpIf your new :manpage:`xyzzy(2)` system call does return a new file descriptor, then the flags argument should include a value that is equivalent to setting ``O_CLOEXEC`` on the new FD. This makes it possible for userspace to close the timing window between ``xyzzy()`` and calling ``fcntl(fd, F_SETFD, FD_CLOEXEC)``, where an unexpected ``fork()`` and ``execve()`` in another thread could leak a descriptor to the exec'ed program. (However, resist the temptation to re-use the actual value of the ``O_CLOEXEC`` constant, as it is architecture-specific and is part of a numbering space of ``O_*`` flags that is fairly full.)h](h If your new }(hj(hhhNhNubj)}(h:manpage:`xyzzy(2)`h]hxyzzy(2)}(hj0hhhNhNubah}(h]h ]jah"]h$]h&]jjjxyzzy(2)jxyzzyjjuh1jhj(ubh} system call does return a new file descriptor, then the flags argument should include a value that is equivalent to setting }(hj(hhhNhNubjP)}(h ``O_CLOEXEC``h]h O_CLOEXEC}(hjDhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj(ubhY on the new FD. This makes it possible for userspace to close the timing window between }(hj(hhhNhNubjP)}(h ``xyzzy()``h]hxyzzy()}(hjVhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj(ubh and calling }(hj(hhhNhNubjP)}(h"``fcntl(fd, F_SETFD, FD_CLOEXEC)``h]hfcntl(fd, F_SETFD, FD_CLOEXEC)}(hjhhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj(ubh, where an unexpected }(hj(hhhNhNubjP)}(h ``fork()``h]hfork()}(hjzhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj(ubh and }(hj(hhhNhNubjP)}(h ``execve()``h]hexecve()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj(ubh in another thread could leak a descriptor to the exec’ed program. (However, resist the temptation to re-use the actual value of the }(hj(hhhNhNubjP)}(h ``O_CLOEXEC``h]h O_CLOEXEC}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj(ubhN constant, as it is architecture-specific and is part of a numbering space of }(hj(hhhNhNubjP)}(h``O_*``h]hO_*}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj(ubh flags that is fairly full.)}(hj(hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKrhj hhubh)}(hXVIf your system call returns a new file descriptor, you should also consider what it means to use the :manpage:`poll(2)` family of system calls on that file descriptor. Making a file descriptor ready for reading or writing is the normal way for the kernel to indicate to userspace that an event has occurred on the corresponding kernel object.h](heIf your system call returns a new file descriptor, you should also consider what it means to use the }(hjhhhNhNubj)}(h:manpage:`poll(2)`h]hpoll(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjpoll(2)jpolljjuh1jhjubh family of system calls on that file descriptor. Making a file descriptor ready for reading or writing is the normal way for the kernel to indicate to userspace that an event has occurred on the corresponding kernel object.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK|hj hhubh)}(hJIf your new :manpage:`xyzzy(2)` system call involves a filename argument::h](h If your new }(hjhhhNhNubj)}(h:manpage:`xyzzy(2)`h]hxyzzy(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjxyzzy(2)jxyzzyjjuh1jhjubh* system call involves a filename argument:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubj)}(h@int sys_xyzzy(const char __user *path, ..., unsigned int flags);h]h@int sys_xyzzy(const char __user *path, ..., unsigned int flags);}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj hhubh)}(hWyou should also consider whether an :manpage:`xyzzyat(2)` version is more appropriate::h](h$you should also consider whether an }(hjhhhNhNubj)}(h:manpage:`xyzzyat(2)`h]h xyzzyat(2)}(hj"hhhNhNubah}(h]h ]jah"]h$]h&]jjj xyzzyat(2)jxyzzyatjjuh1jhjubh version is more appropriate:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubj)}(hKint sys_xyzzyat(int dfd, const char __user *path, ..., unsigned int flags);h]hKint sys_xyzzyat(int dfd, const char __user *path, ..., unsigned int flags);}hj<sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj hhubh)}(hXThis allows more flexibility for how userspace specifies the file in question; in particular it allows userspace to request the functionality for an already-opened file descriptor using the ``AT_EMPTY_PATH`` flag, effectively giving an :manpage:`fxyzzy(3)` operation for free::h](hThis allows more flexibility for how userspace specifies the file in question; in particular it allows userspace to request the functionality for an already-opened file descriptor using the }(hjJhhhNhNubjP)}(h``AT_EMPTY_PATH``h]h AT_EMPTY_PATH}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjJubh flag, effectively giving an }(hjJhhhNhNubj)}(h:manpage:`fxyzzy(3)`h]h fxyzzy(3)}(hjdhhhNhNubah}(h]h ]jah"]h$]h&]jjj fxyzzy(3)jfxyzzyj3uh1jhjJubh operation for free:}(hjJhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubj)}(h- xyzzyat(AT_FDCWD, path, ..., 0) is equivalent to xyzzy(path,...) - xyzzyat(fd, "", ..., AT_EMPTY_PATH) is equivalent to fxyzzy(fd, ...)h]h- xyzzyat(AT_FDCWD, path, ..., 0) is equivalent to xyzzy(path,...) - xyzzyat(fd, "", ..., AT_EMPTY_PATH) is equivalent to fxyzzy(fd, ...)}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj hhubh)}(h(For more details on the rationale of the \*at() calls, see the :manpage:`openat(2)` man page; for an example of AT_EMPTY_PATH, see the :manpage:`fstatat(2)` man page.)h](h@(For more details on the rationale of the *at() calls, see the }(hjhhhNhNubj)}(h:manpage:`openat(2)`h]h openat(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjj openat(2)jopenatjjuh1jhjubh4 man page; for an example of AT_EMPTY_PATH, see the }(hjhhhNhNubj)}(h:manpage:`fstatat(2)`h]h fstatat(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjj fstatat(2)jfstatatjjuh1jhjubh man page.)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hIf your new :manpage:`xyzzy(2)` system call involves a parameter describing an offset within a file, make its type ``loff_t`` so that 64-bit offsets can be supported even on 32-bit architectures.h](h If your new }(hjhhhNhNubj)}(h:manpage:`xyzzy(2)`h]hxyzzy(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjxyzzy(2)jxyzzyjjuh1jhjubhT system call involves a parameter describing an offset within a file, make its type }(hjhhhNhNubjP)}(h ``loff_t``h]hloff_t}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubhF so that 64-bit offsets can be supported even on 32-bit architectures.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hXBIf your new :manpage:`xyzzy(2)` system call involves privileged functionality, it needs to be governed by the appropriate Linux capability bit (checked with a call to ``capable()``), as described in the :manpage:`capabilities(7)` man page. Choose an existing capability bit that governs related functionality, but try to avoid combining lots of only vaguely related functions together under the same bit, as this goes against capabilities' purpose of splitting the power of root. In particular, avoid adding new uses of the already overly-general ``CAP_SYS_ADMIN`` capability.h](h If your new }(hjhhhNhNubj)}(h:manpage:`xyzzy(2)`h]hxyzzy(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjxyzzy(2)jxyzzyjjuh1jhjubh system call involves privileged functionality, it needs to be governed by the appropriate Linux capability bit (checked with a call to }(hjhhhNhNubjP)}(h ``capable()``h]h capable()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh), as described in the }(hjhhhNhNubj)}(h:manpage:`capabilities(7)`h]hcapabilities(7)}(hj%hhhNhNubah}(h]h ]jah"]h$]h&]jjjcapabilities(7)j capabilitiesj7uh1jhjubhXB man page. Choose an existing capability bit that governs related functionality, but try to avoid combining lots of only vaguely related functions together under the same bit, as this goes against capabilities’ purpose of splitting the power of root. In particular, avoid adding new uses of the already overly-general }(hjhhhNhNubjP)}(h``CAP_SYS_ADMIN``h]h CAP_SYS_ADMIN}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh capability.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hX:If your new :manpage:`xyzzy(2)` system call manipulates a process other than the calling process, it should be restricted (using a call to ``ptrace_may_access()``) so that only a calling process with the same permissions as the target process, or with the necessary capabilities, can manipulate the target process.h](h If your new }(hjRhhhNhNubj)}(h:manpage:`xyzzy(2)`h]hxyzzy(2)}(hjZhhhNhNubah}(h]h ]jah"]h$]h&]jjjxyzzy(2)jxyzzyjjuh1jhjRubhl system call manipulates a process other than the calling process, it should be restricted (using a call to }(hjRhhhNhNubjP)}(h``ptrace_may_access()``h]hptrace_may_access()}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjRubh) so that only a calling process with the same permissions as the target process, or with the necessary capabilities, can manipulate the target process.}(hjRhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj hhubh)}(hXNFinally, be aware that some non-x86 architectures have an easier time if system call parameters that are explicitly 64-bit fall on odd-numbered arguments (i.e. parameter 1, 3, 5), to allow use of contiguous pairs of 32-bit registers. (This concern does not apply if the arguments are part of a structure that's passed in by pointer.)h]hXPFinally, be aware that some non-x86 architectures have an easier time if system call parameters that are explicitly 64-bit fall on odd-numbered arguments (i.e. parameter 1, 3, 5), to allow use of contiguous pairs of 32-bit registers. (This concern does not apply if the arguments are part of a structure that’s passed in by pointer.)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj hhubeh}(h]&designing-the-api-other-considerationsah ]h"]'designing the api: other considerationsah$]h&]uh1hhhhhhhhKkubh)}(hhh](h)}(hProposing the APIh]hProposing the API}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hTo make new system calls easy to review, it's best to divide up the patchset into separate chunks. These should include at least the following items as distinct commits (each of which is described further below):h]hTo make new system calls easy to review, it’s best to divide up the patchset into separate chunks. These should include at least the following items as distinct commits (each of which is described further below):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(hX - The core implementation of the system call, together with prototypes, generic numbering, Kconfig changes and fallback stub implementation. - Wiring up of the new system call for one particular architecture, usually x86 (including all of x86_64, x86_32 and x32). - A demonstration of the use of the new system call in userspace via a selftest in ``tools/testing/selftests/``. - A draft man-page for the new system call, either as plain text in the cover letter, or as a patch to the (separate) man-pages repository. h]j$)}(hhh](j))}(hThe core implementation of the system call, together with prototypes, generic numbering, Kconfig changes and fallback stub implementation.h]h)}(hThe core implementation of the system call, together with prototypes, generic numbering, Kconfig changes and fallback stub implementation.h]hThe core implementation of the system call, together with prototypes, generic numbering, Kconfig changes and fallback stub implementation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hxWiring up of the new system call for one particular architecture, usually x86 (including all of x86_64, x86_32 and x32).h]h)}(hxWiring up of the new system call for one particular architecture, usually x86 (including all of x86_64, x86_32 and x32).h]hxWiring up of the new system call for one particular architecture, usually x86 (including all of x86_64, x86_32 and x32).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hnA demonstration of the use of the new system call in userspace via a selftest in ``tools/testing/selftests/``.h]h)}(hnA demonstration of the use of the new system call in userspace via a selftest in ``tools/testing/selftests/``.h](hQA demonstration of the use of the new system call in userspace via a selftest in }(hjhhhNhNubjP)}(h``tools/testing/selftests/``h]htools/testing/selftests/}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hA draft man-page for the new system call, either as plain text in the cover letter, or as a patch to the (separate) man-pages repository. h]h)}(hA draft man-page for the new system call, either as plain text in the cover letter, or as a patch to the (separate) man-pages repository.h]hA draft man-page for the new system call, either as plain text in the cover letter, or as a patch to the (separate) man-pages repository.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]jjuh1j#hhhKhjubah}(h]h ]h"]h$]h&]uh1jhhhKhjhhubh)}(htNew system call proposals, like any change to the kernel's API, should always be cc'ed to linux-api@vger.kernel.org.h](h^New system call proposals, like any change to the kernel’s API, should always be cc’ed to }(hj@hhhNhNubh reference)}(hlinux-api@vger.kernel.orgh]hlinux-api@vger.kernel.org}(hjJhhhNhNubah}(h]h ]h"]h$]h&]refuri mailto:linux-api@vger.kernel.orguh1jHhj@ubh.}(hj@hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]proposing-the-apiah ]h"]proposing the apiah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h"Generic System Call Implementationh]h"Generic System Call Implementation}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhjlhhhhhKubh)}(hXThe main entry point for your new :manpage:`xyzzy(2)` system call will be called ``sys_xyzzy()``, but you add this entry point with the appropriate ``SYSCALL_DEFINEn()`` macro rather than explicitly. The 'n' indicates the number of arguments to the system call, and the macro takes the system call name followed by the (type, name) pairs for the parameters as arguments. Using this macro allows metadata about the new system call to be made available for other tools.h](h"The main entry point for your new }(hj}hhhNhNubj)}(h:manpage:`xyzzy(2)`h]hxyzzy(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjxyzzy(2)jxyzzyjjuh1jhj}ubh system call will be called }(hj}hhhNhNubjP)}(h``sys_xyzzy()``h]h sys_xyzzy()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj}ubh4, but you add this entry point with the appropriate }(hj}hhhNhNubjP)}(h``SYSCALL_DEFINEn()``h]hSYSCALL_DEFINEn()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj}ubhX0 macro rather than explicitly. The ‘n’ indicates the number of arguments to the system call, and the macro takes the system call name followed by the (type, name) pairs for the parameters as arguments. Using this macro allows metadata about the new system call to be made available for other tools.}(hj}hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubh)}(hThe new entry point also needs a corresponding function prototype, in ``include/linux/syscalls.h``, marked as asmlinkage to match the way that system calls are invoked::h](hFThe new entry point also needs a corresponding function prototype, in }(hjhhhNhNubjP)}(h``include/linux/syscalls.h``h]hinclude/linux/syscalls.h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubhF, marked as asmlinkage to match the way that system calls are invoked:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubj)}(hasmlinkage long sys_xyzzy(...);h]hasmlinkage long sys_xyzzy(...);}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjlhhubh)}(hXSome architectures (e.g. x86) have their own architecture-specific syscall tables, but several other architectures share a generic syscall table. Add your new system call to the generic list by adding an entry to the list in ``include/uapi/asm-generic/unistd.h``::h](hSome architectures (e.g. x86) have their own architecture-specific syscall tables, but several other architectures share a generic syscall table. Add your new system call to the generic list by adding an entry to the list in }(hjhhhNhNubjP)}(h%``include/uapi/asm-generic/unistd.h``h]h!include/uapi/asm-generic/unistd.h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh:}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubj)}(h7#define __NR_xyzzy 292 __SYSCALL(__NR_xyzzy, sys_xyzzy)h]h7#define __NR_xyzzy 292 __SYSCALL(__NR_xyzzy, sys_xyzzy)}hj sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjlhhubh)}(hAlso update the __NR_syscalls count to reflect the additional system call, and note that if multiple new system calls are added in the same merge window, your new syscall number may get adjusted to resolve conflicts.h]hAlso update the __NR_syscalls count to reflect the additional system call, and note that if multiple new system calls are added in the same merge window, your new syscall number may get adjusted to resolve conflicts.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubh)}(hThe file ``kernel/sys_ni.c`` provides a fallback stub implementation of each system call, returning ``-ENOSYS``. Add your new system call here too::h](h The file }(hj- hhhNhNubjP)}(h``kernel/sys_ni.c``h]hkernel/sys_ni.c}(hj5 hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj- ubhH provides a fallback stub implementation of each system call, returning }(hj- hhhNhNubjP)}(h ``-ENOSYS``h]h-ENOSYS}(hjG hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj- ubh%. Add your new system call here too:}(hj- hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubj)}(hCOND_SYSCALL(xyzzy);h]hCOND_SYSCALL(xyzzy);}hj_ sbah}(h]h ]h"]h$]h&]jjuh1jhhhKhjlhhubh)}(hYour new kernel functionality, and the system call that controls it, should normally be optional, so add a ``CONFIG`` option (typically to ``init/Kconfig``) for it. As usual for new ``CONFIG`` options:h](hkYour new kernel functionality, and the system call that controls it, should normally be optional, so add a }(hjm hhhNhNubjP)}(h ``CONFIG``h]hCONFIG}(hju hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjm ubh option (typically to }(hjm hhhNhNubjP)}(h``init/Kconfig``h]h init/Kconfig}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjm ubh) for it. As usual for new }(hjm hhhNhNubjP)}(h ``CONFIG``h]hCONFIG}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjm ubh options:}(hjm hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubj)}(hX- Include a description of the new functionality and system call controlled by the option. - Make the option depend on EXPERT if it should be hidden from normal users. - Make any new source files implementing the function dependent on the CONFIG option in the Makefile (e.g. ``obj-$(CONFIG_XYZZY_SYSCALL) += xyzzy.o``). - Double check that the kernel still builds with the new CONFIG option turned off. h]j$)}(hhh](j))}(hXInclude a description of the new functionality and system call controlled by the option.h]h)}(hXInclude a description of the new functionality and system call controlled by the option.h]hXInclude a description of the new functionality and system call controlled by the option.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hJMake the option depend on EXPERT if it should be hidden from normal users.h]h)}(hj h]hJMake the option depend on EXPERT if it should be hidden from normal users.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hMake any new source files implementing the function dependent on the CONFIG option in the Makefile (e.g. ``obj-$(CONFIG_XYZZY_SYSCALL) += xyzzy.o``).h]h)}(hMake any new source files implementing the function dependent on the CONFIG option in the Makefile (e.g. ``obj-$(CONFIG_XYZZY_SYSCALL) += xyzzy.o``).h](hiMake any new source files implementing the function dependent on the CONFIG option in the Makefile (e.g. }(hj hhhNhNubjP)}(h*``obj-$(CONFIG_XYZZY_SYSCALL) += xyzzy.o``h]h&obj-$(CONFIG_XYZZY_SYSCALL) += xyzzy.o}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj ubh).}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubj))}(hQDouble check that the kernel still builds with the new CONFIG option turned off. h]h)}(hPDouble check that the kernel still builds with the new CONFIG option turned off.h]hPDouble check that the kernel still builds with the new CONFIG option turned off.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j(hj ubeh}(h]h ]h"]h$]h&]jjuh1j#hhhKhj ubah}(h]h ]h"]h$]h&]uh1jhhhKhjlhhubh)}(h.To summarize, you need a commit that includes:h]h.To summarize, you need a commit that includes:}(hj5 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlhhubj)}(hX- ``CONFIG`` option for the new function, normally in ``init/Kconfig`` - ``SYSCALL_DEFINEn(xyzzy, ...)`` for the entry point - corresponding prototype in ``include/linux/syscalls.h`` - generic table entry in ``include/uapi/asm-generic/unistd.h`` - fallback stub in ``kernel/sys_ni.c`` h]j$)}(hhh](j))}(hD``CONFIG`` option for the new function, normally in ``init/Kconfig``h]h)}(hjL h](jP)}(h ``CONFIG``h]hCONFIG}(hjQ hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjN ubh* option for the new function, normally in }(hjN hhhNhNubjP)}(h``init/Kconfig``h]h init/Kconfig}(hjc hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjN ubeh}(h]h ]h"]h$]h&]uh1hhhhKhjJ ubah}(h]h ]h"]h$]h&]uh1j(hjG ubj))}(h3``SYSCALL_DEFINEn(xyzzy, ...)`` for the entry pointh]h)}(hj h](jP)}(h``SYSCALL_DEFINEn(xyzzy, ...)``h]hSYSCALL_DEFINEn(xyzzy, ...)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj ubh for the entry point}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhj} ubah}(h]h ]h"]h$]h&]uh1j(hjG ubj))}(h7corresponding prototype in ``include/linux/syscalls.h``h]h)}(hj h](hcorresponding prototype in }(hj hhhNhNubjP)}(h``include/linux/syscalls.h``h]hinclude/linux/syscalls.h}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhj ubeh}(h]h ]h"]h$]h&]uh1hhhhKhj ubah}(h]h ]h"]h$]h&]uh1j(hjG ubj))}(hubah}(h]h ]h"]h$]h&]uh1hhhhMhj:ubah}(h]h ]h"]h$]h&]uh1j(hj7ubj))}(h6git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git h]h)}(h4git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.gith]h4git://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj[ubah}(h]h ]h"]h$]h&]uh1j(hj7ubeh}(h]h ]h"]h$]h&]jjuh1j#hhhMhj3ubah}(h]h ]h"]h$]h&]uh1jhhhMhjhhubeh}(h]testingah ]h"]testingah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hMan Pageh]hMan Page}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hX All new system calls should come with a complete man page, ideally using groff markup, but plain text will do. If groff is used, it's helpful to include a pre-rendered ASCII version of the man page in the cover email for the patchset, for the convenience of reviewers.h]hXAll new system calls should come with a complete man page, ideally using groff markup, but plain text will do. If groff is used, it’s helpful to include a pre-rendered ASCII version of the man page in the cover email for the patchset, for the convenience of reviewers.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hThe man page should be cc'ed to linux-man@vger.kernel.org For more details, see https://www.kernel.org/doc/man-pages/patches.htmlh](h"The man page should be cc’ed to }(hjhhhNhNubjI)}(hlinux-man@vger.kernel.orgh]hlinux-man@vger.kernel.org}(hjhhhNhNubah}(h]h ]h"]h$]h&]refuri mailto:linux-man@vger.kernel.orguh1jHhjubh For more details, see }(hjhhhNhNubjI)}(h1https://www.kernel.org/doc/man-pages/patches.htmlh]h1https://www.kernel.org/doc/man-pages/patches.html}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]man-pageah ]h"]man pageah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h&Do not call System Calls in the Kernelh]h&Do not call System Calls in the Kernel}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hXSystem calls are, as stated above, interaction points between userspace and the kernel. Therefore, system call functions such as ``sys_xyzzy()`` or ``compat_sys_xyzzy()`` should only be called from userspace via the syscall table, but not from elsewhere in the kernel. If the syscall functionality is useful to be used within the kernel, needs to be shared between an old and a new syscall, or needs to be shared between a syscall and its compatibility variant, it should be implemented by means of a "helper" function (such as ``ksys_xyzzy()``). This kernel function may then be called within the syscall stub (``sys_xyzzy()``), the compatibility syscall stub (``compat_sys_xyzzy()``), and/or other kernel code.h](hSystem calls are, as stated above, interaction points between userspace and the kernel. Therefore, system call functions such as }(hjhhhNhNubjP)}(h``sys_xyzzy()``h]h sys_xyzzy()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh or }(hjhhhNhNubjP)}(h``compat_sys_xyzzy()``h]hcompat_sys_xyzzy()}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubhXk should only be called from userspace via the syscall table, but not from elsewhere in the kernel. If the syscall functionality is useful to be used within the kernel, needs to be shared between an old and a new syscall, or needs to be shared between a syscall and its compatibility variant, it should be implemented by means of a “helper” function (such as }(hjhhhNhNubjP)}(h``ksys_xyzzy()``h]h ksys_xyzzy()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubhE). This kernel function may then be called within the syscall stub (}(hjhhhNhNubjP)}(h``sys_xyzzy()``h]h sys_xyzzy()}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh#), the compatibility syscall stub (}(hjhhhNhNubjP)}(h``compat_sys_xyzzy()``h]hcompat_sys_xyzzy()}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh), and/or other kernel code.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hX=At least on 64-bit x86, it will be a hard requirement from v4.17 onwards to not call system call functions in the kernel. It uses a different calling convention for system calls where ``struct pt_regs`` is decoded on-the-fly in a syscall wrapper which then hands processing over to the actual syscall function. This means that only those parameters which are actually needed for a specific syscall are passed on during syscall entry, instead of filling in six CPU registers with random user space content all the time (which may cause serious trouble down the call chain).h](hAt least on 64-bit x86, it will be a hard requirement from v4.17 onwards to not call system call functions in the kernel. It uses a different calling convention for system calls where }(hjXhhhNhNubjP)}(h``struct pt_regs``h]hstruct pt_regs}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjXubhXr is decoded on-the-fly in a syscall wrapper which then hands processing over to the actual syscall function. This means that only those parameters which are actually needed for a specific syscall are passed on during syscall entry, instead of filling in six CPU registers with random user space content all the time (which may cause serious trouble down the call chain).}(hjXhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hMoreover, rules on how data may be accessed may differ between kernel data and user data. This is another reason why calling ``sys_xyzzy()`` is generally a bad idea.h](h~Moreover, rules on how data may be accessed may differ between kernel data and user data. This is another reason why calling }(hjxhhhNhNubjP)}(h``sys_xyzzy()``h]h sys_xyzzy()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjxubh is generally a bad idea.}(hjxhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hExceptions to this rule are only allowed in architecture-specific overrides, architecture-specific compatibility wrappers, or other code in arch/.h]hExceptions to this rule are only allowed in architecture-specific overrides, architecture-specific compatibility wrappers, or other code in arch/.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubeh}(h]&do-not-call-system-calls-in-the-kernelah ]h"]&do not call system calls in the kernelah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hReferences and Sourcesh]hReferences and Sources}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubj)}(hX - LWN article from Michael Kerrisk on use of flags argument in system calls: https://lwn.net/Articles/585415/ - LWN article from Michael Kerrisk on how to handle unknown flags in a system call: https://lwn.net/Articles/588444/ - LWN article from Jake Edge describing constraints on 64-bit system call arguments: https://lwn.net/Articles/311630/ - Pair of LWN articles from David Drysdale that describe the system call implementation paths in detail for v3.14: - https://lwn.net/Articles/604287/ - https://lwn.net/Articles/604515/ - Architecture-specific requirements for system calls are discussed in the :manpage:`syscall(2)` man-page: http://man7.org/linux/man-pages/man2/syscall.2.html#NOTES - Collated emails from Linus Torvalds discussing the problems with ``ioctl()``: https://yarchive.net/comp/linux/ioctl.html - "How to not invent kernel interfaces", Arnd Bergmann, https://www.ukuug.org/events/linux2007/2007/papers/Bergmann.pdf - LWN article from Michael Kerrisk on avoiding new uses of CAP_SYS_ADMIN: https://lwn.net/Articles/486306/ - Recommendation from Andrew Morton that all related information for a new system call should come in the same email thread: https://lore.kernel.org/r/20140724144747.3041b208832bbdf9fbce5d96@linux-foundation.org - Recommendation from Michael Kerrisk that a new system call should come with a man page: https://lore.kernel.org/r/CAKgNAkgMA39AfoSoA5Pe1r9N+ZzfYQNvNPvcRN7tOvRb8+v06Q@mail.gmail.com - Suggestion from Thomas Gleixner that x86 wire-up should be in a separate commit: https://lore.kernel.org/r/alpine.DEB.2.11.1411191249560.3909@nanos - Suggestion from Greg Kroah-Hartman that it's good for new system calls to come with a man-page & selftest: https://lore.kernel.org/r/20140320025530.GA25469@kroah.com - Discussion from Michael Kerrisk of new system call vs. :manpage:`prctl(2)` extension: https://lore.kernel.org/r/CAHO5Pa3F2MjfTtfNxa8LbnkeeU8=YJ+9tDqxZpw7Gz59E-4AUg@mail.gmail.com - Suggestion from Ingo Molnar that system calls that involve multiple arguments should encapsulate those arguments in a struct, which includes a size field for future extensibility: https://lore.kernel.org/r/20150730083831.GA22182@gmail.com - Numbering oddities arising from (re-)use of O_* numbering space flags: - commit 75069f2b5bfb ("vfs: renumber FMODE_NONOTIFY and add to uniqueness check") - commit 12ed2e36c98a ("fanotify: FMODE_NONOTIFY and __O_SYNC in sparc conflict") - commit bb458c644a59 ("Safer ABI for O_TMPFILE") - Discussion from Matthew Wilcox about restrictions on 64-bit arguments: https://lore.kernel.org/r/20081212152929.GM26095@parisc-linux.org - Recommendation from Greg Kroah-Hartman that unknown flags should be policed: https://lore.kernel.org/r/20140717193330.GB4703@kroah.com - Recommendation from Linus Torvalds that x32 system calls should prefer compatibility with 64-bit versions rather than 32-bit versions: https://lore.kernel.org/r/CA+55aFxfmwfB7jbbrXxa=K7VBYPfAvmu3XOkGrLbB1UFjX1+Ew@mail.gmail.comh]j$)}(hhh](j))}(hkLWN article from Michael Kerrisk on use of flags argument in system calls: https://lwn.net/Articles/585415/h]h)}(hkLWN article from Michael Kerrisk on use of flags argument in system calls: https://lwn.net/Articles/585415/h](hKLWN article from Michael Kerrisk on use of flags argument in system calls: }(hjhhhNhNubjI)}(h https://lwn.net/Articles/585415/h]h https://lwn.net/Articles/585415/}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hrLWN article from Michael Kerrisk on how to handle unknown flags in a system call: https://lwn.net/Articles/588444/h]h)}(hrLWN article from Michael Kerrisk on how to handle unknown flags in a system call: https://lwn.net/Articles/588444/h](hRLWN article from Michael Kerrisk on how to handle unknown flags in a system call: }(hjhhhNhNubjI)}(h https://lwn.net/Articles/588444/h]h https://lwn.net/Articles/588444/}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hsLWN article from Jake Edge describing constraints on 64-bit system call arguments: https://lwn.net/Articles/311630/h]h)}(hsLWN article from Jake Edge describing constraints on 64-bit system call arguments: https://lwn.net/Articles/311630/h](hSLWN article from Jake Edge describing constraints on 64-bit system call arguments: }(hjhhhNhNubjI)}(h https://lwn.net/Articles/311630/h]h https://lwn.net/Articles/311630/}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurij"uh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hPair of LWN articles from David Drysdale that describe the system call implementation paths in detail for v3.14: - https://lwn.net/Articles/604287/ - https://lwn.net/Articles/604515/ h](h)}(hpPair of LWN articles from David Drysdale that describe the system call implementation paths in detail for v3.14:h]hpPair of LWN articles from David Drysdale that describe the system call implementation paths in detail for v3.14:}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj;ubj)}(hF- https://lwn.net/Articles/604287/ - https://lwn.net/Articles/604515/ h]j$)}(hhh](j))}(h https://lwn.net/Articles/604287/h]h)}(hjVh]jI)}(hjVh]h https://lwn.net/Articles/604287/}(hj[hhhNhNubah}(h]h ]h"]h$]h&]refurijVuh1jHhjXubah}(h]h ]h"]h$]h&]uh1hhhhMhjTubah}(h]h ]h"]h$]h&]uh1j(hjQubj))}(h!https://lwn.net/Articles/604515/ h]h)}(h https://lwn.net/Articles/604515/h]jI)}(hj{h]h https://lwn.net/Articles/604515/}(hj}hhhNhNubah}(h]h ]h"]h$]h&]refurij{uh1jHhjyubah}(h]h ]h"]h$]h&]uh1hhhhMhjuubah}(h]h ]h"]h$]h&]uh1j(hjQubeh}(h]h ]h"]h$]h&]jjuh1j#hhhMhjMubah}(h]h ]h"]h$]h&]uh1jhhhMhj;ubeh}(h]h ]h"]h$]h&]uh1j(hjubj))}(hArchitecture-specific requirements for system calls are discussed in the :manpage:`syscall(2)` man-page: http://man7.org/linux/man-pages/man2/syscall.2.html#NOTESh]h)}(hArchitecture-specific requirements for system calls are discussed in the :manpage:`syscall(2)` man-page: http://man7.org/linux/man-pages/man2/syscall.2.html#NOTESh](hIArchitecture-specific requirements for system calls are discussed in the }(hjhhhNhNubj)}(h:manpage:`syscall(2)`h]h syscall(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjj syscall(2)jsyscalljjuh1jhjubh man-page: }(hjhhhNhNubjI)}(h9http://man7.org/linux/man-pages/man2/syscall.2.html#NOTESh]h9http://man7.org/linux/man-pages/man2/syscall.2.html#NOTES}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hxCollated emails from Linus Torvalds discussing the problems with ``ioctl()``: https://yarchive.net/comp/linux/ioctl.htmlh]h)}(hxCollated emails from Linus Torvalds discussing the problems with ``ioctl()``: https://yarchive.net/comp/linux/ioctl.htmlh](hACollated emails from Linus Torvalds discussing the problems with }(hjhhhNhNubjP)}(h ``ioctl()``h]hioctl()}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jOhjubh: }(hjhhhNhNubjI)}(h*https://yarchive.net/comp/linux/ioctl.htmlh]h*https://yarchive.net/comp/linux/ioctl.html}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hu"How to not invent kernel interfaces", Arnd Bergmann, https://www.ukuug.org/events/linux2007/2007/papers/Bergmann.pdfh]h)}(hu"How to not invent kernel interfaces", Arnd Bergmann, https://www.ukuug.org/events/linux2007/2007/papers/Bergmann.pdfh](h:“How to not invent kernel interfaces”, Arnd Bergmann, }(hj!hhhNhNubjI)}(h?https://www.ukuug.org/events/linux2007/2007/papers/Bergmann.pdfh]h?https://www.ukuug.org/events/linux2007/2007/papers/Bergmann.pdf}(hj)hhhNhNubah}(h]h ]h"]h$]h&]refurij+uh1jHhj!ubeh}(h]h ]h"]h$]h&]uh1hhhhM!hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hhLWN article from Michael Kerrisk on avoiding new uses of CAP_SYS_ADMIN: https://lwn.net/Articles/486306/h]h)}(hhLWN article from Michael Kerrisk on avoiding new uses of CAP_SYS_ADMIN: https://lwn.net/Articles/486306/h](hHLWN article from Michael Kerrisk on avoiding new uses of CAP_SYS_ADMIN: }(hjHhhhNhNubjI)}(h https://lwn.net/Articles/486306/h]h https://lwn.net/Articles/486306/}(hjPhhhNhNubah}(h]h ]h"]h$]h&]refurijRuh1jHhjHubeh}(h]h ]h"]h$]h&]uh1hhhhM#hjDubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hRecommendation from Andrew Morton that all related information for a new system call should come in the same email thread: https://lore.kernel.org/r/20140724144747.3041b208832bbdf9fbce5d96@linux-foundation.orgh]h)}(hRecommendation from Andrew Morton that all related information for a new system call should come in the same email thread: https://lore.kernel.org/r/20140724144747.3041b208832bbdf9fbce5d96@linux-foundation.orgh](h{Recommendation from Andrew Morton that all related information for a new system call should come in the same email thread: }(hjohhhNhNubjI)}(hVhttps://lore.kernel.org/r/20140724144747.3041b208832bbdf9fbce5d96@linux-foundation.orgh]hVhttps://lore.kernel.org/r/20140724144747.3041b208832bbdf9fbce5d96@linux-foundation.org}(hjwhhhNhNubah}(h]h ]h"]h$]h&]refurijyuh1jHhjoubeh}(h]h ]h"]h$]h&]uh1hhhhM%hjkubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hRecommendation from Michael Kerrisk that a new system call should come with a man page: https://lore.kernel.org/r/CAKgNAkgMA39AfoSoA5Pe1r9N+ZzfYQNvNPvcRN7tOvRb8+v06Q@mail.gmail.comh]h)}(hRecommendation from Michael Kerrisk that a new system call should come with a man page: https://lore.kernel.org/r/CAKgNAkgMA39AfoSoA5Pe1r9N+ZzfYQNvNPvcRN7tOvRb8+v06Q@mail.gmail.comh](hXRecommendation from Michael Kerrisk that a new system call should come with a man page: }(hjhhhNhNubjI)}(h\https://lore.kernel.org/r/CAKgNAkgMA39AfoSoA5Pe1r9N+ZzfYQNvNPvcRN7tOvRb8+v06Q@mail.gmail.comh]h\https://lore.kernel.org/r/CAKgNAkgMA39AfoSoA5Pe1r9N+ZzfYQNvNPvcRN7tOvRb8+v06Q@mail.gmail.com}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhM(hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hSuggestion from Thomas Gleixner that x86 wire-up should be in a separate commit: https://lore.kernel.org/r/alpine.DEB.2.11.1411191249560.3909@nanosh]h)}(hSuggestion from Thomas Gleixner that x86 wire-up should be in a separate commit: https://lore.kernel.org/r/alpine.DEB.2.11.1411191249560.3909@nanosh](hQSuggestion from Thomas Gleixner that x86 wire-up should be in a separate commit: }(hjhhhNhNubjI)}(hBhttps://lore.kernel.org/r/alpine.DEB.2.11.1411191249560.3909@nanosh]hBhttps://lore.kernel.org/r/alpine.DEB.2.11.1411191249560.3909@nanos}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhM*hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hSuggestion from Greg Kroah-Hartman that it's good for new system calls to come with a man-page & selftest: https://lore.kernel.org/r/20140320025530.GA25469@kroah.comh]h)}(hSuggestion from Greg Kroah-Hartman that it's good for new system calls to come with a man-page & selftest: https://lore.kernel.org/r/20140320025530.GA25469@kroah.comh](hmSuggestion from Greg Kroah-Hartman that it’s good for new system calls to come with a man-page & selftest: }(hjhhhNhNubjI)}(h:https://lore.kernel.org/r/20140320025530.GA25469@kroah.comh]h:https://lore.kernel.org/r/20140320025530.GA25469@kroah.com}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhM,hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hDiscussion from Michael Kerrisk of new system call vs. :manpage:`prctl(2)` extension: https://lore.kernel.org/r/CAHO5Pa3F2MjfTtfNxa8LbnkeeU8=YJ+9tDqxZpw7Gz59E-4AUg@mail.gmail.comh]h)}(hDiscussion from Michael Kerrisk of new system call vs. :manpage:`prctl(2)` extension: https://lore.kernel.org/r/CAHO5Pa3F2MjfTtfNxa8LbnkeeU8=YJ+9tDqxZpw7Gz59E-4AUg@mail.gmail.comh](h7Discussion from Michael Kerrisk of new system call vs. }(hj hhhNhNubj)}(h:manpage:`prctl(2)`h]hprctl(2)}(hjhhhNhNubah}(h]h ]jah"]h$]h&]jjjprctl(2)jprctljjuh1jhj ubh extension: }(hj hhhNhNubjI)}(h\https://lore.kernel.org/r/CAHO5Pa3F2MjfTtfNxa8LbnkeeU8=YJ+9tDqxZpw7Gz59E-4AUg@mail.gmail.comh]h\https://lore.kernel.org/r/CAHO5Pa3F2MjfTtfNxa8LbnkeeU8=YJ+9tDqxZpw7Gz59E-4AUg@mail.gmail.com}(hj'hhhNhNubah}(h]h ]h"]h$]h&]refurij)uh1jHhj ubeh}(h]h ]h"]h$]h&]uh1hhhhM.hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hSuggestion from Ingo Molnar that system calls that involve multiple arguments should encapsulate those arguments in a struct, which includes a size field for future extensibility: https://lore.kernel.org/r/20150730083831.GA22182@gmail.comh]h)}(hSuggestion from Ingo Molnar that system calls that involve multiple arguments should encapsulate those arguments in a struct, which includes a size field for future extensibility: https://lore.kernel.org/r/20150730083831.GA22182@gmail.comh](hSuggestion from Ingo Molnar that system calls that involve multiple arguments should encapsulate those arguments in a struct, which includes a size field for future extensibility: }(hjFhhhNhNubjI)}(h:https://lore.kernel.org/r/20150730083831.GA22182@gmail.comh]h:https://lore.kernel.org/r/20150730083831.GA22182@gmail.com}(hjNhhhNhNubah}(h]h ]h"]h$]h&]refurijPuh1jHhjFubeh}(h]h ]h"]h$]h&]uh1hhhhM0hjBubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hX(Numbering oddities arising from (re-)use of O_* numbering space flags: - commit 75069f2b5bfb ("vfs: renumber FMODE_NONOTIFY and add to uniqueness check") - commit 12ed2e36c98a ("fanotify: FMODE_NONOTIFY and __O_SYNC in sparc conflict") - commit bb458c644a59 ("Safer ABI for O_TMPFILE") h](h)}(hFNumbering oddities arising from (re-)use of O_* numbering space flags:h]hFNumbering oddities arising from (re-)use of O_* numbering space flags:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM3hjiubj)}(h- commit 75069f2b5bfb ("vfs: renumber FMODE_NONOTIFY and add to uniqueness check") - commit 12ed2e36c98a ("fanotify: FMODE_NONOTIFY and __O_SYNC in sparc conflict") - commit bb458c644a59 ("Safer ABI for O_TMPFILE") h]j$)}(hhh](j))}(hPcommit 75069f2b5bfb ("vfs: renumber FMODE_NONOTIFY and add to uniqueness check")h]h)}(hPcommit 75069f2b5bfb ("vfs: renumber FMODE_NONOTIFY and add to uniqueness check")h]hTcommit 75069f2b5bfb (“vfs: renumber FMODE_NONOTIFY and add to uniqueness check”)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM5hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hOcommit 12ed2e36c98a ("fanotify: FMODE_NONOTIFY and __O_SYNC in sparc conflict")h]h)}(hOcommit 12ed2e36c98a ("fanotify: FMODE_NONOTIFY and __O_SYNC in sparc conflict")h]hScommit 12ed2e36c98a (“fanotify: FMODE_NONOTIFY and __O_SYNC in sparc conflict”)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM7hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(h0commit bb458c644a59 ("Safer ABI for O_TMPFILE") h]h)}(h/commit bb458c644a59 ("Safer ABI for O_TMPFILE")h]h3commit bb458c644a59 (“Safer ABI for O_TMPFILE”)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM9hjubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]jjuh1j#hhhM5hj{ubah}(h]h ]h"]h$]h&]uh1jhhhM5hjiubeh}(h]h ]h"]h$]h&]uh1j(hjubj))}(hDiscussion from Matthew Wilcox about restrictions on 64-bit arguments: https://lore.kernel.org/r/20081212152929.GM26095@parisc-linux.orgh]h)}(hDiscussion from Matthew Wilcox about restrictions on 64-bit arguments: https://lore.kernel.org/r/20081212152929.GM26095@parisc-linux.orgh](hGDiscussion from Matthew Wilcox about restrictions on 64-bit arguments: }(hjhhhNhNubjI)}(hAhttps://lore.kernel.org/r/20081212152929.GM26095@parisc-linux.orgh]hAhttps://lore.kernel.org/r/20081212152929.GM26095@parisc-linux.org}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhM;hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hRecommendation from Greg Kroah-Hartman that unknown flags should be policed: https://lore.kernel.org/r/20140717193330.GB4703@kroah.comh]h)}(hRecommendation from Greg Kroah-Hartman that unknown flags should be policed: https://lore.kernel.org/r/20140717193330.GB4703@kroah.comh](hMRecommendation from Greg Kroah-Hartman that unknown flags should be policed: }(hjhhhNhNubjI)}(h9https://lore.kernel.org/r/20140717193330.GB4703@kroah.comh]h9https://lore.kernel.org/r/20140717193330.GB4703@kroah.com}(hjhhhNhNubah}(h]h ]h"]h$]h&]refurijuh1jHhjubeh}(h]h ]h"]h$]h&]uh1hhhhM=hjubah}(h]h ]h"]h$]h&]uh1j(hjubj))}(hRecommendation from Linus Torvalds that x32 system calls should prefer compatibility with 64-bit versions rather than 32-bit versions: https://lore.kernel.org/r/CA+55aFxfmwfB7jbbrXxa=K7VBYPfAvmu3XOkGrLbB1UFjX1+Ew@mail.gmail.comh]h)}(hRecommendation from Linus Torvalds that x32 system calls should prefer compatibility with 64-bit versions rather than 32-bit versions: https://lore.kernel.org/r/CA+55aFxfmwfB7jbbrXxa=K7VBYPfAvmu3XOkGrLbB1UFjX1+Ew@mail.gmail.comh](hRecommendation from Linus Torvalds that x32 system calls should prefer compatibility with 64-bit versions rather than 32-bit versions: }(hj.hhhNhNubjI)}(h\https://lore.kernel.org/r/CA+55aFxfmwfB7jbbrXxa=K7VBYPfAvmu3XOkGrLbB1UFjX1+Ew@mail.gmail.comh]h\https://lore.kernel.org/r/CA+55aFxfmwfB7jbbrXxa=K7VBYPfAvmu3XOkGrLbB1UFjX1+Ew@mail.gmail.com}(hj6hhhNhNubah}(h]h ]h"]h$]h&]refurij8uh1jHhj.ubeh}(h]h ]h"]h$]h&]uh1hhhhM?hj*ubah}(h]h ]h"]h$]h&]uh1j(hjubeh}(h]h ]h"]h$]h&]jjuh1j#hhhMhjubah}(h]h ]h"]h$]h&]uh1jhhhMhjhhubeh}(h]references-and-sourcesah ]h"]references and sourcesah$]h&]uh1hhhhhhhhMubeh}(h](adding-a-new-system-callheh ]h"](adding a new system call addsyscallseh$]h&]uh1hhhhhhhhKexpect_referenced_by_name}jkhsexpect_referenced_by_id}hhsubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}h]hasnameids}(jkhjjjgjjjjjjjijfj# j j j jjjAj>j&j#jjjjjjjjjbj_u nametypes}(jkjjjjjjij# j jjAj&jjjjjbuh}(hhjghjhjjjj jfjj jlj j& jj j>jj#jDjj)jjjjjjj_ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages]hsystem_message)}(hhh]h)}(hhh]h1Hyperlink target "addsyscalls" is not referenced.}hjsbah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKuh1juba transformerN include_log] decorationNhhub.