aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/sco.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-03-15 17:12:58 -0400
committerMarcel Holtmann <marcel@holtmann.org>2010-03-21 00:49:32 -0400
commit101545f6fef4a0a3ea8daf0b5b880df2c6a92a69 (patch)
tree5b4254a64db65f1958a36ec6955dbba1b71031a7 /net/bluetooth/sco.c
parentaf98441397227a5a4f212cd48710eea72a14dbdb (diff)
Bluetooth: Fix potential bad memory access with sysfs files
When creating a high number of Bluetooth sockets (L2CAP, SCO and RFCOMM) it is possible to scribble repeatedly on arbitrary pages of memory. Ensure that the content of these sysfs files is always less than one page. Even if this means truncating. The files in question are scheduled to be moved over to debugfs in the future anyway. Based on initial patches from Neil Brown and Linus Torvalds Reported-by: Neil Brown <neilb@suse.de> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/sco.c')
-rw-r--r--net/bluetooth/sco.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index f93b939539b..967a75175c6 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -960,13 +960,22 @@ static ssize_t sco_sysfs_show(struct class *dev,
960 struct sock *sk; 960 struct sock *sk;
961 struct hlist_node *node; 961 struct hlist_node *node;
962 char *str = buf; 962 char *str = buf;
963 int size = PAGE_SIZE;
963 964
964 read_lock_bh(&sco_sk_list.lock); 965 read_lock_bh(&sco_sk_list.lock);
965 966
966 sk_for_each(sk, node, &sco_sk_list.head) { 967 sk_for_each(sk, node, &sco_sk_list.head) {
967 str += sprintf(str, "%s %s %d\n", 968 int len;
969
970 len = snprintf(str, size, "%s %s %d\n",
968 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 971 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
969 sk->sk_state); 972 sk->sk_state);
973
974 size -= len;
975 if (size <= 0)
976 break;
977
978 str += len;
970 } 979 }
971 980
972 read_unlock_bh(&sco_sk_list.lock); 981 read_unlock_bh(&sco_sk_list.lock);