Repository navigation
Check ev_code range in EVIOCGABS and EVIOCSABS - #264
Open
argusSecurityBot wants to merge 1 commit into
Open
argusSecurityBot wants to merge 1 commit into
argusSecurityBot wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
InputDevice.absinfo(axis_num)andset_absinfo(axis_num, ...)pass the axis code throughioctl_EVIOCGABS/ioctl_EVIOCSABSinsrc/evdev/input.c, which parse it as a plainint(input.c:261,input.c:288).It then reaches
ioctl(fd, EVIOCGABS(ev_code), &absinfo)(input.c:265) andioctl(fd, EVIOCSABS(ev_code), &absinfo)(input.c:300) with no range check.EVIOCGABS(abs)is_IOR('E', 0x40 + (abs), struct input_absinfo), so any code aboveABS_MAX(0x3f) names a request outside the absinfo range, and from 192 on0x40 + ev_codeno longer fits the 8-bit number field and_IOCORs its high bits into the type/size/direction bits, issuing a different ioctl with a 24-byteinput_absinfoas its argument.At
INT_MAXthe0x40 + ev_codeaddition is also signed integer overflow.Fix: reject
ev_code < 0orev_code > ABS_MAXwithValueErrorin both functions before callingioctl.With a UBSan build at 9508e52:
src/evdev/input.c:265:21: runtime error: signed integer overflow: 64 + 2147483647 cannot be represented in type 'int'.This patch was generated with Claude and reviewed by a human on our team. It passes the project's existing tests (11 passed before and after; the 6 tests in tests/test_uinput.py need /dev/uinput and fail the same way without this patch). The vulnerability itself was verified by a human; if you'd prefer not to take LLM-generated code, feel free to close this PR.