projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
1268ed0
)
x86/mtrr: Don't copy out-of-bounds data in mtrr_write
author
Jann Horn
<
[email protected]
>
Fri, 6 Jul 2018 21:50:03 +0000
(23:50 +0200)
committer
Thomas Gleixner
<
[email protected]
>
Sat, 7 Jul 2018 16:58:41 +0000
(18:58 +0200)
Don't access the provided buffer out of bounds - this can cause a kernel
out-of-bounds read when invoked through sys_splice() or other things that
use kernel_write()/__kernel_write().
Fixes: 7f8ec5a4f01a ("x86/mtrr: Convert to use strncpy_from_user() helper")
Signed-off-by: Jann Horn <
[email protected]
>
Signed-off-by: Thomas Gleixner <
[email protected]
>
Cc: Andy Shevchenko <
[email protected]
>
Cc: "H. Peter Anvin" <
[email protected]
>
Cc:
[email protected]
Link:
https://lkml.kernel.org/r/
[email protected]
arch/x86/kernel/cpu/mtrr/if.c
patch
|
blob
|
history
diff --git
a/arch/x86/kernel/cpu/mtrr/if.c
b/arch/x86/kernel/cpu/mtrr/if.c
index 4021d3859499c77c14eaa1c40864c752547df68c..40eee6cc412484470daba013f2a197439163707a 100644
(file)
--- a/
arch/x86/kernel/cpu/mtrr/if.c
+++ b/
arch/x86/kernel/cpu/mtrr/if.c
@@
-106,7
+106,8
@@
mtrr_write(struct file *file, const char __user *buf, size_t len, loff_t * ppos)
memset(line, 0, LINE_SIZE);
- length = strncpy_from_user(line, buf, LINE_SIZE - 1);
+ len = min_t(size_t, len, LINE_SIZE - 1);
+ length = strncpy_from_user(line, buf, len);
if (length < 0)
return length;