Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\kmemleak.c Create Date:2022-07-28 16:22:34
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:File write operation to configure kmemleak at run-time

Proto:static ssize_t kmemleak_write(struct file *file, const char __user *user_buf, size_t size, loff_t *ppos)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
const char __user *user_buf
size_tsize
loff_t *ppos
1774  buf_size = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(size, ( size of buf - 1))
1775  If Copy a NUL terminated string from userspace < 0 Then Return -EFAULT
1777  buf[buf_size] = 0
1779  ret = mutex_lock_interruptible( & protects the memory scanning, parameters and debug/kmemleak file access )
1780  If ret < 0 Then Return ret
1783  If strncmp(buf, "clear", 5) == 0 Then
1784  If set if tracing memory operations is enabled Then We use grey instead of black to ensure we can do future scans on the same* objects. If we did not do future scans these black objects could* potentially contain references to newly allocated objects in the future and* we'd end up with false positives.
1786  Else __kmemleak_do_cleanup()
1788  Go to out
1791  If Not set if tracing memory operations is enabled Then
1792  ret = -EPERM
1793  Go to out
1796  If strncmp(buf, "off", 3) == 0 Then kmemleak_disable()
1798  Else if strncmp(buf, "stack=on", 8) == 0 Then ables or disables the task stacks scanning = 1
1800  Else if strncmp(buf, "stack=off", 9) == 0 Then ables or disables the task stacks scanning = 0
1802  Else if strncmp(buf, "scan=on", 7) == 0 Then Start the automatic memory scanning thread. This function must be called* with the scan_mutex held.
1804  Else if strncmp(buf, "scan=off", 8) == 0 Then Stop the automatic memory scanning thread.
1806  Else if strncmp(buf, "scan=", 5) == 0 Then
1809  ret = kstrtoul - convert a string to an unsigned long*@s: The start of the string. The string must be null-terminated, and may also* include a single newline before its terminating null. The first character* may also be a plus sign, but not a minus sign.
1810  If ret < 0 Then Go to out
1812  Stop the automatic memory scanning thread.
1813  If secs Then
1817  Else if strncmp(buf, "scan", 4) == 0 Then Scan data sections and all the referenced memory blocks allocated via the* kernel's standard allocators. This function must be called with the* scan_mutex held.
1819  Else if strncmp(buf, "dump=", 5) == 0 Then ret = dump_str_object_info(buf + 5)
1821  Else ret = -EINVAL
1824  out :
1825  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
1826  If ret < 0 Then Return ret
1830  ppos += size
1831  Return size