Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\trace\trace_probe.c Create Date:2022-07-28 12:43:06
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:String length checking wrapper

Proto:static int traceprobe_parse_probe_arg_body(char *arg, ssize_t *size, struct probe_arg *parg, unsigned int flags, int offset)

Type:int

Parameter:

TypeParameterName
char *arg
ssize_t *size
struct probe_arg *parg
unsigned intflags
intoffset
546  struct fetch_insn * code, * scode, * tmp = NULL
550  len = strlen - Find the length of a string*@s: The string to be sized
551  If len > MAX_ARGSTR_LEN Then
552  trace_probe_log_err(offset, ARG_TOO_LONG)
553  Return -EINVAL
554  Else if len == 0 Then
555  trace_probe_log_err(offset, NO_ARG_BODY)
556  Return -EINVAL
559  Command of this argument = kstrdup(arg, GFP_KERNEL)
560  If Not Command of this argument Then Return -ENOMEM
563  t = 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
564  If t Then
565  t = '\0'
566  t2 = 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
567  If t2 Then
568  t2++ = '\0'
570  If Not t3 Then
575  Else if t3[1] != '\0' Then
578  Return -EINVAL
580  t3 = '\0'
584  Return -EINVAL
589  Return -EINVAL
598  If strcmp(arg, "$comm") == 0 || strncmp(arg, "\\\"", 2) == 0 Then
600  If Array count || t && strcmp(t, "string") Then Return -EINVAL
602  Type of this argument = find_fetch_type("string")
603  Else Type of this argument = find_fetch_type(t)
605  If Not Type of this argument Then
606  trace_probe_log_err(offset + (t ? (t - arg) : 0), BAD_TYPE)
607  Return -EINVAL
609  Offset from argument entry = size
610  size += Byte size of type * If Array count Else 1
612  If Array count Then
613  len = strlen - Find the length of a string*@s: The string to be sized + 6
614  Format string if needed = Allocation memory
615  If Not Format string if needed Then Return -ENOMEM
617  snprintf - Format a string and place it in a buffer*@buf: The buffer to place the result into*@size: The size of the buffer, including the trailing null space*@fmt: The format string to use*@
621  code = tmp = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
622  If Not code Then Return -ENOMEM
624  op = FETCH_OP_END
626  ret = Recursive argument parser
628  If ret Then Go to fail
632  If Not strcmp(Name of type , "string") || Not strcmp(Name of type , "ustring") Then
637  trace_probe_log_err(offset + (t ? (t - arg) : 0), BAD_STRING)
639  ret = -EINVAL
640  Go to fail
650  code++
651  If op != FETCH_OP_NOP Then
653  ret = -EINVAL
654  Go to fail
658  If Not strcmp(Name of type , "ustring") || op == User-space Dereference: .offset Then op = User String: .offset, .size
661  Else op = String: .offset, .size
663  size = Byte size of type
664  Dynamic array (string) is used = true
665  Else if op == Dereference: .offset Then
666  op = Mem: .offset, .size
667  size = Byte size of type
668  Else if op == User-space Dereference: .offset Then
669  op = Mem: .offset, .size
670  size = Byte size of type
671  Else
672  code++
673  If op != FETCH_OP_NOP Then
675  ret = -EINVAL
676  Go to fail
678  op = Raw: .size
679  size = Byte size of type
681  scode = code
683  If (t != NULL) Then
684  ret = Bitfield type needs to be parsed into a fetch function
685  If ret Then
687  Go to fail
691  If Array count Then
695  trace_probe_log_err(offset + (t ? (t - arg) : 0), BAD_STRING)
697  ret = -EINVAL
698  Go to fail
700  code++
701  If op != FETCH_OP_NOP Then
703  ret = -EINVAL
704  Go to fail
706  op = Array: .param = loop count
707  param = Array count
709  code++
710  op = FETCH_OP_END
713  code = kcalloc - allocate memory for an array. The memory is set to zero.*@n: number of elements.*@size: element size.*@flags: the type of memory to allocate (see kmalloc).
714  If Not code Then ret = -ENOMEM
716  Else No 3D Now!(code, tmp, size of code * (code - tmp + 1))
719  fail :
720  If ret Then
721  When code < tmp + ch + deref*N + store + mod + end <= 16, this allows N=12, enough cycle If op == Unresolved Symbol holder || op == Allocated data: .data Then
724  kfree(data)
726  kfree(tmp)
728  Return ret
Caller
NameDescribe
traceprobe_parse_probe_arg