mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-14 12:06:48 +00:00
增加对read和write的空间校验
This commit is contained in:
parent
0e624b1fcf
commit
7598f63383
@ -169,6 +169,10 @@ uint64_t sys_read(struct pt_regs *regs)
|
||||
void *buf = (void *)regs->r9;
|
||||
int64_t count = (int64_t)regs->r10;
|
||||
|
||||
// 校验buf的空间范围
|
||||
if(SYSCALL_FROM_USER(regs) && (!verify_area(buf, count)))
|
||||
return -EPERM;
|
||||
|
||||
// kdebug("sys read: fd=%d", fd_num);
|
||||
|
||||
// 校验文件描述符范围
|
||||
@ -205,6 +209,9 @@ uint64_t sys_write(struct pt_regs *regs)
|
||||
void *buf = (void *)regs->r9;
|
||||
int64_t count = (int64_t)regs->r10;
|
||||
|
||||
// 校验buf的空间范围
|
||||
if(SYSCALL_FROM_USER(regs) && (!verify_area(buf, count)))
|
||||
return -EPERM;
|
||||
kdebug("sys write: fd=%d", fd_num);
|
||||
|
||||
// 校验文件描述符范围
|
||||
|
Loading…
x
Reference in New Issue
Block a user