CVE-2022-49771

Source
https://nvd.nist.gov/vuln/detail/CVE-2022-49771
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2022-49771.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2022-49771
Related
Published
2025-05-01T15:16:00Z
Modified
2025-05-02T14:49:44.735303Z
Summary
[none]
Details

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

dm ioctl: fix misbehavior if list_versions races with module loading

_listversions will first estimate the required space using the "dmtargetiterate(listversiongetneeded, &needed)" call and then will fill the space using the "dmtargetiterate(listversiongetinfo, &iterinfo)" call. Each of these calls locks the targets using the "downread(&lock)" and "upread(&lock)" calls, however between the first and second "dmtargetiterate" there is no lock held and the target modules can be loaded at this point, so the second "dmtargetiterate" call may need more space than what was the first "dmtarget_iterate" returned.

The code tries to handle this overflow (see the beginning of listversionget_info), however this handling is incorrect.

The code sets "param->datasize = param->datastart + needed" and "iterinfo.end = (char *)vers+len" - "needed" is the size returned by the first dmtarget_iterate call; "len" is the size of the buffer allocated by userspace.

"len" may be greater than "needed"; in this case, the code will write up to "len" bytes into the buffer, however param->datasize is set to "needed", so it may write data past the param->datasize value. The ioctl interface copies only up to param->data_size into userspace, thus part of the result will be truncated.

Fix this bug by setting "iterinfo.end = (char *)vers + needed;" - this guarantees that the second "dmtargetiterate" call will write only up to the "needed" buffer and it will exit with "DMBUFFERFULLFLAG" if it overflows the "needed" space - in this case, userspace will allocate a larger buffer and retry.

Note that there is also a bug in listversionget_needed - we need to add "strlen(tt->name) + 1" to the needed size, not "strlen(tt->name)".

References

Affected packages

Debian:11 / linux

Package

Name
linux
Purl
pkg:deb/debian/linux?arch=source

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
5.10.158-1

Affected versions

5.*

5.10.46-4
5.10.46-5
5.10.70-1~bpo10+1
5.10.70-1
5.10.84-1
5.10.92-1~bpo10+1
5.10.92-1
5.10.92-2
5.10.103-1~bpo10+1
5.10.103-1
5.10.106-1
5.10.113-1
5.10.120-1~bpo10+1
5.10.120-1
5.10.127-1
5.10.127-2~bpo10+1
5.10.127-2
5.10.136-1
5.10.140-1
5.10.148-1
5.10.149-1
5.10.149-2

Ecosystem specific

{
    "urgency": "not yet assigned"
}

Debian:12 / linux

Package

Name
linux
Purl
pkg:deb/debian/linux?arch=source

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
6.0.10-1

Ecosystem specific

{
    "urgency": "not yet assigned"
}

Debian:13 / linux

Package

Name
linux
Purl
pkg:deb/debian/linux?arch=source

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
6.0.10-1

Ecosystem specific

{
    "urgency": "not yet assigned"
}