Lines Matching refs:sock
139 struct socket *sock = f->private_data; in sock_show_fdinfo() local
140 const struct proto_ops *ops = READ_ONCE(sock->ops); in sock_show_fdinfo()
143 ops->show_fdinfo(m, sock); in sock_show_fdinfo()
461 struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname) in sock_alloc_file() argument
466 dname = sock->sk ? sock->sk->sk_prot_creator->name : ""; in sock_alloc_file()
468 file = alloc_file_pseudo(SOCK_INODE(sock), sock_mnt, dname, in sock_alloc_file()
472 sock_release(sock); in sock_alloc_file()
477 sock->file = file; in sock_alloc_file()
478 file->private_data = sock; in sock_alloc_file()
479 stream_open(SOCK_INODE(sock), file); in sock_alloc_file()
484 static int sock_map_fd(struct socket *sock, int flags) in sock_map_fd() argument
489 sock_release(sock); in sock_map_fd()
493 newfile = sock_alloc_file(sock, flags, NULL); in sock_map_fd()
535 struct socket *sock; in sockfd_lookup() local
543 sock = sock_from_file(file); in sockfd_lookup()
544 if (!sock) { in sockfd_lookup()
548 return sock; in sockfd_lookup()
555 struct socket *sock; in sockfd_lookup_light() local
559 sock = sock_from_file(fd_file(f)); in sockfd_lookup_light()
560 if (likely(sock)) { in sockfd_lookup_light()
562 return sock; in sockfd_lookup_light()
604 struct socket *sock = SOCKET_I(d_inode(dentry)); in sockfs_setattr() local
606 if (sock->sk) in sockfs_setattr()
607 sock->sk->sk_uid = iattr->ia_uid; in sockfs_setattr()
631 struct socket *sock; in sock_alloc() local
637 sock = SOCKET_I(inode); in sock_alloc()
645 return sock; in sock_alloc()
649 static void __sock_release(struct socket *sock, struct inode *inode) in __sock_release() argument
651 const struct proto_ops *ops = READ_ONCE(sock->ops); in __sock_release()
658 ops->release(sock); in __sock_release()
659 sock->sk = NULL; in __sock_release()
662 sock->ops = NULL; in __sock_release()
666 if (sock->wq.fasync_list) in __sock_release()
669 if (!sock->file) { in __sock_release()
670 iput(SOCK_INODE(sock)); in __sock_release()
673 sock->file = NULL; in __sock_release()
684 void sock_release(struct socket *sock) in sock_release() argument
686 __sock_release(sock, NULL); in sock_release()
721 static noinline void call_trace_sock_send_length(struct sock *sk, int ret, in call_trace_sock_send_length()
727 static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) in sock_sendmsg_nosec() argument
729 int ret = INDIRECT_CALL_INET(READ_ONCE(sock->ops)->sendmsg, inet6_sendmsg, in sock_sendmsg_nosec()
730 inet_sendmsg, sock, msg, in sock_sendmsg_nosec()
735 call_trace_sock_send_length(sock->sk, ret, 0); in sock_sendmsg_nosec()
739 static int __sock_sendmsg(struct socket *sock, struct msghdr *msg) in __sock_sendmsg() argument
741 int err = security_socket_sendmsg(sock, msg, in __sock_sendmsg()
744 return err ?: sock_sendmsg_nosec(sock, msg); in __sock_sendmsg()
755 int sock_sendmsg(struct socket *sock, struct msghdr *msg) in sock_sendmsg() argument
767 ret = __sock_sendmsg(sock, msg); in sock_sendmsg()
787 int kernel_sendmsg(struct socket *sock, struct msghdr *msg, in kernel_sendmsg() argument
791 return sock_sendmsg(sock, msg); in kernel_sendmsg()
808 int kernel_sendmsg_locked(struct sock *sk, struct msghdr *msg, in kernel_sendmsg_locked()
811 struct socket *sock = sk->sk_socket; in kernel_sendmsg_locked() local
812 const struct proto_ops *ops = READ_ONCE(sock->ops); in kernel_sendmsg_locked()
846 static ktime_t get_timestamp(struct sock *sk, struct sk_buff *skb, int *if_index) in get_timestamp()
894 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, in __sock_recv_timestamp()
993 void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, in __sock_recv_wifi_status()
1010 static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, in sock_recv_drops()
1018 static void sock_recv_mark(struct msghdr *msg, struct sock *sk, in sock_recv_mark()
1029 void __sock_recv_cmsgs(struct msghdr *msg, struct sock *sk, in __sock_recv_cmsgs()
1043 static noinline void call_trace_sock_recv_length(struct sock *sk, int ret, int flags) in call_trace_sock_recv_length()
1048 static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, in sock_recvmsg_nosec() argument
1051 int ret = INDIRECT_CALL_INET(READ_ONCE(sock->ops)->recvmsg, in sock_recvmsg_nosec()
1053 inet_recvmsg, sock, msg, in sock_recvmsg_nosec()
1056 call_trace_sock_recv_length(sock->sk, ret, flags); in sock_recvmsg_nosec()
1069 int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags) in sock_recvmsg() argument
1071 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags); in sock_recvmsg()
1073 return err ?: sock_recvmsg_nosec(sock, msg, flags); in sock_recvmsg()
1093 int kernel_recvmsg(struct socket *sock, struct msghdr *msg, in kernel_recvmsg() argument
1098 return sock_recvmsg(sock, msg, flags); in kernel_recvmsg()
1106 struct socket *sock = file->private_data; in sock_splice_read() local
1109 ops = READ_ONCE(sock->ops); in sock_splice_read()
1113 return ops->splice_read(sock, ppos, pipe, len, flags); in sock_splice_read()
1118 struct socket *sock = file->private_data; in sock_splice_eof() local
1121 ops = READ_ONCE(sock->ops); in sock_splice_eof()
1123 ops->splice_eof(sock); in sock_splice_eof()
1129 struct socket *sock = file->private_data; in sock_read_iter() local
1143 res = sock_recvmsg(sock, &msg, msg.msg_flags); in sock_read_iter()
1151 struct socket *sock = file->private_data; in sock_write_iter() local
1162 if (sock->type == SOCK_SEQPACKET) in sock_write_iter()
1165 res = __sock_sendmsg(sock, &msg); in sock_write_iter()
1217 static long sock_do_ioctl(struct net *net, struct socket *sock, in sock_do_ioctl() argument
1220 const struct proto_ops *ops = READ_ONCE(sock->ops); in sock_do_ioctl()
1227 err = ops->ioctl(sock, cmd, arg); in sock_do_ioctl()
1257 struct socket *sock; in sock_ioctl() local
1258 struct sock *sk; in sock_ioctl()
1263 sock = file->private_data; in sock_ioctl()
1264 ops = READ_ONCE(sock->ops); in sock_ioctl()
1265 sk = sock->sk; in sock_ioctl()
1289 err = f_setown(sock->file, pid, 1); in sock_ioctl()
1293 err = put_user(f_getown(sock->file), in sock_ioctl()
1326 err = ops->gettstamp(sock, argp, in sock_ioctl()
1336 err = ops->gettstamp(sock, argp, in sock_ioctl()
1346 err = sock_do_ioctl(net, sock, cmd, arg); in sock_ioctl()
1368 struct socket *sock = NULL; in sock_create_lite() local
1374 sock = sock_alloc(); in sock_create_lite()
1375 if (!sock) { in sock_create_lite()
1380 sock->type = type; in sock_create_lite()
1381 err = security_socket_post_create(sock, family, type, protocol, 1); in sock_create_lite()
1386 *res = sock; in sock_create_lite()
1389 sock_release(sock); in sock_create_lite()
1390 sock = NULL; in sock_create_lite()
1398 struct socket *sock = file->private_data; in sock_poll() local
1399 const struct proto_ops *ops = READ_ONCE(sock->ops); in sock_poll()
1405 if (sk_can_busy_loop(sock->sk)) { in sock_poll()
1408 sk_busy_loop(sock->sk, 1); in sock_poll()
1414 return ops->poll(file, sock, wait) | flag; in sock_poll()
1419 struct socket *sock = file->private_data; in sock_mmap() local
1421 return READ_ONCE(sock->ops)->mmap(file, sock, vma); in sock_mmap()
1443 struct socket *sock = filp->private_data; in sock_fasync() local
1444 struct sock *sk = sock->sk; in sock_fasync()
1445 struct socket_wq *wq = &sock->wq; in sock_fasync()
1509 struct socket *sock; in __sock_create() local
1540 sock = sock_alloc(); in __sock_create()
1541 if (!sock) { in __sock_create()
1547 sock->type = type; in __sock_create()
1576 err = pf->create(net, sock, protocol, kern); in __sock_create()
1581 sock->sk = NULL; in __sock_create()
1589 if (!try_module_get(sock->ops->owner)) in __sock_create()
1597 err = security_socket_post_create(sock, family, type, protocol, kern); in __sock_create()
1600 *res = sock; in __sock_create()
1607 sock->ops = NULL; in __sock_create()
1610 sock_release(sock); in __sock_create()
1656 struct socket *sock; in __sys_socket_create() local
1669 retval = sock_create(family, type, protocol, &sock); in __sys_socket_create()
1673 return sock; in __sys_socket_create()
1678 struct socket *sock; in __sys_socket_file() local
1681 sock = __sys_socket_create(family, type, protocol); in __sys_socket_file()
1682 if (IS_ERR(sock)) in __sys_socket_file()
1683 return ERR_CAST(sock); in __sys_socket_file()
1689 return sock_alloc_file(sock, flags, NULL); in __sys_socket_file()
1713 struct socket *sock; in __sys_socket() local
1716 sock = __sys_socket_create(family, type, in __sys_socket()
1718 if (IS_ERR(sock)) in __sys_socket()
1719 return PTR_ERR(sock); in __sys_socket()
1725 return sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK)); in __sys_socket()
1835 int __sys_bind_socket(struct socket *sock, struct sockaddr_storage *address, in __sys_bind_socket() argument
1840 err = security_socket_bind(sock, (struct sockaddr *)address, in __sys_bind_socket()
1843 err = READ_ONCE(sock->ops)->bind(sock, in __sys_bind_socket()
1859 struct socket *sock; in __sys_bind() local
1863 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_bind()
1864 if (sock) { in __sys_bind()
1867 err = __sys_bind_socket(sock, &address, addrlen); in __sys_bind()
1868 fput_light(sock->file, fput_needed); in __sys_bind()
1883 int __sys_listen_socket(struct socket *sock, int backlog) in __sys_listen_socket() argument
1887 somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn); in __sys_listen_socket()
1891 err = security_socket_listen(sock, backlog); in __sys_listen_socket()
1893 err = READ_ONCE(sock->ops)->listen(sock, backlog); in __sys_listen_socket()
1899 struct socket *sock; in __sys_listen() local
1902 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_listen()
1903 if (sock) { in __sys_listen()
1904 err = __sys_listen_socket(sock, backlog); in __sys_listen()
1905 fput_light(sock->file, fput_needed); in __sys_listen()
1919 struct socket *sock, *newsock; in do_accept() local
1925 sock = sock_from_file(file); in do_accept()
1926 if (!sock) in do_accept()
1932 ops = READ_ONCE(sock->ops); in do_accept()
1934 newsock->type = sock->type; in do_accept()
1943 newfile = sock_alloc_file(newsock, flags, sock->sk->sk_prot_creator->name); in do_accept()
1947 err = security_socket_accept(sock, newsock); in do_accept()
1951 arg->flags |= sock->file->f_flags; in do_accept()
1952 err = ops->accept(sock, newsock, arg); in do_accept()
2057 struct socket *sock; in __sys_connect_file() local
2060 sock = sock_from_file(file); in __sys_connect_file()
2061 if (!sock) { in __sys_connect_file()
2067 security_socket_connect(sock, (struct sockaddr *)address, addrlen); in __sys_connect_file()
2071 err = READ_ONCE(sock->ops)->connect(sock, (struct sockaddr *)address, in __sys_connect_file()
2072 addrlen, sock->file->f_flags | file_flags); in __sys_connect_file()
2109 struct socket *sock; in __sys_getsockname() local
2113 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_getsockname()
2114 if (!sock) in __sys_getsockname()
2117 err = security_socket_getsockname(sock); in __sys_getsockname()
2121 err = READ_ONCE(sock->ops)->getname(sock, (struct sockaddr *)&address, 0); in __sys_getsockname()
2128 fput_light(sock->file, fput_needed); in __sys_getsockname()
2147 struct socket *sock; in __sys_getpeername() local
2151 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_getpeername()
2152 if (sock != NULL) { in __sys_getpeername()
2153 const struct proto_ops *ops = READ_ONCE(sock->ops); in __sys_getpeername()
2155 err = security_socket_getpeername(sock); in __sys_getpeername()
2157 fput_light(sock->file, fput_needed); in __sys_getpeername()
2161 err = ops->getname(sock, (struct sockaddr *)&address, 1); in __sys_getpeername()
2166 fput_light(sock->file, fput_needed); in __sys_getpeername()
2185 struct socket *sock; in __sys_sendto() local
2194 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_sendto()
2195 if (!sock) in __sys_sendto()
2211 if (sock->file->f_flags & O_NONBLOCK) in __sys_sendto()
2214 err = __sock_sendmsg(sock, &msg); in __sys_sendto()
2217 fput_light(sock->file, fput_needed); in __sys_sendto()
2252 struct socket *sock; in __sys_recvfrom() local
2259 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_recvfrom()
2260 if (!sock) in __sys_recvfrom()
2263 if (sock->file->f_flags & O_NONBLOCK) in __sys_recvfrom()
2265 err = sock_recvmsg(sock, &msg, flags); in __sys_recvfrom()
2274 fput_light(sock->file, fput_needed); in __sys_recvfrom()
2296 static bool sock_use_custom_sol_socket(const struct socket *sock) in sock_use_custom_sol_socket() argument
2298 return test_bit(SOCK_CUSTOM_SOCKOPT, &sock->flags); in sock_use_custom_sol_socket()
2301 int do_sock_setsockopt(struct socket *sock, bool compat, int level, in do_sock_setsockopt() argument
2311 err = security_socket_setsockopt(sock, level, optname); in do_sock_setsockopt()
2316 err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname, in do_sock_setsockopt()
2328 ops = READ_ONCE(sock->ops); in do_sock_setsockopt()
2329 if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) in do_sock_setsockopt()
2330 err = sock_setsockopt(sock, level, optname, optval, optlen); in do_sock_setsockopt()
2334 err = ops->setsockopt(sock, level, optname, optval, in do_sock_setsockopt()
2351 struct socket *sock; in __sys_setsockopt() local
2353 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_setsockopt()
2354 if (!sock) in __sys_setsockopt()
2357 err = do_sock_setsockopt(sock, compat, level, optname, optval, optlen); in __sys_setsockopt()
2359 fput_light(sock->file, fput_needed); in __sys_setsockopt()
2372 int do_sock_getsockopt(struct socket *sock, bool compat, int level, in do_sock_getsockopt() argument
2379 err = security_socket_getsockopt(sock, level, optname); in do_sock_getsockopt()
2386 ops = READ_ONCE(sock->ops); in do_sock_getsockopt()
2388 err = sk_getsockopt(sock->sk, level, optname, optval, optlen); in do_sock_getsockopt()
2396 err = ops->getsockopt(sock, level, optname, optval.user, in do_sock_getsockopt()
2401 err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname, in do_sock_getsockopt()
2417 struct socket *sock; in __sys_getsockopt() local
2420 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_getsockopt()
2421 if (!sock) in __sys_getsockopt()
2425 err = do_sock_getsockopt(sock, compat, level, optname, in __sys_getsockopt()
2428 fput_light(sock->file, fput_needed); in __sys_getsockopt()
2442 int __sys_shutdown_sock(struct socket *sock, int how) in __sys_shutdown_sock() argument
2446 err = security_socket_shutdown(sock, how); in __sys_shutdown_sock()
2448 err = READ_ONCE(sock->ops)->shutdown(sock, how); in __sys_shutdown_sock()
2456 struct socket *sock; in __sys_shutdown() local
2458 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_shutdown()
2459 if (sock != NULL) { in __sys_shutdown()
2460 err = __sys_shutdown_sock(sock, how); in __sys_shutdown()
2461 fput_light(sock->file, fput_needed); in __sys_shutdown()
2550 static int ____sys_sendmsg(struct socket *sock, struct msghdr *msg_sys, in ____sys_sendmsg() argument
2569 cmsghdr_from_user_compat_to_kern(msg_sys, sock->sk, ctl, in ____sys_sendmsg()
2579 ctl_buf = sock_kmalloc(sock->sk, ctl_len, GFP_KERNEL); in ____sys_sendmsg()
2592 if (sock->file->f_flags & O_NONBLOCK) in ____sys_sendmsg()
2604 err = sock_sendmsg_nosec(sock, msg_sys); in ____sys_sendmsg()
2607 err = __sock_sendmsg(sock, msg_sys); in ____sys_sendmsg()
2621 sock_kfree_s(sock->sk, ctl_buf, ctl_len); in ____sys_sendmsg()
2646 static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg, in ___sys_sendmsg() argument
2661 err = ____sys_sendmsg(sock, msg_sys, flags, used_address, in ___sys_sendmsg()
2670 long __sys_sendmsg_sock(struct socket *sock, struct msghdr *msg, in __sys_sendmsg_sock() argument
2673 return ____sys_sendmsg(sock, msg, flags, NULL, 0); in __sys_sendmsg_sock()
2681 struct socket *sock; in __sys_sendmsg() local
2686 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_sendmsg()
2687 if (!sock) in __sys_sendmsg()
2690 err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL, 0); in __sys_sendmsg()
2692 fput_light(sock->file, fput_needed); in __sys_sendmsg()
2710 struct socket *sock; in __sys_sendmmsg() local
2725 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_sendmmsg()
2726 if (!sock) in __sys_sendmmsg()
2740 err = ___sys_sendmsg(sock, (struct user_msghdr __user *)compat_entry, in __sys_sendmmsg()
2747 err = ___sys_sendmsg(sock, in __sys_sendmmsg()
2764 fput_light(sock->file, fput_needed); in __sys_sendmmsg()
2800 static int ____sys_recvmsg(struct socket *sock, struct msghdr *msg_sys, in ____sys_recvmsg() argument
2820 if (sock->file->f_flags & O_NONBLOCK) in ____sys_recvmsg()
2824 err = sock_recvmsg_nosec(sock, msg_sys, flags); in ____sys_recvmsg()
2826 err = sock_recvmsg(sock, msg_sys, flags); in ____sys_recvmsg()
2856 static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg, in ___sys_recvmsg() argument
2868 err = ____sys_recvmsg(sock, msg_sys, msg, uaddr, flags, nosec); in ___sys_recvmsg()
2877 long __sys_recvmsg_sock(struct socket *sock, struct msghdr *msg, in __sys_recvmsg_sock() argument
2881 return ____sys_recvmsg(sock, msg, umsg, uaddr, flags, 0); in __sys_recvmsg_sock()
2889 struct socket *sock; in __sys_recvmsg() local
2894 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_recvmsg()
2895 if (!sock) in __sys_recvmsg()
2898 err = ___sys_recvmsg(sock, msg, &msg_sys, flags, 0); in __sys_recvmsg()
2900 fput_light(sock->file, fput_needed); in __sys_recvmsg()
2920 struct socket *sock; in do_recvmmsg() local
2934 sock = sockfd_lookup_light(fd, &err, &fput_needed); in do_recvmmsg()
2935 if (!sock) in do_recvmmsg()
2939 err = sock_error(sock->sk); in do_recvmmsg()
2954 err = ___sys_recvmsg(sock, (struct user_msghdr __user *)compat_entry, in do_recvmmsg()
2962 err = ___sys_recvmsg(sock, in do_recvmmsg()
3018 WRITE_ONCE(sock->sk->sk_err, -err); in do_recvmmsg()
3021 fput_light(sock->file, fput_needed); in do_recvmmsg()
3434 static int compat_sock_ioctl_trans(struct file *file, struct socket *sock, in compat_sock_ioctl_trans() argument
3438 struct sock *sk = sock->sk; in compat_sock_ioctl_trans()
3450 ops = READ_ONCE(sock->ops); in compat_sock_ioctl_trans()
3453 return ops->gettstamp(sock, argp, cmd == SIOCGSTAMP_OLD, in compat_sock_ioctl_trans()
3525 return sock_do_ioctl(net, sock, cmd, arg); in compat_sock_ioctl_trans()
3534 struct socket *sock = file->private_data; in compat_sock_ioctl() local
3535 const struct proto_ops *ops = READ_ONCE(sock->ops); in compat_sock_ioctl()
3537 struct sock *sk; in compat_sock_ioctl()
3540 sk = sock->sk; in compat_sock_ioctl()
3544 ret = ops->compat_ioctl(sock, cmd, arg); in compat_sock_ioctl()
3551 ret = compat_sock_ioctl_trans(file, sock, cmd, arg); in compat_sock_ioctl()
3566 int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen) in kernel_bind() argument
3572 return READ_ONCE(sock->ops)->bind(sock, (struct sockaddr *)&address, in kernel_bind()
3585 int kernel_listen(struct socket *sock, int backlog) in kernel_listen() argument
3587 return READ_ONCE(sock->ops)->listen(sock, backlog); in kernel_listen()
3602 int kernel_accept(struct socket *sock, struct socket **newsock, int flags) in kernel_accept() argument
3604 struct sock *sk = sock->sk; in kernel_accept()
3605 const struct proto_ops *ops = READ_ONCE(sock->ops); in kernel_accept()
3617 err = ops->accept(sock, *newsock, &arg); in kernel_accept()
3645 int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, in kernel_connect() argument
3652 return READ_ONCE(sock->ops)->connect(sock, (struct sockaddr *)&address, in kernel_connect()
3666 int kernel_getsockname(struct socket *sock, struct sockaddr *addr) in kernel_getsockname() argument
3668 return READ_ONCE(sock->ops)->getname(sock, addr, 0); in kernel_getsockname()
3681 int kernel_getpeername(struct socket *sock, struct sockaddr *addr) in kernel_getpeername() argument
3683 return READ_ONCE(sock->ops)->getname(sock, addr, 1); in kernel_getpeername()
3695 int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) in kernel_sock_shutdown() argument
3697 return READ_ONCE(sock->ops)->shutdown(sock, how); in kernel_sock_shutdown()
3711 u32 kernel_sock_ip_overhead(struct sock *sk) in kernel_sock_ip_overhead()