Commit 2f42878e authored by Junxiao Bi's avatar Junxiao Bi Committed by Willy Tarreau

oprofile: use KM_NMI slot for kmap_atomic

If one kernel path is using KM_USER0 slot and is interrupted by
the oprofile nmi, then in copy_from_user_nmi(), the KM_USER0 slot
will be overwrite and cleared to zero at last, when the control
return to the original kernel path, it will access an invalid
virtual address and trigger a crash.

Cc: Robert Richter <robert.richter@amd.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJunxiao Bi <junxiao.bi@oracle.com>

[WT: According to Junxiao and Robert, this patch is needed for stable kernels
 which include a backport of a0e3e702 without
 3e4d3af5, but there is no exact equivalent in
 mainline]
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 012660d6
......@@ -71,9 +71,9 @@ copy_from_user_nmi(void *to, const void __user *from, unsigned long n)
offset = addr & (PAGE_SIZE - 1);
size = min(PAGE_SIZE - offset, n - len);
map = kmap_atomic(page, KM_USER0);
map = kmap_atomic(page, KM_NMI);
memcpy(to, map+offset, size);
kunmap_atomic(map, KM_USER0);
kunmap_atomic(map, KM_NMI);
put_page(page);
len += size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment