Debian Codegraph @

templates/man2/memfd_create.2.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:31+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "memfd_create"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2026-02-08"
31 msgstr ""
32
33 #. type: TH
34 #: archlinux debian-unstable
35 #, no-wrap
36 msgid "Linux man-pages 6.18"
37 msgstr ""
38
39 #. type: SH
40 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
41 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
42 #, no-wrap
43 msgid "NAME"
44 msgstr ""
45
46 #. type: Plain text
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 msgid "memfd_create - create an anonymous file"
50 msgstr ""
51
52 #. type: SH
53 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
54 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
55 #, no-wrap
56 msgid "LIBRARY"
57 msgstr ""
58
59 #. type: Plain text
60 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
61 #: opensuse-leap-16-1 opensuse-tumbleweed
62 msgid "Standard C library (I<libc>,\\ I<-lc>)"
63 msgstr ""
64
65 #. type: SH
66 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
67 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
68 #, no-wrap
69 msgid "SYNOPSIS"
70 msgstr ""
71
72 #. type: Plain text
73 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
74 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
75 #, no-wrap
76 msgid ""
77 "B<#define _GNU_SOURCE> /* See feature_test_macros(7) */\n"
78 "B<#include E<lt>sys/mman.hE<gt>>\n"
79 msgstr ""
80
81 #. type: Plain text
82 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
83 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
84 #, no-wrap
85 msgid "B<int memfd_create(const char *>I<name>B<, unsigned int >I<flags>B<);>\n"
86 msgstr ""
87
88 #. type: SH
89 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
90 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
91 #, no-wrap
92 msgid "DESCRIPTION"
93 msgstr ""
94
95 #. #-#-#-#-# archlinux: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
96 #. David Herrmann:
97 #. memfd uses VM_NORESERVE so each page is accounted on first access.
98 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
99 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
100 #. those are accounted on "current" and "current->mm", that is, the
101 #. process doing the first page access.
102 #. type: Plain text
103 #. #-#-#-#-# debian-trixie: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
104 #. David Herrmann:
105 #. memfd uses VM_NORESERVE so each page is accounted on first access.
106 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
107 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
108 #. those are accounted on "current" and "current->mm", that is, the
109 #. process doing the first page access.
110 #. type: Plain text
111 #. #-#-#-#-# debian-unstable: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
112 #. David Herrmann:
113 #. memfd uses VM_NORESERVE so each page is accounted on first access.
114 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
115 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
116 #. those are accounted on "current" and "current->mm", that is, the
117 #. process doing the first page access.
118 #. type: Plain text
119 #. #-#-#-#-# fedora-44: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
120 #. David Herrmann:
121 #. memfd uses VM_NORESERVE so each page is accounted on first access.
122 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
123 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
124 #. those are accounted on "current" and "current->mm", that is, the
125 #. process doing the first page access.
126 #. type: Plain text
127 #. #-#-#-#-# fedora-rawhide: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
128 #. David Herrmann:
129 #. memfd uses VM_NORESERVE so each page is accounted on first access.
130 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
131 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
132 #. those are accounted on "current" and "current->mm", that is, the
133 #. process doing the first page access.
134 #. type: Plain text
135 #. #-#-#-#-# mageia-cauldron: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
136 #. David Herrmann:
137 #. memfd uses VM_NORESERVE so each page is accounted on first access.
138 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
139 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
140 #. those are accounted on "current" and "current->mm", that is, the
141 #. process doing the first page access.
142 #. type: Plain text
143 #. #-#-#-#-# opensuse-leap-16-1: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
144 #. David Herrmann:
145 #. memfd uses VM_NORESERVE so each page is accounted on first access.
146 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
147 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
148 #. those are accounted on "current" and "current->mm", that is, the
149 #. process doing the first page access.
150 #. type: Plain text
151 #. #-#-#-#-# opensuse-tumbleweed: memfd_create.2.pot (PACKAGE VERSION) #-#-#-#-#
152 #. David Herrmann:
153 #. memfd uses VM_NORESERVE so each page is accounted on first access.
154 #. This means, the overcommit-limits (see __vm_enough_memory()) and the
155 #. memory-cgroup limits (mem_cgroup_try_charge()) are applied. Note that
156 #. those are accounted on "current" and "current->mm", that is, the
157 #. process doing the first page access.
158 #. type: Plain text
159 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
160 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
161 msgid ""
162 "B<memfd_create>() creates an anonymous file and returns a file descriptor "
163 "that refers to it. The file behaves like a regular file, and so can be "
164 "modified, truncated, memory-mapped, and so on. However, unlike a regular "
165 "file, it lives in RAM and has a volatile backing storage. Once all "
166 "references to the file are dropped, it is automatically released. Anonymous "
167 "memory is used for all backing pages of the file. Therefore, files created "
168 "by B<memfd_create>() have the same semantics as other anonymous memory "
169 "allocations such as those allocated using B<mmap>(2) with the "
170 "B<MAP_ANONYMOUS> flag."
171 msgstr ""
172
173 #. type: Plain text
174 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
175 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
176 msgid ""
177 "The initial size of the file is set to 0. Following the call, the file size "
178 "should be set using B<ftruncate>(2). (Alternatively, the file may be "
179 "populated by calls to B<write>(2) or similar.)"
180 msgstr ""
181
182 #. type: Plain text
183 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
184 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
185 msgid ""
186 "The name supplied in I<name> is used as a filename and will be displayed as "
187 "the target of the corresponding symbolic link in the directory I</proc/self/"
188 "fd/>. The displayed name is always prefixed with I<memfd:> and serves only "
189 "for debugging purposes. Names do not affect the behavior of the file "
190 "descriptor, and as such multiple files can have the same name without any "
191 "side effects."
192 msgstr ""
193
194 #. type: Plain text
195 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
196 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
197 msgid ""
198 "The following values may be bitwise ORed in I<flags> to change the behavior "
199 "of B<memfd_create>():"
200 msgstr ""
201
202 #. type: TP
203 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
204 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
205 #, no-wrap
206 msgid "B<MFD_CLOEXEC>"
207 msgstr ""
208
209 #. type: Plain text
210 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
211 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
212 msgid ""
213 "Set the close-on-exec (B<FD_CLOEXEC>) flag on the new file descriptor. See "
214 "the description of the B<O_CLOEXEC> flag in B<open>(2) for reasons why this "
215 "may be useful."
216 msgstr ""
217
218 #. type: TP
219 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
220 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
221 #, no-wrap
222 msgid "B<MFD_ALLOW_SEALING>"
223 msgstr ""
224
225 #. FIXME Why is the MFD_ALLOW_SEALING behavior not simply the default?
226 #. Is it worth adding some text explaining this?
227 #. type: Plain text
228 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
229 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
230 msgid ""
231 "Allow sealing operations on this file. See the discussion of the "
232 "B<F_ADD_SEALS> and B<F_GET_SEALS> operations in B<fcntl>(2), and also NOTES, "
233 "below. The initial set of seals is empty. If this flag is not set, the "
234 "initial set of seals will be B<F_SEAL_SEAL>, meaning that no other seals can "
235 "be set on the file."
236 msgstr ""
237
238 #. type: TP
239 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
240 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
241 #, no-wrap
242 msgid "B<MFD_HUGETLB> (since Linux 4.14)"
243 msgstr ""
244
245 #. commit 749df87bd7bee5a79cef073f5d032ddb2b211de8
246 #. commit 47b9012ecdc747f6936395265e677d41e11a31ff
247 #. type: Plain text
248 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
249 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
250 msgid ""
251 "The anonymous file will be created in the hugetlbfs filesystem using huge "
252 "pages. See the Linux kernel source file I<Documentation/admin-guide/mm/"
253 "hugetlbpage.rst> for more information about hugetlbfs. Specifying both "
254 "B<MFD_HUGETLB> and B<MFD_ALLOW_SEALING> in I<flags> is supported since Linux "
255 "4.16."
256 msgstr ""
257
258 #. type: TP
259 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
260 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
261 #, no-wrap
262 msgid "B<MFD_HUGE_2MB>"
263 msgstr ""
264
265 #. type: TQ
266 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
267 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
268 #, no-wrap
269 msgid "B<MFD_HUGE_1GB>"
270 msgstr ""
271
272 #. type: TQ
273 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
274 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
275 #, no-wrap
276 msgid "\\&.\\|.\\|."
277 msgstr ""
278
279 #. type: Plain text
280 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
281 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
282 msgid ""
283 "Used in conjunction with B<MFD_HUGETLB> to select alternative hugetlb page "
284 "sizes (respectively, 2\\ MB, 1\\ GB, ...) on systems that support multiple "
285 "hugetlb page sizes. Definitions for known huge page sizes are included in "
286 "the header file I<E<lt>linux/memfd.hE<gt>.>"
287 msgstr ""
288
289 #. type: Plain text
290 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
291 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
292 msgid ""
293 "For details on encoding huge page sizes not included in the header file, see "
294 "the discussion of the similarly named constants in B<mmap>(2)."
295 msgstr ""
296
297 #. type: Plain text
298 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
299 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
300 msgid "Unused bits in I<flags> must be 0."
301 msgstr ""
302
303 #. type: Plain text
304 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
305 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
306 msgid ""
307 "As its return value, B<memfd_create>() returns a new file descriptor that "
308 "can be used to refer to the file. This file descriptor is opened for both "
309 "reading and writing (B<O_RDWR>) and B<O_LARGEFILE> is set for the file "
310 "descriptor."
311 msgstr ""
312
313 #. type: Plain text
314 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
315 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
316 msgid ""
317 "With respect to B<fork>(2) and B<execve>(2), the usual semantics apply for "
318 "the file descriptor created by B<memfd_create>(). A copy of the file "
319 "descriptor is inherited by the child produced by B<fork>(2) and refers to "
320 "the same file. The file descriptor is preserved across B<execve>(2), unless "
321 "the close-on-exec flag has been set."
322 msgstr ""
323
324 #. type: SH
325 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
326 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
327 #, no-wrap
328 msgid "RETURN VALUE"
329 msgstr ""
330
331 #. type: Plain text
332 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
333 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
334 msgid ""
335 "On success, B<memfd_create>() returns a new file descriptor. On error, -1 "
336 "is returned and I<errno> is set to indicate the error."
337 msgstr ""
338
339 #. type: SH
340 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
341 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
342 #, no-wrap
343 msgid "ERRORS"
344 msgstr ""
345
346 #. type: TP
347 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
348 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
349 #, no-wrap
350 msgid "B<EFAULT>"
351 msgstr ""
352
353 #. type: Plain text
354 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
355 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
356 msgid "The address in I<name> points to invalid memory."
357 msgstr ""
358
359 #. type: TP
360 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
361 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
362 #, no-wrap
363 msgid "B<EINVAL>"
364 msgstr ""
365
366 #. type: Plain text
367 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
368 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
369 msgid "I<flags> included unknown bits."
370 msgstr ""
371
372 #. NAME_MAX - strlen("memfd:")
373 #. type: Plain text
374 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
375 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
376 msgid ""
377 "I<name> was too long. (The limit is 249 bytes, excluding the terminating "
378 "null byte.)"
379 msgstr ""
380
381 #. type: Plain text
382 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
383 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
384 msgid ""
385 "Both B<MFD_HUGETLB> and B<MFD_ALLOW_SEALING> were specified in I<flags>."
386 msgstr ""
387
388 #. type: TP
389 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
390 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
391 #, no-wrap
392 msgid "B<EMFILE>"
393 msgstr ""
394
395 #. type: Plain text
396 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
397 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
398 msgid ""
399 "The per-process limit on the number of open file descriptors has been "
400 "reached."
401 msgstr ""
402
403 #. type: TP
404 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
405 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
406 #, no-wrap
407 msgid "B<ENFILE>"
408 msgstr ""
409
410 #. type: Plain text
411 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
412 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
413 msgid ""
414 "The system-wide limit on the total number of open files has been reached."
415 msgstr ""
416
417 #. type: TP
418 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
419 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
420 #, no-wrap
421 msgid "B<ENOMEM>"
422 msgstr ""
423
424 #. type: Plain text
425 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
426 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
427 msgid "There was insufficient memory to create a new anonymous file."
428 msgstr ""
429
430 #. type: TP
431 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
432 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
433 #, no-wrap
434 msgid "B<EPERM>"
435 msgstr ""
436
437 #. type: Plain text
438 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
439 #: opensuse-tumbleweed
440 msgid ""
441 "The B<MFD_HUGETLB> flag was specified, but the caller was not privileged "
442 "(did not have the B<CAP_IPC_LOCK> capability) and is not a member of the "
443 "I<hugetlb_shm_group> group; see the description of I</proc/sys/vm/"
444 "hugetlb_shm_group> in B<proc_sys_vm>(5)."
445 msgstr ""
446
447 #. type: SH
448 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
449 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
450 #, no-wrap
451 msgid "STANDARDS"
452 msgstr ""
453
454 #. type: Plain text
455 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
456 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
457 msgid "Linux."
458 msgstr ""
459
460 #. type: SH
461 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
462 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
463 #, no-wrap
464 msgid "HISTORY"
465 msgstr ""
466
467 #. type: Plain text
468 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
469 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
470 msgid "Linux 3.17, glibc 2.27."
471 msgstr ""
472
473 #. type: SH
474 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
475 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
476 #, no-wrap
477 msgid "NOTES"
478 msgstr ""
479
480 #. See also http://lwn.net/Articles/593918/
481 #. and http://lwn.net/Articles/594919/ and http://lwn.net/Articles/591108/
482 #. type: Plain text
483 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
484 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
485 msgid ""
486 "The B<memfd_create>() system call provides a simple alternative to manually "
487 "mounting a B<tmpfs>(5) filesystem and creating and opening a file in that "
488 "filesystem. The primary purpose of B<memfd_create>() is to create files "
489 "and associated file descriptors that are used with the file-sealing APIs "
490 "provided by B<fcntl>(2)."
491 msgstr ""
492
493 #. type: Plain text
494 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
495 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
496 msgid ""
497 "The B<memfd_create>() system call also has uses without file sealing (which "
498 "is why file-sealing is disabled, unless explicitly requested with the "
499 "B<MFD_ALLOW_SEALING> flag). In particular, it can be used as an alternative "
500 "to creating files in I<tmp> or as an alternative to using the B<open>(2) "
501 "B<O_TMPFILE> in cases where there is no intention to actually link the "
502 "resulting file into the filesystem."
503 msgstr ""
504
505 #. type: SS
506 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
507 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
508 #, no-wrap
509 msgid "File sealing"
510 msgstr ""
511
512 #. type: Plain text
513 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
514 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
515 msgid ""
516 "In the absence of file sealing, processes that communicate via shared memory "
517 "must either trust each other, or take measures to deal with the possibility "
518 "that an untrusted peer may manipulate the shared memory region in "
519 "problematic ways. For example, an untrusted peer might modify the contents "
520 "of the shared memory at any time, or shrink the shared memory region. The "
521 "former possibility leaves the local process vulnerable to time-of-check-to-"
522 "time-of-use race conditions (typically dealt with by copying data from the "
523 "shared memory region before checking and using it). The latter possibility "
524 "leaves the local process vulnerable to B<SIGBUS> signals when an attempt is "
525 "made to access a now-nonexistent location in the shared memory region. "
526 "(Dealing with this possibility necessitates the use of a handler for the "
527 "B<SIGBUS> signal.)"
528 msgstr ""
529
530 #. type: Plain text
531 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
532 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
533 msgid ""
534 "Dealing with untrusted peers imposes extra complexity on code that employs "
535 "shared memory. Memory sealing enables that extra complexity to be "
536 "eliminated, by allowing a process to operate secure in the knowledge that "
537 "its peer can't modify the shared memory in an undesired fashion."
538 msgstr ""
539
540 #. type: Plain text
541 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
542 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
543 msgid "An example of the usage of the sealing mechanism is as follows:"
544 msgstr ""
545
546 #. type: IP
547 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
548 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
549 #, no-wrap
550 msgid "(1)"
551 msgstr ""
552
553 #. type: Plain text
554 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
555 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
556 msgid ""
557 "The first process creates a B<tmpfs>(5) file using B<memfd_create>(). The "
558 "call yields a file descriptor used in subsequent steps."
559 msgstr ""
560
561 #. type: IP
562 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
563 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
564 #, no-wrap
565 msgid "(2)"
566 msgstr ""
567
568 #. type: Plain text
569 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
570 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
571 msgid ""
572 "The first process sizes the file created in the previous step using "
573 "B<ftruncate>(2), maps it using B<mmap>(2), and populates the shared memory "
574 "with the desired data."
575 msgstr ""
576
577 #. type: IP
578 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
579 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
580 #, no-wrap
581 msgid "(3)"
582 msgstr ""
583
584 #. type: Plain text
585 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
586 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
587 msgid ""
588 "The first process uses the B<fcntl>(2) B<F_ADD_SEALS> operation to place "
589 "one or more seals on the file, in order to restrict further modifications on "
590 "the file. (If placing the seal B<F_SEAL_WRITE>, then it will be necessary "
591 "to first unmap the shared writable mapping created in the previous step. "
592 "Otherwise, behavior similar to B<F_SEAL_WRITE> can be achieved by using "
593 "B<F_SEAL_FUTURE_WRITE>, which will prevent future writes via B<mmap>(2) and "
594 "B<write>(2) from succeeding while keeping existing shared writable "
595 "mappings)."
596 msgstr ""
597
598 #. type: IP
599 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
600 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
601 #, no-wrap
602 msgid "(4)"
603 msgstr ""
604
605 #. type: Plain text
606 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
607 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
608 msgid ""
609 "A second process obtains a file descriptor for the B<tmpfs>(5) file and "
610 "maps it. Among the possible ways in which this could happen are the "
611 "following:"
612 msgstr ""
613
614 #. type: IP
615 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
616 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
617 #, no-wrap
618 msgid "\\[bu]"
619 msgstr ""
620
621 #. type: Plain text
622 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
623 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
624 msgid ""
625 "The process that called B<memfd_create>() could transfer the resulting file "
626 "descriptor to the second process via a UNIX domain socket (see B<unix>(7) "
627 "and B<cmsg>(3)). The second process then maps the file using B<mmap>(2)."
628 msgstr ""
629
630 #. type: Plain text
631 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
632 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
633 msgid ""
634 "The second process is created via B<fork>(2) and thus automatically "
635 "inherits the file descriptor and mapping. (Note that in this case and the "
636 "next, there is a natural trust relationship between the two processes, since "
637 "they are running under the same user ID. Therefore, file sealing would not "
638 "normally be necessary.)"
639 msgstr ""
640
641 #. type: Plain text
642 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
643 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
644 msgid ""
645 "The second process opens the file I</proc/>pidI</fd/>fd, where "
646 "I<E<lt>pidE<gt>> is the PID of the first process (the one that called "
647 "B<memfd_create>()), and I<E<lt>fdE<gt>> is the number of the file descriptor "
648 "returned by the call to B<memfd_create>() in that process. The second "
649 "process then maps the file using B<mmap>(2)."
650 msgstr ""
651
652 #. type: IP
653 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
654 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
655 #, no-wrap
656 msgid "(5)"
657 msgstr ""
658
659 #. type: Plain text
660 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
661 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
662 msgid ""
663 "The second process uses the B<fcntl>(2) B<F_GET_SEALS> operation to "
664 "retrieve the bit mask of seals that has been applied to the file. This bit "
665 "mask can be inspected in order to determine what kinds of restrictions have "
666 "been placed on file modifications. If desired, the second process can apply "
667 "further seals to impose additional restrictions (so long as the "
668 "B<F_SEAL_SEAL> seal has not yet been applied)."
669 msgstr ""
670
671 #. type: SH
672 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
673 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
674 #, no-wrap
675 msgid "EXAMPLES"
676 msgstr ""
677
678 #. type: Plain text
679 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
680 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
681 msgid ""
682 "Below are shown two example programs that demonstrate the use of "
683 "B<memfd_create>() and the file sealing API."
684 msgstr ""
685
686 #. type: Plain text
687 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
688 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
689 msgid ""
690 "The first program, I<t_memfd_create.c>, creates a B<tmpfs>(5) file using "
691 "B<memfd_create>(), sets a size for the file, maps it into memory, and "
692 "optionally places some seals on the file. The program accepts up to three "
693 "command-line arguments, of which the first two are required. The first "
694 "argument is the name to associate with the file, the second argument is the "
695 "size to be set for the file, and the optional third argument is a string of "
696 "characters that specify seals to be set on the file."
697 msgstr ""
698
699 #. type: Plain text
700 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
701 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
702 msgid ""
703 "The second program, I<t_get_seals.c>, can be used to open an existing file "
704 "that was created via B<memfd_create>() and inspect the set of seals that "
705 "have been applied to that file."
706 msgstr ""
707
708 #. type: Plain text
709 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
710 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
711 msgid ""
712 "The following shell session demonstrates the use of these programs. First "
713 "we create a B<tmpfs>(5) file and set some seals on it:"
714 msgstr ""
715
716 #. type: Plain text
717 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
718 #: opensuse-tumbleweed
719 #, no-wrap
720 msgid ""
721 "$B< ./t_memfd_create my_memfd_file 4096 sw &>\n"
722 "[1] 11775\n"
723 "PID: 11775;\\& fd: 3;\\& /proc/11775/fd/3\n"
724 msgstr ""
725
726 #. type: Plain text
727 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
728 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
729 msgid ""
730 "At this point, the I<t_memfd_create> program continues to run in the "
731 "background. From another program, we can obtain a file descriptor for the "
732 "file created by B<memfd_create>() by opening the I</proc/>pidI</fd> file "
733 "that corresponds to the file descriptor opened by B<memfd_create>(). Using "
734 "that pathname, we inspect the content of the I</proc/>pidI</fd> symbolic "
735 "link, and use our I<t_get_seals> program to view the seals that have been "
736 "placed on the file:"
737 msgstr ""
738
739 #. type: Plain text
740 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
741 #: opensuse-tumbleweed
742 #, no-wrap
743 msgid ""
744 "$B< readlink /proc/11775/fd/3>;\n"
745 "/memfd:my_memfd_file (deleted)\n"
746 "$B< ./t_get_seals /proc/11775/fd/3>;\n"
747 "Existing seals: WRITE SHRINK\n"
748 msgstr ""
749
750 #. type: SS
751 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
752 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
753 #, no-wrap
754 msgid "Program source: t_memfd_create.c"
755 msgstr ""
756
757 #. type: Plain text
758 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
759 #: opensuse-tumbleweed
760 #, no-wrap
761 msgid ""
762 "#define _GNU_SOURCE\n"
763 "#include E<lt>err.hE<gt>\n"
764 "#include E<lt>fcntl.hE<gt>\n"
765 "#include E<lt>stdint.hE<gt>\n"
766 "#include E<lt>stdio.hE<gt>\n"
767 "#include E<lt>stdlib.hE<gt>\n"
768 "#include E<lt>string.hE<gt>\n"
769 "#include E<lt>sys/mman.hE<gt>\n"
770 "#include E<lt>sys/types.hE<gt>\n"
771 "#include E<lt>unistd.hE<gt>\n"
772 "\\&\n"
773 "int\n"
774 "main(int argc, char *argv[])\n"
775 "{\n"
776 " int fd;\n"
777 " char *name, *seals_arg;\n"
778 " ssize_t size;\n"
779 " unsigned int seals;\n"
780 "\\&\n"
781 " if (argc E<lt> 3) {\n"
782 " fprintf(stderr, \"%s name size [seals]\\[rs]n\", argv[0]);\n"
783 " fprintf(stderr, \"\\[rs]t\\[aq]seals\\[aq] can contain any of the \"\n"
784 " \"following characters:\\[rs]n\");\n"
785 " fprintf(stderr, \"\\[rs]t\\[rs]tg - F_SEAL_GROW\\[rs]n\");\n"
786 " fprintf(stderr, \"\\[rs]t\\[rs]ts - F_SEAL_SHRINK\\[rs]n\");\n"
787 " fprintf(stderr, \"\\[rs]t\\[rs]tw - F_SEAL_WRITE\\[rs]n\");\n"
788 " fprintf(stderr, \"\\[rs]t\\[rs]tW - F_SEAL_FUTURE_WRITE\\[rs]n\");\n"
789 " fprintf(stderr, \"\\[rs]t\\[rs]tS - F_SEAL_SEAL\\[rs]n\");\n"
790 " exit(EXIT_FAILURE);\n"
791 " }\n"
792 "\\&\n"
793 " name = argv[1];\n"
794 " size = atoi(argv[2]);\n"
795 " seals_arg = argv[3];\n"
796 "\\&\n"
797 " /* Create an anonymous file in tmpfs; allow seals to be\n"
798 " placed on the file. */\n"
799 "\\&\n"
800 " fd = memfd_create(name, MFD_ALLOW_SEALING);\n"
801 " if (fd == -1)\n"
802 " err(EXIT_FAILURE, \"memfd_create\");\n"
803 "\\&\n"
804 " /* Size the file as specified on the command line. */\n"
805 "\\&\n"
806 " if (ftruncate(fd, size) == -1)\n"
807 " err(EXIT_FAILURE, \"truncate\");\n"
808 "\\&\n"
809 " printf(\"PID: %jd; fd: %d; /proc/%jd/fd/%d\\[rs]n\",\n"
810 " (intmax_t) getpid(), fd, (intmax_t) getpid(), fd);\n"
811 "\\&\n"
812 " /* Code to map the file and populate the mapping with data\n"
813 " omitted. */\n"
814 "\\&\n"
815 " /* If a \\[aq]seals\\[aq] command-line argument was supplied, set some\n"
816 " seals on the file. */\n"
817 "\\&\n"
818 " if (seals_arg != NULL) {\n"
819 " seals = 0;\n"
820 "\\&\n"
821 " if (strchr(seals_arg, \\[aq]g\\[aq]) != NULL)\n"
822 " seals |= F_SEAL_GROW;\n"
823 " if (strchr(seals_arg, \\[aq]s\\[aq]) != NULL)\n"
824 " seals |= F_SEAL_SHRINK;\n"
825 " if (strchr(seals_arg, \\[aq]w\\[aq]) != NULL)\n"
826 " seals |= F_SEAL_WRITE;\n"
827 " if (strchr(seals_arg, \\[aq]W\\[aq]) != NULL)\n"
828 " seals |= F_SEAL_FUTURE_WRITE;\n"
829 " if (strchr(seals_arg, \\[aq]S\\[aq]) != NULL)\n"
830 " seals |= F_SEAL_SEAL;\n"
831 "\\&\n"
832 " if (fcntl(fd, F_ADD_SEALS, seals) == -1)\n"
833 " err(EXIT_FAILURE, \"fcntl\");\n"
834 " }\n"
835 "\\&\n"
836 " /* Keep running, so that the file created by memfd_create()\n"
837 " continues to exist. */\n"
838 "\\&\n"
839 " pause();\n"
840 "\\&\n"
841 " exit(EXIT_SUCCESS);\n"
842 "}\n"
843 msgstr ""
844
845 #. SRC END
846 #. type: SS
847 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
848 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
849 #, no-wrap
850 msgid "Program source: t_get_seals.c"
851 msgstr ""
852
853 #. type: Plain text
854 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
855 #: opensuse-tumbleweed
856 #, no-wrap
857 msgid ""
858 "#define _GNU_SOURCE\n"
859 "#include E<lt>err.hE<gt>\n"
860 "#include E<lt>fcntl.hE<gt>\n"
861 "#include E<lt>stdio.hE<gt>\n"
862 "#include E<lt>stdlib.hE<gt>\n"
863 "\\&\n"
864 "int\n"
865 "main(int argc, char *argv[])\n"
866 "{\n"
867 " int fd;\n"
868 " unsigned int seals;\n"
869 "\\&\n"
870 " if (argc != 2) {\n"
871 " fprintf(stderr, \"%s /proc/PID/fd/FD\\[rs]n\", argv[0]);\n"
872 " exit(EXIT_FAILURE);\n"
873 " }\n"
874 "\\&\n"
875 " fd = open(argv[1], O_RDWR);\n"
876 " if (fd == -1)\n"
877 " err(EXIT_FAILURE, \"open\");\n"
878 "\\&\n"
879 " seals = fcntl(fd, F_GET_SEALS);\n"
880 " if (seals == -1)\n"
881 " err(EXIT_FAILURE, \"fcntl\");\n"
882 "\\&\n"
883 " printf(\"Existing seals:\");\n"
884 " if (seals & F_SEAL_SEAL)\n"
885 " printf(\" SEAL\");\n"
886 " if (seals & F_SEAL_GROW)\n"
887 " printf(\" GROW\");\n"
888 " if (seals & F_SEAL_WRITE)\n"
889 " printf(\" WRITE\");\n"
890 " if (seals & F_SEAL_FUTURE_WRITE)\n"
891 " printf(\" FUTURE_WRITE\");\n"
892 " if (seals & F_SEAL_SHRINK)\n"
893 " printf(\" SHRINK\");\n"
894 " printf(\"\\[rs]n\");\n"
895 "\\&\n"
896 " /* Code to map the file and access the contents of the\n"
897 " resulting mapping omitted. */\n"
898 "\\&\n"
899 " exit(EXIT_SUCCESS);\n"
900 "}\n"
901 msgstr ""
902
903 #. SRC END
904 #. type: SH
905 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
906 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
907 #, no-wrap
908 msgid "SEE ALSO"
909 msgstr ""
910
911 #. type: Plain text
912 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
913 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
914 msgid ""
915 "B<fcntl>(2), B<ftruncate>(2), B<memfd_secret>(2), B<mmap>(2), B<shmget>(2), "
916 "B<shm_open>(3)"
917 msgstr ""
918
919 #. type: TH
920 #: debian-trixie
921 #, no-wrap
922 msgid "2024-06-15"
923 msgstr ""
924
925 #. type: TH
926 #: debian-trixie
927 #, no-wrap
928 msgid "Linux man-pages 6.9.1"
929 msgstr ""
930
931 #. type: Plain text
932 #: debian-trixie
933 msgid "Standard C library (I<libc>, I<-lc>)"
934 msgstr ""
935
936 #. type: Plain text
937 #: debian-trixie fedora-44 fedora-rawhide
938 msgid ""
939 "The B<MFD_HUGETLB> flag was specified, but the caller was not privileged "
940 "(did not have the B<CAP_IPC_LOCK> capability) and is not a member of the "
941 "I<sysctl_hugetlb_shm_group> group; see the description of I</proc/sys/vm/"
942 "sysctl_hugetlb_shm_group> in B<proc>(5)."
943 msgstr ""
944
945 #. type: Plain text
946 #: debian-trixie fedora-44 fedora-rawhide
947 #, no-wrap
948 msgid ""
949 "$ B<./t_memfd_create my_memfd_file 4096 sw &>\n"
950 "[1] 11775\n"
951 "PID: 11775; fd: 3; /proc/11775/fd/3\n"
952 msgstr ""
953
954 #. type: Plain text
955 #: debian-trixie fedora-44 fedora-rawhide
956 #, no-wrap
957 msgid ""
958 "$ B<readlink /proc/11775/fd/3>\n"
959 "/memfd:my_memfd_file (deleted)\n"
960 "$ B<./t_get_seals /proc/11775/fd/3>\n"
961 "Existing seals: WRITE SHRINK\n"
962 msgstr ""
963
964 #. type: Plain text
965 #: debian-trixie
966 #, no-wrap
967 msgid ""
968 "#define _GNU_SOURCE\n"
969 "#include E<lt>err.hE<gt>\n"
970 "#include E<lt>fcntl.hE<gt>\n"
971 "#include E<lt>stdint.hE<gt>\n"
972 "#include E<lt>stdio.hE<gt>\n"
973 "#include E<lt>stdlib.hE<gt>\n"
974 "#include E<lt>string.hE<gt>\n"
975 "#include E<lt>sys/mman.hE<gt>\n"
976 "#include E<lt>sys/types.hE<gt>\n"
977 "#include E<lt>unistd.hE<gt>\n"
978 "\\&\n"
979 "int\n"
980 "main(int argc, char *argv[])\n"
981 "{\n"
982 " int fd;\n"
983 " char *name, *seals_arg;\n"
984 " ssize_t len;\n"
985 " unsigned int seals;\n"
986 "\\&\n"
987 " if (argc E<lt> 3) {\n"
988 " fprintf(stderr, \"%s name size [seals]\\[rs]n\", argv[0]);\n"
989 " fprintf(stderr, \"\\[rs]t\\[aq]seals\\[aq] can contain any of the \"\n"
990 " \"following characters:\\[rs]n\");\n"
991 " fprintf(stderr, \"\\[rs]t\\[rs]tg - F_SEAL_GROW\\[rs]n\");\n"
992 " fprintf(stderr, \"\\[rs]t\\[rs]ts - F_SEAL_SHRINK\\[rs]n\");\n"
993 " fprintf(stderr, \"\\[rs]t\\[rs]tw - F_SEAL_WRITE\\[rs]n\");\n"
994 " fprintf(stderr, \"\\[rs]t\\[rs]tW - F_SEAL_FUTURE_WRITE\\[rs]n\");\n"
995 " fprintf(stderr, \"\\[rs]t\\[rs]tS - F_SEAL_SEAL\\[rs]n\");\n"
996 " exit(EXIT_FAILURE);\n"
997 " }\n"
998 "\\&\n"
999 " name = argv[1];\n"
1000 " len = atoi(argv[2]);\n"
1001 " seals_arg = argv[3];\n"
1002 "\\&\n"
1003 " /* Create an anonymous file in tmpfs; allow seals to be\n"
1004 " placed on the file. */\n"
1005 "\\&\n"
1006 " fd = memfd_create(name, MFD_ALLOW_SEALING);\n"
1007 " if (fd == -1)\n"
1008 " err(EXIT_FAILURE, \"memfd_create\");\n"
1009 "\\&\n"
1010 " /* Size the file as specified on the command line. */\n"
1011 "\\&\n"
1012 " if (ftruncate(fd, len) == -1)\n"
1013 " err(EXIT_FAILURE, \"truncate\");\n"
1014 "\\&\n"
1015 " printf(\"PID: %jd; fd: %d; /proc/%jd/fd/%d\\[rs]n\",\n"
1016 " (intmax_t) getpid(), fd, (intmax_t) getpid(), fd);\n"
1017 "\\&\n"
1018 " /* Code to map the file and populate the mapping with data\n"
1019 " omitted. */\n"
1020 "\\&\n"
1021 " /* If a \\[aq]seals\\[aq] command-line argument was supplied, set some\n"
1022 " seals on the file. */\n"
1023 "\\&\n"
1024 " if (seals_arg != NULL) {\n"
1025 " seals = 0;\n"
1026 "\\&\n"
1027 " if (strchr(seals_arg, \\[aq]g\\[aq]) != NULL)\n"
1028 " seals |= F_SEAL_GROW;\n"
1029 " if (strchr(seals_arg, \\[aq]s\\[aq]) != NULL)\n"
1030 " seals |= F_SEAL_SHRINK;\n"
1031 " if (strchr(seals_arg, \\[aq]w\\[aq]) != NULL)\n"
1032 " seals |= F_SEAL_WRITE;\n"
1033 " if (strchr(seals_arg, \\[aq]W\\[aq]) != NULL)\n"
1034 " seals |= F_SEAL_FUTURE_WRITE;\n"
1035 " if (strchr(seals_arg, \\[aq]S\\[aq]) != NULL)\n"
1036 " seals |= F_SEAL_SEAL;\n"
1037 "\\&\n"
1038 " if (fcntl(fd, F_ADD_SEALS, seals) == -1)\n"
1039 " err(EXIT_FAILURE, \"fcntl\");\n"
1040 " }\n"
1041 "\\&\n"
1042 " /* Keep running, so that the file created by memfd_create()\n"
1043 " continues to exist. */\n"
1044 "\\&\n"
1045 " pause();\n"
1046 "\\&\n"
1047 " exit(EXIT_SUCCESS);\n"
1048 "}\n"
1049 msgstr ""
1050
1051 #. type: Plain text
1052 #: debian-trixie fedora-44 fedora-rawhide
1053 #, no-wrap
1054 msgid ""
1055 "#define _GNU_SOURCE\n"
1056 "#include E<lt>err.hE<gt>\n"
1057 "#include E<lt>fcntl.hE<gt>\n"
1058 "#include E<lt>stdio.hE<gt>\n"
1059 "#include E<lt>stdlib.hE<gt>\n"
1060 "\\&\n"
1061 "int\n"
1062 "main(int argc, char *argv[])\n"
1063 "{\n"
1064 " int fd;\n"
1065 " unsigned int seals;\n"
1066 "\\&\n"
1067 " if (argc != 2) {\n"
1068 " fprintf(stderr, \"%s /proc/PID/fd/FD\\[rs]n\", argv[0]);\n"
1069 " exit(EXIT_FAILURE);\n"
1070 " }\n"
1071 "\\&\n"
1072 " fd = open(argv[1], O_RDWR);\n"
1073 " if (fd == -1)\n"
1074 " err(EXIT_FAILURE, \"open\");\n"
1075 "\\&\n"
1076 " seals = fcntl(fd, F_GET_SEALS);\n"
1077 " if (seals == -1)\n"
1078 " err(EXIT_FAILURE, \"fcntl\");\n"
1079 "\\&\n"
1080 " printf(\"Existing seals:\");\n"
1081 " if (seals & F_SEAL_SEAL)\n"
1082 " printf(\" SEAL\");\n"
1083 " if (seals & F_SEAL_GROW)\n"
1084 " printf(\" GROW\");\n"
1085 " if (seals & F_SEAL_WRITE)\n"
1086 " printf(\" WRITE\");\n"
1087 " if (seals & F_SEAL_FUTURE_WRITE)\n"
1088 " printf(\" FUTURE_WRITE\");\n"
1089 " if (seals & F_SEAL_SHRINK)\n"
1090 " printf(\" SHRINK\");\n"
1091 " printf(\"\\[rs]n\");\n"
1092 "\\&\n"
1093 " /* Code to map the file and access the contents of the\n"
1094 " resulting mapping omitted. */\n"
1095 "\\&\n"
1096 " exit(EXIT_SUCCESS);\n"
1097 "}\n"
1098 msgstr ""
1099
1100 #. type: TH
1101 #: fedora-44 fedora-rawhide
1102 #, no-wrap
1103 msgid "2024-11-17"
1104 msgstr ""
1105
1106 #. type: TH
1107 #: fedora-44 fedora-rawhide
1108 #, no-wrap
1109 msgid "Linux man-pages 6.13"
1110 msgstr ""
1111
1112 #. type: Plain text
1113 #: fedora-44 fedora-rawhide
1114 #, no-wrap
1115 msgid ""
1116 "#define _GNU_SOURCE\n"
1117 "#include E<lt>err.hE<gt>\n"
1118 "#include E<lt>fcntl.hE<gt>\n"
1119 "#include E<lt>stdint.hE<gt>\n"
1120 "#include E<lt>stdio.hE<gt>\n"
1121 "#include E<lt>stdlib.hE<gt>\n"
1122 "#include E<lt>string.hE<gt>\n"
1123 "#include E<lt>sys/mman.hE<gt>\n"
1124 "#include E<lt>sys/types.hE<gt>\n"
1125 "#include E<lt>unistd.hE<gt>\n"
1126 "\\&\n"
1127 "int\n"
1128 "main(int argc, char *argv[])\n"
1129 "{\n"
1130 " int fd;\n"
1131 " char *name, *seals_arg;\n"
1132 " ssize_t size;\n"
1133 " unsigned int seals;\n"
1134 "\\&\n"
1135 " if (argc E<lt> 3) {\n"
1136 " fprintf(stderr, \"%s name size [seals]\\[rs]n\", argv[0]);\n"
1137 " fprintf(stderr, \"\\[rs]t\\[aq]seals\\[aq] can contain any of the \"\n"
1138 " \"following characters:\\[rs]n\");\n"
1139 " fprintf(stderr, \"\\[rs]t\\[rs]tg - F_SEAL_GROW\\[rs]n\");\n"
1140 " fprintf(stderr, \"\\[rs]t\\[rs]ts - F_SEAL_SHRINK\\[rs]n\");\n"
1141 " fprintf(stderr, \"\\[rs]t\\[rs]tw - F_SEAL_WRITE\\[rs]n\");\n"
1142 " fprintf(stderr, \"\\[rs]t\\[rs]tW - F_SEAL_FUTURE_WRITE\\[rs]n\");\n"
1143 " fprintf(stderr, \"\\[rs]t\\[rs]tS - F_SEAL_SEAL\\[rs]n\");\n"
1144 " exit(EXIT_FAILURE);\n"
1145 " }\n"
1146 "\\&\n"
1147 " name = argv[1];\n"
1148 " size = atoi(argv[2]);\n"
1149 " seals_arg = argv[3];\n"
1150 "\\&\n"
1151 " /* Create an anonymous file in tmpfs; allow seals to be\n"
1152 " placed on the file. */\n"
1153 "\\&\n"
1154 " fd = memfd_create(name, MFD_ALLOW_SEALING);\n"
1155 " if (fd == -1)\n"
1156 " err(EXIT_FAILURE, \"memfd_create\");\n"
1157 "\\&\n"
1158 " /* Size the file as specified on the command line. */\n"
1159 "\\&\n"
1160 " if (ftruncate(fd, size) == -1)\n"
1161 " err(EXIT_FAILURE, \"truncate\");\n"
1162 "\\&\n"
1163 " printf(\"PID: %jd; fd: %d; /proc/%jd/fd/%d\\[rs]n\",\n"
1164 " (intmax_t) getpid(), fd, (intmax_t) getpid(), fd);\n"
1165 "\\&\n"
1166 " /* Code to map the file and populate the mapping with data\n"
1167 " omitted. */\n"
1168 "\\&\n"
1169 " /* If a \\[aq]seals\\[aq] command-line argument was supplied, set some\n"
1170 " seals on the file. */\n"
1171 "\\&\n"
1172 " if (seals_arg != NULL) {\n"
1173 " seals = 0;\n"
1174 "\\&\n"
1175 " if (strchr(seals_arg, \\[aq]g\\[aq]) != NULL)\n"
1176 " seals |= F_SEAL_GROW;\n"
1177 " if (strchr(seals_arg, \\[aq]s\\[aq]) != NULL)\n"
1178 " seals |= F_SEAL_SHRINK;\n"
1179 " if (strchr(seals_arg, \\[aq]w\\[aq]) != NULL)\n"
1180 " seals |= F_SEAL_WRITE;\n"
1181 " if (strchr(seals_arg, \\[aq]W\\[aq]) != NULL)\n"
1182 " seals |= F_SEAL_FUTURE_WRITE;\n"
1183 " if (strchr(seals_arg, \\[aq]S\\[aq]) != NULL)\n"
1184 " seals |= F_SEAL_SEAL;\n"
1185 "\\&\n"
1186 " if (fcntl(fd, F_ADD_SEALS, seals) == -1)\n"
1187 " err(EXIT_FAILURE, \"fcntl\");\n"
1188 " }\n"
1189 "\\&\n"
1190 " /* Keep running, so that the file created by memfd_create()\n"
1191 " continues to exist. */\n"
1192 "\\&\n"
1193 " pause();\n"
1194 "\\&\n"
1195 " exit(EXIT_SUCCESS);\n"
1196 "}\n"
1197 msgstr ""
1198
1199 #. type: TH
1200 #: mageia-cauldron
1201 #, no-wrap
1202 msgid "Linux man-pages 6.17"
1203 msgstr ""
1204
1205 #. type: TH
1206 #: opensuse-leap-16-1 opensuse-tumbleweed
1207 #, no-wrap
1208 msgid "Linux man-pages (unreleased)"
1209 msgstr ""