Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\binfmt_misc.c Create Date:2022-07-28 20:27:41
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:This registers a new binary format, it recognises the syntax* ':name:type:offset:magic:mask:interpreter:flags'* where the ':' is the IFS, that can be chosen with the first char

Proto:static Node *create_entry(const char __user *buffer, size_t count)

Type:Node

Parameter:

TypeParameterName
const char __user *buffer
size_tcount
328  pr_debug("register: received %zu bytes\n", count)
331  err = -EINVAL
332  If count < 11 || count > Max length of the register string Then Go to out
335  err = -ENOMEM
336  memsize = sizeof(Node) + count + 8
337  e = Allocation memory
338  If Not e Then Go to out
341  p = buf = e + sizeof(Node)
343  memset(e, 0, sizeof(Node))
344  If copy_from_user(buf, buffer, count) Then Go to efault
347  del = p++
349  pr_debug("register: delim: %#x {%c}\n", del, del)
352  memset(buf + count, del, 8)
355  name = p
356  p = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
357  If Not p Then Go to einval
359  p++ = '\0'
360  If Not name[0] || Not strcmp(name, ".") || Not strcmp(name, "..") || strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for Then Go to einval
366  pr_debug("register: name: {%s}\n", name)
370  Case ++ == 'E'
371  pr_debug("register: type: E (extension)\n")
372  type, status, etc. = 1 << Enabled
373  Break
374  Case ++ == 'M'
375  pr_debug("register: type: M (magic)\n")
376  type, status, etc. = 1 << Enabled | 1 << Magic
377  Break
378  Default
379  Go to einval
381  If p++ != del Then Go to einval
384  If st_bit - Determine whether a bit is set*@nr: bit number to test*@addr: Address to start counting from Then
389  s = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
390  If Not s Then Go to einval
392  s = '\0'
393  If p != s Then
395  If r != 0 || offset of magic < 0 Then Go to einval
398  p = s
399  If p++ Then Go to einval
401  pr_debug("register: offset: %#x\n", offset of magic )
404  magic or filename extension = p
405  p = parses and copies one argument enclosed in del from *sp to *dp,* recognising the \x special.* returns pointer to the copied argument or NULL in case of an* error (and sets err) or null argument length.
406  If Not p Then Go to einval
408  If Not magic or filename extension [0] Then Go to einval
410  If USE_DEBUG Then print_hex_dump_bytes - shorthand form of print_hex_dump() with default params*@prefix_str: string to prefix each line with;* caller supplies trailing spaces for alignment if desired*@prefix_type: controls whether prefix of an offset, address, or none* is (KBUILD_MODNAME": register: magic[raw]: ", DUMP_PREFIX_NONE, magic or filename extension , p - magic or filename extension )
416  mask, NULL for exact match = p
417  p = parses and copies one argument enclosed in del from *sp to *dp,* recognising the \x special.* returns pointer to the copied argument or NULL in case of an* error (and sets err) or null argument length.
418  If Not p Then Go to einval
420  If Not mask, NULL for exact match [0] Then
422  pr_debug("register: mask[raw]: none\n")
423  Else if USE_DEBUG Then print_hex_dump_bytes - shorthand form of print_hex_dump() with default params*@prefix_str: string to prefix each line with;* caller supplies trailing spaces for alignment if desired*@prefix_type: controls whether prefix of an offset, address, or none* is (KBUILD_MODNAME": register: mask[raw]: ", DUMP_PREFIX_NONE, mask, NULL for exact match , p - mask, NULL for exact match )
434  size of magic/mask = string_unescape_inplace( magic or filename extension , UNESCAPE_HEX)
435  If mask, NULL for exact match && string_unescape_inplace( mask, NULL for exact match , UNESCAPE_HEX) != size of magic/mask Then Go to einval
438  If size of magic/mask > sizeof(linux_binprm->buf) || sizeof(linux_binprm->buf) - size of magic/mask < offset of magic Then Go to einval
441  pr_debug("register: magic/mask length: %i\n", size of magic/mask )
442  If USE_DEBUG Then
466  Else
470  p = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
471  If Not p Then Go to einval
473  p++ = '\0'
476  magic or filename extension = p
477  p = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
478  If Not p Then Go to einval
480  p++ = '\0'
481  If Not magic or filename extension [0] || strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for Then Go to einval
483  pr_debug("register: extension: {%s}\n", magic or filename extension )
486  p = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
487  If Not p Then Go to einval
489  p++ = '\0'
493  filename of interpreter = p
494  p = strchr - Find the first occurrence of the character c in the string s.*@s: the string to be searched*@c: the character to search for
495  If Not p Then Go to einval
497  p++ = '\0'
498  If Not filename of interpreter [0] Then Go to einval
500  pr_debug("register: interpreter: {%s}\n", filename of interpreter )
503  p = check_special_flags(p, e)
504  If p == '\n' Then p++
506  If p != buf + count Then Go to einval
509  Return e
511  out :
512  Return ERR_PTR(err)
514  efault :
515  kfree(e)
516  Return ERR_PTR( - EFAULT)
517  einval :
518  kfree(e)
519  Return ERR_PTR( - EINVAL)
Caller
NameDescribe
bm_register_write/register