Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

binfmt_misc: touch up documentation a bit

Line wrap the content to 80 cols, and add more details to various fields
to match the code. Drop reference to a website that does not exist
anymore.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Mike Frysinger and committed by
Linus Torvalds
43bd40e5 bbaecc08

+28 -20
+28 -20
Documentation/binfmt_misc.txt
··· 15 15 mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc 16 16 17 17 To actually register a new binary type, you have to set up a string looking like 18 - :name:type:offset:magic:mask:interpreter:flags (where you can choose the ':' upon 19 - your needs) and echo it to /proc/sys/fs/binfmt_misc/register. 18 + :name:type:offset:magic:mask:interpreter:flags (where you can choose the ':' 19 + upon your needs) and echo it to /proc/sys/fs/binfmt_misc/register. 20 + 20 21 Here is what the fields mean: 21 22 - 'name' is an identifier string. A new /proc file will be created with this 22 - name below /proc/sys/fs/binfmt_misc 23 + name below /proc/sys/fs/binfmt_misc; cannot contain slashes '/' for obvious 24 + reasons. 23 25 - 'type' is the type of recognition. Give 'M' for magic and 'E' for extension. 24 26 - 'offset' is the offset of the magic/mask in the file, counted in bytes. This 25 - defaults to 0 if you omit it (i.e. you write ':name:type::magic...') 27 + defaults to 0 if you omit it (i.e. you write ':name:type::magic...'). Ignored 28 + when using filename extension matching. 26 29 - 'magic' is the byte sequence binfmt_misc is matching for. The magic string 27 - may contain hex-encoded characters like \x0a or \xA4. In a shell environment 28 - you will have to write \\x0a to prevent the shell from eating your \. 30 + may contain hex-encoded characters like \x0a or \xA4. Note that you must 31 + escape any NUL bytes; parsing halts at the first one. In a shell environment 32 + you might have to write \\x0a to prevent the shell from eating your \. 29 33 If you chose filename extension matching, this is the extension to be 30 34 recognised (without the '.', the \x0a specials are not allowed). Extension 31 - matching is case sensitive! 35 + matching is case sensitive, and slashes '/' are not allowed! 32 36 - 'mask' is an (optional, defaults to all 0xff) mask. You can mask out some 33 37 bits from matching by supplying a string like magic and as long as magic. 34 - The mask is anded with the byte sequence of the file. 38 + The mask is anded with the byte sequence of the file. Note that you must 39 + escape any NUL bytes; parsing halts at the first one. Ignored when using 40 + filename extension matching. 35 41 - 'interpreter' is the program that should be invoked with the binary as first 36 42 argument (specify the full path) 37 43 - 'flags' is an optional field that controls several aspects of the invocation 38 - of the interpreter. It is a string of capital letters, each controls a certain 39 - aspect. The following flags are supported - 40 - 'P' - preserve-argv[0]. Legacy behavior of binfmt_misc is to overwrite the 41 - original argv[0] with the full path to the binary. When this flag is 42 - included, binfmt_misc will add an argument to the argument vector for 43 - this purpose, thus preserving the original argv[0]. 44 + of the interpreter. It is a string of capital letters, each controls a 45 + certain aspect. The following flags are supported - 46 + 'P' - preserve-argv[0]. Legacy behavior of binfmt_misc is to overwrite 47 + the original argv[0] with the full path to the binary. When this 48 + flag is included, binfmt_misc will add an argument to the argument 49 + vector for this purpose, thus preserving the original argv[0]. 50 + e.g. If your interp is set to /bin/foo and you run `blah` (which is 51 + in /usr/local/bin), then the kernel will execute /bin/foo with 52 + argv[] set to ["/bin/foo", "/usr/local/bin/blah", "blah"]. The 53 + interp has to be aware of this so it can execute /usr/local/bin/blah 54 + with argv[] set to ["blah"]. 44 55 'O' - open-binary. Legacy behavior of binfmt_misc is to pass the full path 45 56 of the binary to the interpreter as an argument. When this flag is 46 57 included, binfmt_misc will open the file for reading and pass its 47 58 descriptor as an argument, instead of the full path, thus allowing 48 - the interpreter to execute non-readable binaries. This feature should 49 - be used with care - the interpreter has to be trusted not to emit 50 - the contents of the non-readable binary. 59 + the interpreter to execute non-readable binaries. This feature 60 + should be used with care - the interpreter has to be trusted not to 61 + emit the contents of the non-readable binary. 51 62 'C' - credentials. Currently, the behavior of binfmt_misc is to calculate 52 63 the credentials and security token of the new process according to 53 64 the interpreter. When this flag is included, these attributes are ··· 120 109 passes it the full filename (or the file descriptor) to use. Using $PATH can 121 110 cause unexpected behaviour and can be a security hazard. 122 111 123 - 124 - There is a web page about binfmt_misc at 125 - http://www.tat.physik.uni-tuebingen.de 126 112 127 113 Richard Günther <rguenth@tat.physik.uni-tuebingen.de>