All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 RESEND] bluetooth:Fix locking issues in the function l2cap_connect_cfm
@ 2016-02-26 14:16 Nicholas Krause
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Krause @ 2016-02-26 14:16 UTC (permalink / raw)
  To: marcel
  Cc: gustavo, johan.hedberg, davem, linux-bluetooth, netdev, linux-kernel

This fixes a locking issue in the function l2cap_connect_cfm for
not locking the mutex lock for channels on the l2cap_conn structure
pointer conn before calling __l2cap_get_chan_by_dcid as all callers
need to lock and unlock this mutex before calling this function due
to issues with either concurrent users or race conditions arising
if this mutex is not locked before these calls.
v3 Fix double locking of mutex lock on goto next label to instead correctly
unlock the channel mutex
v2 Remove unneeded mutex_unlock for channels as the unlock was due early
for adding correct protection for all functions that have requirements
for this mutex lock needing to be locked before calling them.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 net/bluetooth/l2cap_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 45fffa4..20d3909 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7285,6 +7285,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 		struct l2cap_chan *chan, *next;
 
 		/* Client fixed channels should override server ones */
+		mutex_lock(&conn->chan_lock);
 		if (__l2cap_get_chan_by_dcid(conn, pchan->scid))
 			goto next;
 
@@ -7301,6 +7302,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 
 		l2cap_chan_unlock(pchan);
 next:
+		mutex_unlock(&conn->chan_lock);
 		next = l2cap_global_fixed_chan(pchan, hcon);
 		l2cap_chan_put(pchan);
 		pchan = next;
-- 
2.1.4

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

* [PATCH v3 RESEND] bluetooth:Fix locking issues in the function l2cap_connect_cfm
@ 2016-03-07 22:59 Nicholas Krause
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Krause @ 2016-03-07 22:59 UTC (permalink / raw)
  To: marcel; +Cc: gustavo, johan.hedberg, davem, linux-bluetooth, netdev

This fixes a locking issue in the function l2cap_connect_cfm for
not locking the mutex lock for channels on the l2cap_conn structure
pointer conn before calling __l2cap_get_chan_by_dcid as all callers
need to lock and unlock this mutex before calling this function due
to issues with either concurrent users or race conditions arising
if this mutex is not locked before these calls.
v3 Fix double locking of mutex lock on goto next label to instead correctly
unlock the channel mutex
v2 Remove unneeded mutex_unlock for channels as the unlock was due early
for adding correct protection for all functions that have requirements
for this mutex lock needing to be locked before calling them.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 net/bluetooth/l2cap_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 45fffa4..20d3909 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7285,6 +7285,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 		struct l2cap_chan *chan, *next;
 
 		/* Client fixed channels should override server ones */
+		mutex_lock(&conn->chan_lock);
 		if (__l2cap_get_chan_by_dcid(conn, pchan->scid))
 			goto next;
 
@@ -7301,6 +7302,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 
 		l2cap_chan_unlock(pchan);
 next:
+		mutex_unlock(&conn->chan_lock);
 		next = l2cap_global_fixed_chan(pchan, hcon);
 		l2cap_chan_put(pchan);
 		pchan = next;
-- 
2.1.4

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

* [PATCH v3 RESEND] bluetooth:Fix locking issues in the function l2cap_connect_cfm
@ 2015-12-20  7:35 Nicholas Krause
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Krause @ 2015-12-20  7:35 UTC (permalink / raw)
  To: marcel
  Cc: gustavo, johan.hedberg, davem, linux-bluetooth, netdev, linux-kernel

This fixes a locking issue in the function l2cap_connect_cfm for
not locking the mutex lock for channels on the l2cap_conn structure
pointer conn before calling __l2cap_get_chan_by_dcid as all callers
need to lock and unlock this mutex before calling this function due
to issues with either concurrent users or race conditions arising
if this mutex is not locked before these calls.
v3 Fix double locking of mutex lock on goto next label to instead correctly
unlock the channel mutex
v2 Remove unneeded mutex_unlock for channels as the unlock was due early
for adding correct protection for all functions that have requirements
for this mutex lock needing to be locked before calling them.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 net/bluetooth/l2cap_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 45fffa4..20d3909 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7285,6 +7285,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 		struct l2cap_chan *chan, *next;
 
 		/* Client fixed channels should override server ones */
+		mutex_lock(&conn->chan_lock);
 		if (__l2cap_get_chan_by_dcid(conn, pchan->scid))
 			goto next;
 
@@ -7301,6 +7302,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 
 		l2cap_chan_unlock(pchan);
 next:
+		mutex_unlock(&conn->chan_lock);
 		next = l2cap_global_fixed_chan(pchan, hcon);
 		l2cap_chan_put(pchan);
 		pchan = next;
-- 
2.1.4

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

* [PATCH v3 RESEND] bluetooth:Fix locking issues in the function l2cap_connect_cfm
@ 2015-11-27 15:16 Nicholas Krause
  0 siblings, 0 replies; 4+ messages in thread
From: Nicholas Krause @ 2015-11-27 15:16 UTC (permalink / raw)
  To: marcel
  Cc: gustavo, johan.hedberg, davem, linux-bluetooth, netdev, linux-kernel

This fixes a locking issue in the function l2cap_connect_cfm for
not locking the mutex lock for channels on the l2cap_conn structure
pointer conn before calling __l2cap_get_chan_by_dcid as all callers
need to lock and unlock this mutex before calling this function due
to issues with either concurrent users or race conditions arising
if this mutex is not locked before these calls.
v3 Fix double locking of mutex lock on goto next label to instead correctly
unlock the channel mutex
v2 Remove unneeded mutex_unlock for channels as the unlock was due early
for adding correct protection for all functions that have requirements
for this mutex lock needing to be locked before calling them.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 net/bluetooth/l2cap_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 45fffa4..20d3909 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -7285,6 +7285,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 		struct l2cap_chan *chan, *next;
 
 		/* Client fixed channels should override server ones */
+		mutex_lock(&conn->chan_lock);
 		if (__l2cap_get_chan_by_dcid(conn, pchan->scid))
 			goto next;
 
@@ -7301,6 +7302,7 @@ static void l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 
 		l2cap_chan_unlock(pchan);
 next:
+		mutex_unlock(&conn->chan_lock);
 		next = l2cap_global_fixed_chan(pchan, hcon);
 		l2cap_chan_put(pchan);
 		pchan = next;
-- 
2.1.4

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

end of thread, other threads:[~2016-03-07 22:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26 14:16 [PATCH v3 RESEND] bluetooth:Fix locking issues in the function l2cap_connect_cfm Nicholas Krause
  -- strict thread matches above, loose matches on Subject: below --
2016-03-07 22:59 Nicholas Krause
2015-12-20  7:35 Nicholas Krause
2015-11-27 15:16 Nicholas Krause

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.