mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rfcomm: fix information leak in rfcomm_sock_bind
@ 2016-01-06  4:36 Insu Yun
  2016-01-06  6:48 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Insu Yun @ 2016-01-06  4:36 UTC (permalink / raw)
  To: marcel, gustavo, johan.hedberg, davem, peter, jaganath.k,
	ying.xue, ebiederm, linux-bluetooth, netdev, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun

if addr_len < sizeof(sa), sa.rc_bdaddr(4bytes) can be leaked 
by using rfcomm_sock_getname()

Signed-off-by: Insu Yun <wuninsu@gmail.com>
---
 net/bluetooth/rfcomm/sock.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 7511df7..d61dfdc 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -336,14 +336,15 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
 {
 	struct sockaddr_rc sa;
 	struct sock *sk = sock->sk;
-	int len, err = 0;
+	int err = 0;
 
 	if (!addr || addr->sa_family != AF_BLUETOOTH)
 		return -EINVAL;
 
-	memset(&sa, 0, sizeof(sa));
-	len = min_t(unsigned int, sizeof(sa), addr_len);
-	memcpy(&sa, addr, len);
+	if (addr_len != sizeof(sa))
+		return -EINVAL;
+
+	memcpy(&sa, addr, addr_len);
 
 	BT_DBG("sk %p %pMR", sk, &sa.rc_bdaddr);
 
-- 
1.9.1


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

end of thread, other threads:[~2016-01-06  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-06  4:36 [PATCH] rfcomm: fix information leak in rfcomm_sock_bind Insu Yun
2016-01-06  6:48 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®