Use of __kernel_timespec in userspace genetlink API

Matt Layher mdlayher at gmail.com
Thu Apr 18 16:06:17 CEST 2019


Hey all,

I recently received a bug report for 
https://github.com/mdlayher/wireguardctrl which indicated that the 
timespec structure being returned from the WireGuard genetlink API was 
not of the expected size on a 32-bit machine.

It then occurred to us that the userspace-facing API is returning a 
"__kernel_timespec"; something I did not realize before:

https://git.zx2c4.com/WireGuard/tree/src/uapi/wireguard.h?id=91b0a211861d487382a534572844ff29839064f1#n38
https://git.zx2c4.com/WireGuard/tree/src/netlink.c?id=91b0a211861d487382a534572844ff29839064f1#n112

My C experience is very limited, and I have no experience working on C 
within the kernel, but is exposing a "__kernel*" type to userspace a 
normal procedure? I would have expected to see a regular timespec from 
linux/time.h, or perhaps a timespec64 in its place.

I can do some slightly more intelligent checking to fix the current 
issue with my library, but I wanted to check in and confirm that this 
API contract is correct.

Thanks for your time!
- Matt Layher



More information about the WireGuard mailing list