Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:security\tomoyo\audit.c Create Date:2022-07-28 19:32:54
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:moyo_print_bprm - Print "struct linux_binprm" for auditing

Proto:static char *tomoyo_print_bprm(struct linux_binprm *bprm, struct tomoyo_page_dump *dump)

Type:char

Parameter:

TypeParameterName
struct linux_binprm *bprm
struct tomoyo_page_dump *dump
25  tomoyo_buffer_len = 4096 * 2
26  buffer = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
30  pos = current top of mem
31  offset = pos % PAGE_SIZE
32  argv_count = argc
33  envp_count = envc
34  bool truncated = false
36  If Not buffer Then Return NULL
38  len = 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*@
39  cp = buffer + len
40  If Not argv_count Then
41  memmove(cp, "} envp[]={ ", 11)
42  cp += 11
44  last_start = cp
45  When argv_count || envp_count cycle
46  If Not tomoyo_dump_page(bprm, pos, dump) Then Go to out
48  pos += PAGE_SIZE - offset
50  When offset < PAGE_SIZE cycle
52  c = kaddr[offset++]
54  If cp == last_start Then cp++ = '"'
56  If cp >= buffer + tomoyo_buffer_len - 32 Then
58  truncated = true
59  Else if c == '\\' Then
60  cp++ = '\\'
61  cp++ = '\\'
62  Else if c > ' ' && c < 127 Then
63  cp++ = c
64  Else if Not c Then
65  cp++ = '"'
66  cp++ = ' '
67  last_start = cp
68  Else
69  cp++ = '\\'
70  cp++ = (c >> 6) + '0'
71  cp++ = ( c >> 3 & 7) + '0'
72  cp++ = (c & 7) + '0'
74  If c Then Continue
76  If argv_count Then
77  If --argv_count == 0 Then
78  If truncated Then
79  cp = last_start
80  memmove(cp, "... ", 4)
81  cp += 4
83  memmove(cp, "} envp[]={ ", 11)
84  cp += 11
85  last_start = cp
86  truncated = false
88  Else if envp_count Then
89  If --envp_count == 0 Then
90  If truncated Then
91  cp = last_start
92  memmove(cp, "... ", 4)
93  cp += 4
97  If Not argv_count && Not envp_count Then Break
100  offset = 0
102  cp++ = '}'
103  cp = '\0'
104  Return buffer
105  out :
106  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*@
108  Return buffer
Caller
NameDescribe
tomoyo_init_logmoyo_init_log - Allocate buffer for audit logs