Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the bug about rwbuffer causing mem overflow #12056

Closed
wants to merge 0 commits into from

Conversation

ChenChuangForLinux
Copy link

when the offest from rwb->wrblockstart to startblock plus rwb->wrnblocks is greater than rwb->wralignblocks, it will be causing memory overflow since rwb->wrbuffer is allocated rwb.wrmaxblock(rwb.wralignblocks) bytes.

Summary

Impact

Testing

@ChenChuangForLinux
Copy link
Author

when the offest from rwb->wrblockstart to startblock plus rwb->wrnblocks is greater than rwb->wralignblocks, it will be causing memory overflow since rwb->wrbuffer is allocated rwb.wrmaxblock(rwb.wralignblocks) block_size bytes

@acassis
Copy link
Contributor

acassis commented Apr 5, 2024

@ChenChuangForLinux please check coding style issues:

$ ./tools/checkpatch.sh -f drivers/misc/rwbuffer.c

And fix the issues

@xiaoxiang781216
Copy link
Contributor

@ChenChuangForLinux please squash into one patch.

drivers/misc/rwbuffer.c Outdated Show resolved Hide resolved
{
tmp_blocks = padblocks - rwb->wrnblocks -
rwb->wralignblocks;
tmp = kmm_malloc(tmp_blocks * rwb->blocksize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it isn't good to allocate temp buffer in the hot path.

@xiaoxiang781216
Copy link
Contributor

@ChenChuangForLinux please remove the merge patch from pr.

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.

None yet

4 participants