Re: [PATCH] kernel: introduce prctl(PR_LOG_UACCESS)
From: Peter Collingbourne <hidden>
Date: 2021-11-23 05:17:44
Also in:
lkml
On Tue, Sep 21, 2021 at 11:30 PM Cyrill Gorcunov [off-list ref] wrote:
On Tue, Sep 21, 2021 at 11:18:09PM -0700, Peter Collingbourne wrote:quoted
This patch introduces a kernel feature known as uaccess logging. With uaccess logging, the userspace program passes the address and size of a so-called uaccess buffer to the kernel via a prctl(). The prctl() is a request for the kernel to log any uaccesses made during the next syscall to the uaccess buffer. When the next syscall returns, the address one past the end of the logged uaccess buffer entries is written to the location specified by the third argument to the prctl(). In this way, the userspace program may enumerate the uaccesses logged to the access buffer to determine which accesses occurred....quoted
diff --git a/include/linux/sched.h b/include/linux/sched.h index e12b524426b0..3fecb0487b97 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h@@ -34,6 +34,7 @@ #include <linux/rseq.h> #include <linux/seqlock.h> #include <linux/kcsan.h> +#include <linux/uaccess_buffer_info.h> #include <asm/kmap_size.h> /* task_struct member predeclarations (sorted alphabetically): */@@ -1487,6 +1488,8 @@ struct task_struct { struct callback_head l1d_flush_kill; #endif + struct uaccess_buffer_info uaccess_buffer; +Hi, Peter! I didn't read the patch carefully yet (will do once time permit) but from a glance should not this member be under #ifdef CONFIG_UACCESS_BUFFER or something? task_struct is already bloated too much :(
Yes, I've now added an ifdef here (previously I had the ifdef inside the struct uaccess_buffer_info, but I think this would still leave some space due to C struct layout rules).
quoted
+ case PR_LOG_UACCESS: + if (arg5) + return -EINVAL; + error = uaccess_buffer_set_logging(arg2, arg3, arg4); + break;Same here (if only I didn't miss something obvious). If there is no support for CONFIG_UACCESS_BUFFER we should return an error I guess.
The uaccess_buffer_set_logging (now uaccess_buffer_set_descriptor_addr_addr) function is defined to return -EINVAL if CONFIG_UACCESS_BUFFER is not defined. Peter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel