2017-04-25 01:25:04

by Szymon Janc

[permalink] [raw]
Subject: [PATCH] Bluetooth: Fix user channel for 32bit userspace on 64bit kernel

Running 32bit userspace on 64bit kernel results in MSG_CMSG_COMPAT being
defined as 0x80000000. This results in sendmsg failure if used from 32bit
userspace running on 64bit kernel. Fix this by accounting for MSG_CMSG_COMPAT
in flags check in hci_sock_sendmsg.

Signed-off-by: Szymon Janc <[email protected]>
Signed-off-by: Marko Kiiskila <[email protected]>
---
net/bluetooth/hci_sock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index f64d656..e9d3e1b 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -1680,7 +1680,8 @@ static int hci_sock_sendmsg(struct socket *sock, struct msghdr *msg,
if (msg->msg_flags & MSG_OOB)
return -EOPNOTSUPP;

- if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE))
+ if (msg->msg_flags &
+ ~(MSG_DONTWAIT|MSG_NOSIGNAL|MSG_ERRQUEUE|MSG_CMSG_COMPAT))
return -EINVAL;

if (len < 4 || len > HCI_MAX_FRAME_SIZE)
--
2.9.3



2017-04-25 02:53:08

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH] Bluetooth: Fix user channel for 32bit userspace on 64bit kernel

Hi Szymon,

> Running 32bit userspace on 64bit kernel results in MSG_CMSG_COMPAT being
> defined as 0x80000000. This results in sendmsg failure if used from 32bit
> userspace running on 64bit kernel. Fix this by accounting for MSG_CMSG_COMPAT
> in flags check in hci_sock_sendmsg.
>
> Signed-off-by: Szymon Janc <[email protected]>
> Signed-off-by: Marko Kiiskila <[email protected]>
> ---
> net/bluetooth/hci_sock.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel