Skip to content

Fix invalid access in lpFind on corrupted listpack#9819

Merged
oranagra merged 2 commits intoredis:unstablefrom
oranagra:fix_lpfind_access
Nov 22, 2021
Merged

Fix invalid access in lpFind on corrupted listpack#9819
oranagra merged 2 commits intoredis:unstablefrom
oranagra:fix_lpfind_access

Conversation

@oranagra
Copy link
Member

Issue found by corrupt-dump-fuzzer test with ASAN.
The problem was that lpSkip and lpGetWithSize could read the next listpack entry without validating that it's in range.
Similarly even the memcmp in lpFind could do that and possibly crash on segfault and now they'll crash on assert first.

The naive fix of using lpAssertValidEntry every time, resulted in 30% degradation in the lpFind benchmark of the unit test.
The final fix with the condition at the bottom has no performance implications.

@oranagra oranagra requested review from sundb and yossigo November 21, 2021 19:15
@oranagra oranagra merged commit f07dedf into redis:unstable Nov 22, 2021
@oranagra oranagra deleted the fix_lpfind_access branch November 22, 2021 13:30
hwware pushed a commit to hwware/redis that referenced this pull request Dec 20, 2021
Issue found by corrupt-dump-fuzzer test with ASAN.
The problem was that lpSkip and lpGetWithSize could read the next listpack entry without validating that it's in range.
Similarly even the memcmp in lpFind could do that and possibly crash on segfault and now they'll crash on assert first.

The naive fix of using lpAssertValidEntry every time, resulted in 30% degradation in the lpFind benchmark of the unit test.
The final fix with the condition at the bottom has no performance implications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants