Merge "netd.c: handle overflowuid in bpf_owner_match()" into main
This commit is contained in:
commit
901db13423
1 changed files with 11 additions and 1 deletions
|
|
@ -446,8 +446,18 @@ static __always_inline inline int bpf_traffic_account(struct __sk_buff* skb,
|
|||
const struct egress_bool egress,
|
||||
const bool enable_tracing,
|
||||
const struct kver_uint kver) {
|
||||
// sock_uid will be 'overflowuid' if !sk_fullsock(sk_to_full_sk(skb->sk))
|
||||
uint32_t sock_uid = bpf_get_socket_uid(skb);
|
||||
uint64_t cookie = bpf_get_socket_cookie(skb);
|
||||
|
||||
// kernel's DEFAULT_OVERFLOWUID is 65534, this is the overflow 'nobody' uid,
|
||||
// usually this being returned means that skb->sk is NULL during RX
|
||||
// (early decap socket lookup failure), which commonly happens for incoming
|
||||
// packets to an unconnected udp socket.
|
||||
// But it can also happen for egress from a timewait socket.
|
||||
// Let's treat such cases as 'root' which is_system_uid()
|
||||
if (sock_uid == 65534) sock_uid = 0;
|
||||
|
||||
uint64_t cookie = bpf_get_socket_cookie(skb); // 0 iff !skb->sk
|
||||
UidTagValue* utag = bpf_cookie_tag_map_lookup_elem(&cookie);
|
||||
uint32_t uid, tag;
|
||||
if (utag) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue