diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-04-01 16:51:53 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2015-04-02 01:43:11 -0400 |
commit | 5f5da99f1da5b01c7c45473a500c7dbb77a00958 (patch) | |
tree | d13a71ede7e5d4d2b84da3917d08fedfd7f7fb33 /net/bluetooth | |
parent | 8bf17a3619250944957c732e71659787528131c3 (diff) |
Bluetooth: Restrict HIDP flags to only valid ones
The HIDP flags should be clearly restricted to valid ones. So this puts
extra checks in place to ensure this.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hidp/core.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 07348e142f16..926a0e8b7136 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -70,10 +70,11 @@ static void hidp_session_terminate(struct hidp_session *s); | |||
70 | 70 | ||
71 | static void hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci) | 71 | static void hidp_copy_session(struct hidp_session *session, struct hidp_conninfo *ci) |
72 | { | 72 | { |
73 | u32 valid_flags = 0; | ||
73 | memset(ci, 0, sizeof(*ci)); | 74 | memset(ci, 0, sizeof(*ci)); |
74 | bacpy(&ci->bdaddr, &session->bdaddr); | 75 | bacpy(&ci->bdaddr, &session->bdaddr); |
75 | 76 | ||
76 | ci->flags = session->flags; | 77 | ci->flags = session->flags & valid_flags; |
77 | ci->state = BT_CONNECTED; | 78 | ci->state = BT_CONNECTED; |
78 | 79 | ||
79 | if (session->input) { | 80 | if (session->input) { |
@@ -1312,6 +1313,7 @@ int hidp_connection_add(struct hidp_connadd_req *req, | |||
1312 | struct socket *ctrl_sock, | 1313 | struct socket *ctrl_sock, |
1313 | struct socket *intr_sock) | 1314 | struct socket *intr_sock) |
1314 | { | 1315 | { |
1316 | u32 valid_flags = 0; | ||
1315 | struct hidp_session *session; | 1317 | struct hidp_session *session; |
1316 | struct l2cap_conn *conn; | 1318 | struct l2cap_conn *conn; |
1317 | struct l2cap_chan *chan; | 1319 | struct l2cap_chan *chan; |
@@ -1321,6 +1323,9 @@ int hidp_connection_add(struct hidp_connadd_req *req, | |||
1321 | if (ret) | 1323 | if (ret) |
1322 | return ret; | 1324 | return ret; |
1323 | 1325 | ||
1326 | if (req->flags & ~valid_flags) | ||
1327 | return -EINVAL; | ||
1328 | |||
1324 | chan = l2cap_pi(ctrl_sock->sk)->chan; | 1329 | chan = l2cap_pi(ctrl_sock->sk)->chan; |
1325 | conn = NULL; | 1330 | conn = NULL; |
1326 | l2cap_chan_lock(chan); | 1331 | l2cap_chan_lock(chan); |
@@ -1351,8 +1356,12 @@ out_conn: | |||
1351 | 1356 | ||
1352 | int hidp_connection_del(struct hidp_conndel_req *req) | 1357 | int hidp_connection_del(struct hidp_conndel_req *req) |
1353 | { | 1358 | { |
1359 | u32 valid_flags = BIT(HIDP_VIRTUAL_CABLE_UNPLUG); | ||
1354 | struct hidp_session *session; | 1360 | struct hidp_session *session; |
1355 | 1361 | ||
1362 | if (req->flags & ~valid_flags) | ||
1363 | return -EINVAL; | ||
1364 | |||
1356 | session = hidp_session_find(&req->bdaddr); | 1365 | session = hidp_session_find(&req->bdaddr); |
1357 | if (!session) | 1366 | if (!session) |
1358 | return -ENOENT; | 1367 | return -ENOENT; |