[compiler-rt] [rtsan] Add ioctl interceptor (PR #117569)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 26 14:44:52 PST 2024
================
@@ -190,6 +190,23 @@ INTERCEPTOR(int, fcntl, int filedes, int cmd, ...) {
return REAL(fcntl)(filedes, cmd, arg);
}
+INTERCEPTOR(int, ioctl, int filedes, unsigned long request, ...) {
+ __rtsan_notify_intercepted_call("ioctl");
+
+ // See fcntl for discussion on why we use intptr_t
+ // And why we read from va_args on all request types
+ using arg_type = intptr_t;
+ static_assert(sizeof(arg_type) >= sizeof(struct ifreq *));
+ static_assert(sizeof(arg_type) >= sizeof(int));
+
+ va_list args;
+ va_start(args, request);
+ arg_type arg = va_arg(args, arg_type);
+ va_end(args);
+
+ return REAL(ioctl)(filedes, request, arg);
----------------
cjappl wrote:
To my knowledge there is not a va_list overload of `ioctl` - I can't find any mention of one online.
It seems like all `request` have either 0 or one arguments, so I think we can successfully assume that we only have argument in the list
https://github.com/llvm/llvm-project/pull/117569
More information about the llvm-commits
mailing list