Thread (15 messages) 15 messages, 3 authors, 3d ago

[RFC PATCH 07/41] Bluetooth: keep classic sender ids in skb->cb

flat view
WARM3d

From: Jan Koester <hidden>
Date: 2026-10-18 18:01:59
Also in: keyrings, linux-arch, linux-cifs, linux-ext4, linux-fsdevel, linux-nfs, linux-security-module, lkml, netdev
Subsystem: bluetooth subsystem, the rest · Maintainers: Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds

struct bt_skb_cb holds the sender's struct scm_creds for HCI sockets,
which no longer fits into skb->cb now that kuid_t and kgid_t can hold
UUIDs and GUIDs. Like netlink, keep them as struct scm_creds_classic:
classic ids as before, the overflow id for UUID and GUID senders.

Assisted-by: Claude:claude-opus-5-5

Signed-off-by: Jan Koester <redacted>
---
 include/net/bluetooth/bluetooth.h | 2 +-
 net/bluetooth/hci_sock.c          | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index b624da5026..2c8fe50f4d 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -497,7 +497,7 @@ struct bt_skb_cb {
 		struct l2cap_ctrl l2cap;
 		struct hci_ctrl hci;
 		struct mgmt_ctrl mgmt;
-		struct scm_creds creds;
+		struct scm_creds_classic creds;
 	};
 };
 #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 81068b5857..9f422ae5fd 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -276,7 +276,7 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb)
 
 static void hci_sock_copy_creds(struct sock *sk, struct sk_buff *skb)
 {
-	struct scm_creds *creds;
+	struct scm_creds_classic *creds;
 
 	if (!sk || WARN_ON(!skb))
 		return;
@@ -300,8 +300,8 @@ static void hci_sock_copy_creds(struct sock *sk, struct sk_buff *skb)
 
 	creds->pid = pid_vnr(sk->sk_peer_pid);
 	if (sk->sk_peer_cred) {
-		creds->uid = sk->sk_peer_cred->uid;
-		creds->gid = sk->sk_peer_cred->gid;
+		creds->uid = __kuid_val(sk->sk_peer_cred->uid);
+		creds->gid = __kgid_val(sk->sk_peer_cred->gid);
 	}
 }
 
@@ -1615,7 +1615,7 @@ static int hci_sock_recvmsg(struct socket *sock, struct msghdr *msg,
 	}
 
 	memset(&scm, 0, sizeof(scm));
-	scm.creds = bt_cb(skb)->creds;
+	scm_creds_from_classic(&scm.creds, &bt_cb(skb)->creds);
 
 	skb_free_datagram(sk, skb);
 
-- 
2.56.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help