Forwarded: [PATCH] x86/mm/pat: fix oob error

syzbot posted 1 patch 2 weeks, 5 days ago
arch/x86/mm/pat/set_memory.c | 3 +++
1 file changed, 3 insertions(+)
Forwarded: [PATCH] x86/mm/pat: fix oob error
Posted by syzbot 2 weeks, 5 days ago
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] x86/mm/pat: fix oob error
Author: chandna.linuxkernel@gmail.com

Signed-off-by: Sahil Chandna <chandna.linuxkernel@gmail.com>
---
 arch/x86/mm/pat/set_memory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
index 8834c76f91c9..944e6a912fc6 100644
#syz test

--- a/arch/x86/mm/pat/set_memory.c
+++ b/arch/x86/mm/pat/set_memory.c
@@ -305,6 +305,9 @@ static inline unsigned long fix_addr(unsigned long addr)
 
 static unsigned long __cpa_addr(struct cpa_data *cpa, unsigned long idx)
 {
+	if (WARN_ON_ONCE(!cpa->pages || !cpa->pages[idx]))
+		return 0;
+
 	if (cpa->flags & CPA_PAGES_ARRAY) {
 		struct page *page = cpa->pages[idx];
 
-- 
2.51.0