wireguard.lists.zx2c4.com archive mirror
 help / color / mirror / Atom feed
* Use of __kernel_timespec in userspace genetlink API
@ 2019-04-18 14:06 Matt Layher
  2019-04-22 18:13 ` Tharre
  0 siblings, 1 reply; 4+ messages in thread
From: Matt Layher @ 2019-04-18 14:06 UTC (permalink / raw)
  To: wireguard

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

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Use of __kernel_timespec in userspace genetlink API
  2019-04-18 14:06 Use of __kernel_timespec in userspace genetlink API Matt Layher
@ 2019-04-22 18:13 ` Tharre
  2019-04-22 23:35   ` Ryan Whelan
  0 siblings, 1 reply; 4+ messages in thread
From: Tharre @ 2019-04-22 18:13 UTC (permalink / raw)
  To: Matt Layher; +Cc: wireguard


[-- Attachment #1.1: Type: text/plain, Size: 970 bytes --]

On 04/18, Matt Layher wrote:
> 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.

There is no timespec64 defined anywhere in include/linux, and it can't
be a normal timespec because of the Year 2038 problem. And despite it's
prefix, __kernel_timespec is defined in include/linux/time.h.

> 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.

The change from struct timespec to struct __kernel_timespec happened in
commit c870c7a[0] so I'm guessing it's intentional.

Hope that helps.

[0] http://git.zx2c4.com/WireGuard/commit/?id=c870c7a

-- 
PGP fingerprint: 42CE 7698 D6A0 6129 AA16  EF5C 5431 BDE2 C8F0 B2F4

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 148 bytes --]

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Use of __kernel_timespec in userspace genetlink API
  2019-04-22 18:13 ` Tharre
@ 2019-04-22 23:35   ` Ryan Whelan
  2019-04-22 23:48     ` Tharre
  0 siblings, 1 reply; 4+ messages in thread
From: Ryan Whelan @ 2019-04-22 23:35 UTC (permalink / raw)
  To: Tharre; +Cc: Matt Layher, WireGuard mailing list


[-- Attachment #1.1: Type: text/plain, Size: 1364 bytes --]

Sorry to be dense, but given commit c870c7a; the timespec struct will be 16
bytes in size, regardless of the arch? 32/64bit x86 and 32/64bit ARM?



On Mon, Apr 22, 2019 at 2:15 PM Tharre <tharre3@gmail.com> wrote:

> On 04/18, Matt Layher wrote:
> > 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.
>
> There is no timespec64 defined anywhere in include/linux, and it can't
> be a normal timespec because of the Year 2038 problem. And despite it's
> prefix, __kernel_timespec is defined in include/linux/time.h.
>
> > 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.
>
> The change from struct timespec to struct __kernel_timespec happened in
> commit c870c7a[0] so I'm guessing it's intentional.
>
> Hope that helps.
>
> [0] http://git.zx2c4.com/WireGuard/commit/?id=c870c7a
>
> --
> PGP fingerprint: 42CE 7698 D6A0 6129 AA16  EF5C 5431 BDE2 C8F0 B2F4
> _______________________________________________
> WireGuard mailing list
> WireGuard@lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/wireguard
>

[-- Attachment #1.2: Type: text/html, Size: 2057 bytes --]

[-- Attachment #2: Type: text/plain, Size: 148 bytes --]

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Use of __kernel_timespec in userspace genetlink API
  2019-04-22 23:35   ` Ryan Whelan
@ 2019-04-22 23:48     ` Tharre
  0 siblings, 0 replies; 4+ messages in thread
From: Tharre @ 2019-04-22 23:48 UTC (permalink / raw)
  To: Ryan Whelan; +Cc: Matt Layher, WireGuard mailing list


[-- Attachment #1.1: Type: text/plain, Size: 283 bytes --]

On 04/22, Ryan Whelan wrote:
> Sorry to be dense, but given commit c870c7a; the timespec struct will be 16
> bytes in size, regardless of the arch? 32/64bit x86 and 32/64bit ARM?

Yes, that is correct.

-- 
PGP fingerprint: 42CE 7698 D6A0 6129 AA16  EF5C 5431 BDE2 C8F0 B2F4

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 148 bytes --]

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-22 23:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18 14:06 Use of __kernel_timespec in userspace genetlink API Matt Layher
2019-04-22 18:13 ` Tharre
2019-04-22 23:35   ` Ryan Whelan
2019-04-22 23:48     ` Tharre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).