]> git.hungrycats.org Git - linux/commitdiff
Bluetooth: ISO: zero the sockaddr before returning it in getname
authorAli Ahmet Memis <ali@iusegentoo.com>
Thu, 6 Aug 2026 23:06:21 +0000 (23:06 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Aug 2026 12:32:54 +0000 (14:32 +0200)
commit 884cf2cc957da7ac178a0e6c6c69ddfec0481cc8 upstream.

iso_sock_getname() fills a struct sockaddr_iso in place and returns its
size without clearing it first, so bytes it does not write are copied to
user space from the kernel stack. The getsockname(2) and getpeername(2)
paths both run through do_getsockname(), which hands getname() an
uninitialized sockaddr_storage on the stack and copies back up to the
number of bytes getname() returns, so the driver has to initialize every
byte it accounts for.

Two ranges are left uninitialized:

  - struct sockaddr_iso is 10 bytes but only 9 are written (family,
    iso_bdaddr, iso_bdaddr_type), leaking the trailing pad byte on every
    call.

  - for a broadcast peer (BIS_LINK or PA_LINK) the returned length grows
    by sizeof(struct sockaddr_iso_bc), but only bc_sid, bc_num_bis and
    bc_bis are filled; bc_bdaddr and bc_bdaddr_type, the first 7 bytes of
    that structure, are never written.

An unprivileged process can open a BTPROTO_ISO socket and reach the pad
leak with getsockname(); the broadcast leak needs an established BIS/PA
connection. l2cap and rfcomm already memset their sockaddr in getname
for the same reason; do the same here.

Fixes: ccf74f2390d6 ("Bluetooth: Add BTPROTO_ISO socket type")
Fixes: 0a766a0affb5 ("Bluetooth: ISO: Fix getpeername not returning sockaddr_iso_bc fields")
Cc: stable@vger.kernel.org
Signed-off-by: Ali Ahmet Memis <ali@iusegentoo.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/bluetooth/iso.c

index 3c1693eb20e7c41187832db9cf0240c217ed3ee8..022978f4ffd6c09494bdb77f51b85879de691dcf 100644 (file)
@@ -1415,6 +1415,7 @@ static int iso_sock_getname(struct socket *sock, struct sockaddr *addr,
 
        lock_sock(sk);
 
+       memset(sa, 0, sizeof(struct sockaddr_iso));
        addr->sa_family = AF_BLUETOOTH;
 
        if (peer) {
@@ -1425,6 +1426,7 @@ static int iso_sock_getname(struct socket *sock, struct sockaddr *addr,
                sa->iso_bdaddr_type = iso_pi(sk)->dst_type;
 
                if (hcon && (hcon->type == BIS_LINK || hcon->type == PA_LINK)) {
+                       memset(sa->iso_bc, 0, sizeof(struct sockaddr_iso_bc));
                        sa->iso_bc->bc_sid = iso_pi(sk)->bc_sid;
                        sa->iso_bc->bc_num_bis = iso_pi(sk)->bc_num_bis;
                        memcpy(sa->iso_bc->bc_bis, iso_pi(sk)->bc_bis,