capabilities: fix potential memleak on error path from vfs_getxattr_alloc()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 8db6c34f1dbc8e06aa016a9b829b06902c3e1340 · < 7480aeff0093d8c54377553ec6b31110bea37b4d| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
capabilities: fix potential memleak on error path from vfs_getxattr_alloc()
In cap_inode_getsecurity(), we will use vfs_getxattr_alloc() to complete the memory allocation of tmpbuf, if we have completed the memory allocation of tmpbuf, but failed to call handler->get(...), there will be a memleak in below logic:
|-- ret = (int)vfs_getxattr_alloc(mnt_userns, ...) | /* ^^^ alloc for tmpbuf */ |-- value = krealloc(*xattr_value, error + 1, flags) | /* ^^^ alloc memory */ |-- error = handler->get(handler, ...) | /* error! */ |-- *xattr_value = value | /* xattr_value is &tmpbuf (memory leak!) */
So we will try to free(tmpbuf) after vfs_getxattr_alloc() fails to fix it.
[PM: subject line and backtrace tweaks]
From the CVE record · Linux
The Linux kernel's cap_inode_getsecurity() can leak memory when vfs_getxattr_alloc() allocates a buffer but a subsequent handler call fails. The input does not establish how an attacker could trigger this path or whether access, authentication, or user interaction is required.
Engineers running the Linux kernel should check their deployments; affected versions are not specified.