Skip to content

Prevent LCS from allocating temp memory over proto-max-bulk-len#9817

Merged
oranagra merged 1 commit intoredis:unstablefrom
oranagra:lcs_mem_limit
Nov 21, 2021
Merged

Prevent LCS from allocating temp memory over proto-max-bulk-len#9817
oranagra merged 1 commit intoredis:unstablefrom
oranagra:lcs_mem_limit

Conversation

@oranagra
Copy link
Copy Markdown
Member

@oranagra oranagra commented Nov 21, 2021

LCS can allocate immense amount of memory (sizes of two inputs multiplied by each other).
In the past this caused some possible security issues due to overflows, which we solved
and also added use of trymalloc to return "Insufficient memory" instead of OOM panic zmalloc.

But in case overcommit is enabled, it could be that we won't get the OOM panic, and zmalloc
will succeed, and then we can get OOM killed by the kernel.

The solution here is to prevent LCS from allocating transient memory that's bigger than
proto-max-bulk-len config.
This config is not directly related to transient memory, but using a hard coded value ad well as
introducing a specific config seems wrong.

This comes to solve an error in the corrupt-dump-fuzzer test that started in the daily CI see #9799

@oranagra oranagra requested a review from yossigo November 21, 2021 10:07
@oranagra
Copy link
Copy Markdown
Member Author

@yossigo should this go on the release notes?

@yossigo
Copy link
Copy Markdown
Collaborator

yossigo commented Nov 21, 2021

@oranagra I'd say yes, we anyway document the command change so we can mention it also imposes a new memory limit.

@oranagra oranagra added the release-notes indication that this issue needs to be mentioned in the release notes label Nov 21, 2021
@oranagra oranagra merged commit 1417648 into redis:unstable Nov 21, 2021
@oranagra oranagra deleted the lcs_mem_limit branch November 21, 2021 12:30
hwware pushed a commit to hwware/redis that referenced this pull request Dec 20, 2021
…s#9817)

LCS can allocate immense amount of memory (sizes of two inputs multiplied by each other).
In the past this caused some possible security issues due to overflows, which we solved
and also added use of `trymalloc` to return "Insufficient memory" instead of OOM panic zmalloc.

But in case overcommit is enabled, it could be that we won't get the OOM panic, and zmalloc
will succeed, and then we can get OOM killed by the kernel.

The solution here is to prevent LCS from allocating transient memory that's bigger than
`proto-max-bulk-len` config.
This config is not directly related to transient memory, but using a hard coded value ad well as
introducing a specific config seems wrong.

This comes to solve an error in the corrupt-dump-fuzzer test that started in the daily CI see redis#9799
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes indication that this issue needs to be mentioned in the release notes

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants