Bug 9082 - Fix show_rcu_tasks_trace_gp_kthread buffer overflow
Summary: Fix show_rcu_tasks_trace_gp_kthread buffer overflow
Status: NEW
Alias: None
Product: ANCK 5.10 Dev
Classification: ANCK
Component: general/others (show other bugs) general/others
Version: unspecified
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: banye97
QA Contact: shuming
URL:
Whiteboard:
Keywords: Bugfix
Depends on:
Blocks:
 
Reported: 2024-05-20 15:53 UTC by YudeSS
Modified: 2024-05-20 16:38 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description YudeSS 2024-05-20 15:53:45 UTC
Description of problem:

The original code uses sprintf to format the string and store it in buf. sprintf does not check the buffer size, so if the resulting string exceeds the size of buf (64 bytes), a buffer overflow will occur.
Buffer overflows corrupt memory data and may cause program crashes or other unpredictable behavior.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.Replace sprintf with snprintf and specify the buffer size sizeof(buf).
snprintf will check the buffer size when formatting the string to ensure that no data exceeding the buffer size is written to avoid buffer overflow.

Actual results:


Expected results:


Additional info:
Comment 1 小龙 admin 2024-05-20 16:38:55 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/3229