CVE-2024-50067: uprobe: avoid out-of-bounds memory access of fetching args

0.0 CVSS

Description

In the Linux kernel, the following vulnerability has been resolved:

uprobe: avoid out-of-bounds memory access of fetching args

Uprobe needs to fetch args into a percpu buffer, and then copy to ring
buffer to avoid non-atomic context problem.

Sometimes user-space strings, arrays can be very large, but the size of
percpu buffer is only page size. And store_trace_args() won't check
whether these data exceeds a single page or not, caused out-of-bounds
memory access.

It could be reproduced by following steps:
1. build kernel with CONFIG_KASAN enabled
2. save follow program as test.c

```
\#include
\#include
\#include

// If string length large than MAX_STRING_SIZE, the fetch_store_strlen()
// will return 0, cause __get_data_size() return shorter size, and
// store_trace_args() will not trigger out-of-bounds access.
// So make string length less than 4096.
\#define STRLEN 4093

void generate_string(char *str, int n)
{
int i;
for (i = 0; i < n; ++i)
{
char c = i % 26 + 'a';
str[i] = c;
}
str[n-1] = '\0';
}

void print_string(char *str)
{
printf("%s\n", str);
}

int main()
{
char tmp[STRLEN];

generate_string(tmp, STRLEN);
print_string(tmp);

return 0;
}
```
3. compile program
`gcc -o test test.c`

4. get the offset of `print_string()`
```
objdump -t test | grep -w print_string
0000000000401199 g F .text 000000000000001b print_string
```

5. configure uprobe with offset 0x1199
```
off=0x1199

cd /sys/...

Classification

CVE ID: CVE-2024-50067

CVSS Base Severity: LOW

CVSS Base Score: 0.0

Affected Products

Vendor: Linux

Product: Linux

Exploit Prediction Scoring System (EPSS)

EPSS Score: 0.04% (probability of being exploited)

EPSS Percentile: 5.08% (scored less or equal to compared to others)

EPSS Date: 2025-02-04 (when was this score calculated)

References

https://git.kernel.org/stable/c/0dc3ad9ad2188da7f090b3dbe4d2fcd9ae8ae64f
https://git.kernel.org/stable/c/9e5f93788c9dd4309e75a56860a1ac44a8e117b9
https://git.kernel.org/stable/c/537ad4a431f6dddbf15d40d19f24bb9ee12b55cb
https://git.kernel.org/stable/c/373b9338c9722a368925d83bc622c596896b328e

Timeline