Skip to content

kernel: use kvrealloc#3087

Merged
aviraxp merged 1 commit into
devfrom
kvrealloc
Dec 21, 2025
Merged

kernel: use kvrealloc#3087
aviraxp merged 1 commit into
devfrom
kvrealloc

Conversation

@5ec1cff

@5ec1cff 5ec1cff commented Dec 21, 2025

Copy link
Copy Markdown
Collaborator

We used to think that oneplus protected the original memory with RO, but we are wrong. Why kfree() panic kernel is that original memory isn't allocated with kmalloc() but kvmalloc(). Normal device will eventually use kmalloc() anyway, but oneplus seems to use more aggressive memory allocation optimization and switched to vmalloc() path.

Use kvrealloc() to fix it. Note, kvrealloc() will check flags first and use kmalloc() if GFP_ATOMIC is passed, so it is fine to be called in kprobe context. This also fix the last memory leak we found in ksu driver.

@aviraxp aviraxp changed the title use kvrealloc kernel: use kvrealloc Dec 21, 2025
@aviraxp aviraxp changed the base branch from main to dev December 21, 2025 15:16
@aviraxp aviraxp changed the base branch from dev to main December 21, 2025 15:16
@aviraxp aviraxp changed the base branch from main to dev December 21, 2025 15:18
@aviraxp aviraxp merged commit 4bd9d3d into dev Dec 21, 2025
17 checks passed
@aviraxp aviraxp deleted the kvrealloc branch December 21, 2025 15:18
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 22, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref: tiann#3087

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 22, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref: tiann#3087

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 22, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 22, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 22, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 22, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 22, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 23, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 23, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 23, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 23, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 23, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
sakana164 pushed a commit to sakana164/KernelSU that referenced this pull request Dec 23, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 24, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 24, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
sakana164 pushed a commit to sakana164/KernelSU that referenced this pull request Dec 24, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 25, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
sakana164 pushed a commit to sakana164/KernelSU that referenced this pull request Dec 25, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
sakana164 pushed a commit to sakana164/KernelSU that referenced this pull request Dec 25, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 25, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 25, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 25, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 28, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 28, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 28, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 28, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
sakana164 pushed a commit to sakana164/KernelSU that referenced this pull request Dec 28, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
sakana164 pushed a commit to sakana164/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
sakana164 pushed a commit to sakana164/KernelSU that referenced this pull request Dec 30, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
this tries to mimic the behavior of 6.12+'s kvrealloc
where it straight up opts out of kasan checks.

we dont have unsafe_memcpy on older kernels
its just a macro of __builtin_memcpy anyway.

ref:
tiann#3087
tiann#3089
tiann@438559c *

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
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.

2 participants