linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gustavo Padovan <gustavo@padovan.org>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 2/2] Bluetooth: report the right security level in getsockopt
Date: Thu,  3 May 2012 22:59:54 -0300	[thread overview]
Message-ID: <1336096794-16993-2-git-send-email-gustavo@padovan.org> (raw)
In-Reply-To: <1336096794-16993-1-git-send-email-gustavo@padovan.org>

During a security level elevation we need to keep track of the current
security level of a connection until the new one is not confirmed.

Signed-off-by: Gustavo Padovan <gustavo@padovan.org>
---
 include/net/bluetooth/l2cap.h |    1 +
 net/bluetooth/l2cap_sock.c    |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 92c0423..ff34be7 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -446,6 +446,7 @@ struct l2cap_chan {
 	__le16		sport;
 
 	__u8		sec_level;
+	__u8		current_sl;
 
 	__u8		ident;
 
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 7e3386f..8f59fa6 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -379,7 +379,10 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
 		}
 
 		memset(&sec, 0, sizeof(sec));
-		sec.level = chan->sec_level;
+		if (bt_sk(sk)->suspended)
+			sec.level = chan->current_sl;
+		else
+			sec.level = chan->sec_level;
 
 		if (sk->sk_state == BT_CONNECTED)
 			sec.key_size = chan->conn->hcon->enc_key_size;
@@ -577,6 +580,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 			break;
 		}
 
+		chan->current_sl = chan->sec_level;
 		chan->sec_level = sec.level;
 
 		if (!chan->conn)
-- 
1.7.10


  reply	other threads:[~2012-05-04  1:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-04  1:59 [PATCH 1/2] Bluetooth: notify userspace of security level change Gustavo Padovan
2012-05-04  1:59 ` Gustavo Padovan [this message]
2012-05-06 16:13   ` [PATCH 2/2] Bluetooth: report the right security level in getsockopt Marcel Holtmann
2012-05-06 16:07 ` [PATCH 1/2] Bluetooth: notify userspace of security level change Marcel Holtmann
2012-05-07  5:13   ` Gustavo Padovan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336096794-16993-2-git-send-email-gustavo@padovan.org \
    --to=gustavo@padovan.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).