1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef __AF_UNIX_H 3 #define __AF_UNIX_H 4 5 #include <linux/uidgid.h> 6 7 #define UNIX_HASH_MOD (256 - 1) 8 #define UNIX_HASH_SIZE (256 * 2) 9 #define UNIX_HASH_BITS 8 10 11 struct sock *unix_peer_get(struct sock *sk); 12 13 struct unix_skb_parms { 14 struct pid *pid; /* skb credentials */ 15 kuid_t uid; 16 kgid_t gid; 17 struct scm_fp_list *fp; /* Passed files */ 18 #ifdef CONFIG_SECURITY_NETWORK 19 u32 secid; /* Security ID */ 20 #endif 21 u32 consumed; 22 } __randomize_layout; 23 24 #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) 25 26 /* GC for SCM_RIGHTS */ 27 void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver); 28 void unix_del_edges(struct scm_fp_list *fpl); 29 void unix_update_edges(struct unix_sock *receiver); 30 int unix_prepare_fpl(struct scm_fp_list *fpl); 31 void unix_destroy_fpl(struct scm_fp_list *fpl); 32 void unix_peek_fpl(struct scm_fp_list *fpl); 33 void unix_schedule_gc(struct user_struct *user); 34 35 /* SOCK_DIAG */ 36 long unix_inq_len(struct sock *sk); 37 long unix_outq_len(struct sock *sk); 38 39 /* sysctl */ 40 #ifdef CONFIG_SYSCTL 41 int unix_sysctl_register(struct net *net); 42 void unix_sysctl_unregister(struct net *net); 43 #else 44 static inline int unix_sysctl_register(struct net *net) 45 { 46 return 0; 47 } 48 49 static inline void unix_sysctl_unregister(struct net *net) 50 { 51 } 52 #endif 53 54 /* BPF SOCKMAP */ 55 int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); 56 int __unix_stream_recvmsg(struct sock *sk, struct msghdr *msg, size_t size, int flags); 57 58 #ifdef CONFIG_BPF_SYSCALL 59 extern struct proto unix_dgram_proto; 60 extern struct proto unix_stream_proto; 61 62 int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 63 int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore); 64 void __init unix_bpf_build_proto(void); 65 #else 66 static inline void __init unix_bpf_build_proto(void) 67 { 68 } 69 #endif 70 71 #endif 72