Commit 767c5eb5d35aeb85987143f0a730bc21d3ecfb3d

Authored by Marcel Holtmann
1 parent 26a4a06e7f

[Bluetooth] Add compat handling for timestamp structure

The timestamp structure needs special handling in case of compat
programs. Use the same wrapping method the network core uses.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Showing 1 changed file with 16 additions and 1 deletions Side-by-side Diff

net/bluetooth/hci_sock.c
... ... @@ -37,6 +37,7 @@
37 37 #include <linux/skbuff.h>
38 38 #include <linux/workqueue.h>
39 39 #include <linux/interrupt.h>
  40 +#include <linux/compat.h>
40 41 #include <linux/socket.h>
41 42 #include <linux/ioctl.h>
42 43 #include <net/sock.h>
43 44  
... ... @@ -342,9 +343,23 @@
342 343  
343 344 if (mask & HCI_CMSG_TSTAMP) {
344 345 struct timeval tv;
  346 + void *data;
  347 + int len;
345 348  
346 349 skb_get_timestamp(skb, &tv);
347   - put_cmsg(msg, SOL_HCI, HCI_CMSG_TSTAMP, sizeof(tv), &tv);
  350 +
  351 + if (msg->msg_flags & MSG_CMSG_COMPAT) {
  352 + struct compat_timeval ctv;
  353 + ctv.tv_sec = tv.tv_sec;
  354 + ctv.tv_usec = tv.tv_usec;
  355 + data = &ctv;
  356 + len = sizeof(ctv);
  357 + } else {
  358 + data = &tv;
  359 + len = sizeof(tv);
  360 + }
  361 +
  362 + put_cmsg(msg, SOL_HCI, HCI_CMSG_TSTAMP, len, data);
348 363 }
349 364 }
350 365