Lines Matching refs:sock

136 	struct socket *sock = f->private_data;  in sock_show_fdinfo()  local
138 if (sock->ops->show_fdinfo) in sock_show_fdinfo()
139 sock->ops->show_fdinfo(m, sock); in sock_show_fdinfo()
455 struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname) in sock_alloc_file() argument
460 dname = sock->sk ? sock->sk->sk_prot_creator->name : ""; in sock_alloc_file()
462 file = alloc_file_pseudo(SOCK_INODE(sock), sock_mnt, dname, in sock_alloc_file()
466 sock_release(sock); in sock_alloc_file()
470 sock->file = file; in sock_alloc_file()
471 file->private_data = sock; in sock_alloc_file()
472 stream_open(SOCK_INODE(sock), file); in sock_alloc_file()
477 static int sock_map_fd(struct socket *sock, int flags) in sock_map_fd() argument
482 sock_release(sock); in sock_map_fd()
486 newfile = sock_alloc_file(sock, flags, NULL); in sock_map_fd()
528 struct socket *sock; in sockfd_lookup() local
536 sock = sock_from_file(file); in sockfd_lookup()
537 if (!sock) { in sockfd_lookup()
541 return sock; in sockfd_lookup()
548 struct socket *sock; in sockfd_lookup_light() local
552 sock = sock_from_file(f.file); in sockfd_lookup_light()
553 if (likely(sock)) { in sockfd_lookup_light()
555 return sock; in sockfd_lookup_light()
597 struct socket *sock = SOCKET_I(d_inode(dentry)); in sockfs_setattr() local
599 if (sock->sk) in sockfs_setattr()
600 sock->sk->sk_uid = iattr->ia_uid; in sockfs_setattr()
624 struct socket *sock; in sock_alloc() local
630 sock = SOCKET_I(inode); in sock_alloc()
638 return sock; in sock_alloc()
642 static void __sock_release(struct socket *sock, struct inode *inode) in __sock_release() argument
644 if (sock->ops) { in __sock_release()
645 struct module *owner = sock->ops->owner; in __sock_release()
649 sock->ops->release(sock); in __sock_release()
650 sock->sk = NULL; in __sock_release()
653 sock->ops = NULL; in __sock_release()
657 if (sock->wq.fasync_list) in __sock_release()
660 if (!sock->file) { in __sock_release()
661 iput(SOCK_INODE(sock)); in __sock_release()
664 sock->file = NULL; in __sock_release()
675 void sock_release(struct socket *sock) in sock_release() argument
677 __sock_release(sock, NULL); in sock_release()
702 static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) in sock_sendmsg_nosec() argument
704 int ret = INDIRECT_CALL_INET(sock->ops->sendmsg, inet6_sendmsg, in sock_sendmsg_nosec()
705 inet_sendmsg, sock, msg, in sock_sendmsg_nosec()
719 int sock_sendmsg(struct socket *sock, struct msghdr *msg) in sock_sendmsg() argument
721 int err = security_socket_sendmsg(sock, msg, in sock_sendmsg()
724 return err ?: sock_sendmsg_nosec(sock, msg); in sock_sendmsg()
740 int kernel_sendmsg(struct socket *sock, struct msghdr *msg, in kernel_sendmsg() argument
744 return sock_sendmsg(sock, msg); in kernel_sendmsg()
761 int kernel_sendmsg_locked(struct sock *sk, struct msghdr *msg, in kernel_sendmsg_locked()
764 struct socket *sock = sk->sk_socket; in kernel_sendmsg_locked() local
766 if (!sock->ops->sendmsg_locked) in kernel_sendmsg_locked()
771 return sock->ops->sendmsg_locked(sk, msg, msg_data_left(msg)); in kernel_sendmsg_locked()
822 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, in __sock_recv_timestamp()
905 void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, in __sock_recv_wifi_status()
921 static inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, in sock_recv_drops()
929 void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, in __sock_recv_ts_and_drops()
941 static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, in sock_recvmsg_nosec() argument
944 return INDIRECT_CALL_INET(sock->ops->recvmsg, inet6_recvmsg, in sock_recvmsg_nosec()
945 inet_recvmsg, sock, msg, msg_data_left(msg), in sock_recvmsg_nosec()
958 int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags) in sock_recvmsg() argument
960 int err = security_socket_recvmsg(sock, msg, msg_data_left(msg), flags); in sock_recvmsg()
962 return err ?: sock_recvmsg_nosec(sock, msg, flags); in sock_recvmsg()
982 int kernel_recvmsg(struct socket *sock, struct msghdr *msg, in kernel_recvmsg() argument
987 return sock_recvmsg(sock, msg, flags); in kernel_recvmsg()
994 struct socket *sock; in sock_sendpage() local
997 sock = file->private_data; in sock_sendpage()
1003 return kernel_sendpage(sock, page, offset, size, flags); in sock_sendpage()
1010 struct socket *sock = file->private_data; in sock_splice_read() local
1012 if (unlikely(!sock->ops->splice_read)) in sock_splice_read()
1015 return sock->ops->splice_read(sock, ppos, pipe, len, flags); in sock_splice_read()
1021 struct socket *sock = file->private_data; in sock_read_iter() local
1035 res = sock_recvmsg(sock, &msg, msg.msg_flags); in sock_read_iter()
1043 struct socket *sock = file->private_data; in sock_write_iter() local
1054 if (sock->type == SOCK_SEQPACKET) in sock_write_iter()
1057 res = sock_sendmsg(sock, &msg); in sock_write_iter()
1109 static long sock_do_ioctl(struct net *net, struct socket *sock, in sock_do_ioctl() argument
1118 err = sock->ops->ioctl(sock, cmd, arg); in sock_do_ioctl()
1147 struct socket *sock; in sock_ioctl() local
1148 struct sock *sk; in sock_ioctl()
1153 sock = file->private_data; in sock_ioctl()
1154 sk = sock->sk; in sock_ioctl()
1178 err = f_setown(sock->file, pid, 1); in sock_ioctl()
1182 err = put_user(f_getown(sock->file), in sock_ioctl()
1211 if (!sock->ops->gettstamp) { in sock_ioctl()
1215 err = sock->ops->gettstamp(sock, argp, in sock_ioctl()
1221 if (!sock->ops->gettstamp) { in sock_ioctl()
1225 err = sock->ops->gettstamp(sock, argp, in sock_ioctl()
1235 err = sock_do_ioctl(net, sock, cmd, arg); in sock_ioctl()
1257 struct socket *sock = NULL; in sock_create_lite() local
1263 sock = sock_alloc(); in sock_create_lite()
1264 if (!sock) { in sock_create_lite()
1269 sock->type = type; in sock_create_lite()
1270 err = security_socket_post_create(sock, family, type, protocol, 1); in sock_create_lite()
1275 *res = sock; in sock_create_lite()
1278 sock_release(sock); in sock_create_lite()
1279 sock = NULL; in sock_create_lite()
1287 struct socket *sock = file->private_data; in sock_poll() local
1290 if (!sock->ops->poll) in sock_poll()
1293 if (sk_can_busy_loop(sock->sk)) { in sock_poll()
1296 sk_busy_loop(sock->sk, 1); in sock_poll()
1302 return sock->ops->poll(file, sock, wait) | flag; in sock_poll()
1307 struct socket *sock = file->private_data; in sock_mmap() local
1309 return sock->ops->mmap(file, sock, vma); in sock_mmap()
1331 struct socket *sock = filp->private_data; in sock_fasync() local
1332 struct sock *sk = sock->sk; in sock_fasync()
1333 struct socket_wq *wq = &sock->wq; in sock_fasync()
1397 struct socket *sock; in __sock_create() local
1428 sock = sock_alloc(); in __sock_create()
1429 if (!sock) { in __sock_create()
1435 sock->type = type; in __sock_create()
1464 err = pf->create(net, sock, protocol, kern); in __sock_create()
1472 if (!try_module_get(sock->ops->owner)) in __sock_create()
1480 err = security_socket_post_create(sock, family, type, protocol, kern); in __sock_create()
1483 *res = sock; in __sock_create()
1490 sock->ops = NULL; in __sock_create()
1493 sock_release(sock); in __sock_create()
1540 struct socket *sock; in __sys_socket() local
1557 retval = sock_create(family, type, protocol, &sock); in __sys_socket()
1561 return sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK)); in __sys_socket()
1681 struct socket *sock; in __sys_bind() local
1685 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_bind()
1686 if (sock) { in __sys_bind()
1689 err = security_socket_bind(sock, in __sys_bind()
1693 err = sock->ops->bind(sock, in __sys_bind()
1697 fput_light(sock->file, fput_needed); in __sys_bind()
1715 struct socket *sock; in __sys_listen() local
1719 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_listen()
1720 if (sock) { in __sys_listen()
1721 somaxconn = sock_net(sock->sk)->core.sysctl_somaxconn; in __sys_listen()
1725 err = security_socket_listen(sock, backlog); in __sys_listen()
1727 err = sock->ops->listen(sock, backlog); in __sys_listen()
1729 fput_light(sock->file, fput_needed); in __sys_listen()
1743 struct socket *sock, *newsock; in do_accept() local
1748 sock = sock_from_file(file); in do_accept()
1749 if (!sock) in do_accept()
1756 newsock->type = sock->type; in do_accept()
1757 newsock->ops = sock->ops; in do_accept()
1765 newfile = sock_alloc_file(newsock, flags, sock->sk->sk_prot_creator->name); in do_accept()
1769 err = security_socket_accept(sock, newsock); in do_accept()
1773 err = sock->ops->accept(sock, newsock, sock->file->f_flags | file_flags, in do_accept()
1882 struct socket *sock; in __sys_connect_file() local
1885 sock = sock_from_file(file); in __sys_connect_file()
1886 if (!sock) { in __sys_connect_file()
1892 security_socket_connect(sock, (struct sockaddr *)address, addrlen); in __sys_connect_file()
1896 err = sock->ops->connect(sock, (struct sockaddr *)address, addrlen, in __sys_connect_file()
1897 sock->file->f_flags | file_flags); in __sys_connect_file()
1934 struct socket *sock; in __sys_getsockname() local
1938 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_getsockname()
1939 if (!sock) in __sys_getsockname()
1942 err = security_socket_getsockname(sock); in __sys_getsockname()
1946 err = sock->ops->getname(sock, (struct sockaddr *)&address, 0); in __sys_getsockname()
1953 fput_light(sock->file, fput_needed); in __sys_getsockname()
1972 struct socket *sock; in __sys_getpeername() local
1976 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_getpeername()
1977 if (sock != NULL) { in __sys_getpeername()
1978 err = security_socket_getpeername(sock); in __sys_getpeername()
1980 fput_light(sock->file, fput_needed); in __sys_getpeername()
1984 err = sock->ops->getname(sock, (struct sockaddr *)&address, 1); in __sys_getpeername()
1989 fput_light(sock->file, fput_needed); in __sys_getpeername()
2008 struct socket *sock; in __sys_sendto() local
2018 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_sendto()
2019 if (!sock) in __sys_sendto()
2033 if (sock->file->f_flags & O_NONBLOCK) in __sys_sendto()
2036 err = sock_sendmsg(sock, &msg); in __sys_sendto()
2039 fput_light(sock->file, fput_needed); in __sys_sendto()
2069 struct socket *sock; in __sys_recvfrom() local
2079 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_recvfrom()
2080 if (!sock) in __sys_recvfrom()
2091 if (sock->file->f_flags & O_NONBLOCK) in __sys_recvfrom()
2093 err = sock_recvmsg(sock, &msg, flags); in __sys_recvfrom()
2102 fput_light(sock->file, fput_needed); in __sys_recvfrom()
2124 static bool sock_use_custom_sol_socket(const struct socket *sock) in sock_use_custom_sol_socket() argument
2126 const struct sock *sk = sock->sk; in sock_use_custom_sol_socket()
2145 struct socket *sock; in __sys_setsockopt() local
2150 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_setsockopt()
2151 if (!sock) in __sys_setsockopt()
2154 err = security_socket_setsockopt(sock, level, optname); in __sys_setsockopt()
2159 err = BPF_CGROUP_RUN_PROG_SETSOCKOPT(sock->sk, &level, &optname, in __sys_setsockopt()
2171 if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) in __sys_setsockopt()
2172 err = sock_setsockopt(sock, level, optname, optval, optlen); in __sys_setsockopt()
2173 else if (unlikely(!sock->ops->setsockopt)) in __sys_setsockopt()
2176 err = sock->ops->setsockopt(sock, level, optname, optval, in __sys_setsockopt()
2180 fput_light(sock->file, fput_needed); in __sys_setsockopt()
2201 struct socket *sock; in __sys_getsockopt() local
2204 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_getsockopt()
2205 if (!sock) in __sys_getsockopt()
2208 err = security_socket_getsockopt(sock, level, optname); in __sys_getsockopt()
2216 err = sock_getsockopt(sock, level, optname, optval, optlen); in __sys_getsockopt()
2217 else if (unlikely(!sock->ops->getsockopt)) in __sys_getsockopt()
2220 err = sock->ops->getsockopt(sock, level, optname, optval, in __sys_getsockopt()
2224 err = BPF_CGROUP_RUN_PROG_GETSOCKOPT(sock->sk, level, optname, in __sys_getsockopt()
2228 fput_light(sock->file, fput_needed); in __sys_getsockopt()
2242 int __sys_shutdown_sock(struct socket *sock, int how) in __sys_shutdown_sock() argument
2246 err = security_socket_shutdown(sock, how); in __sys_shutdown_sock()
2248 err = sock->ops->shutdown(sock, how); in __sys_shutdown_sock()
2256 struct socket *sock; in __sys_shutdown() local
2258 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_shutdown()
2259 if (sock != NULL) { in __sys_shutdown()
2260 err = __sys_shutdown_sock(sock, how); in __sys_shutdown()
2261 fput_light(sock->file, fput_needed); in __sys_shutdown()
2353 static int ____sys_sendmsg(struct socket *sock, struct msghdr *msg_sys, in ____sys_sendmsg() argument
2372 cmsghdr_from_user_compat_to_kern(msg_sys, sock->sk, ctl, in ____sys_sendmsg()
2382 ctl_buf = sock_kmalloc(sock->sk, ctl_len, GFP_KERNEL); in ____sys_sendmsg()
2394 if (sock->file->f_flags & O_NONBLOCK) in ____sys_sendmsg()
2406 err = sock_sendmsg_nosec(sock, msg_sys); in ____sys_sendmsg()
2409 err = sock_sendmsg(sock, msg_sys); in ____sys_sendmsg()
2423 sock_kfree_s(sock->sk, ctl_buf, ctl_len); in ____sys_sendmsg()
2448 static int ___sys_sendmsg(struct socket *sock, struct user_msghdr __user *msg, in ___sys_sendmsg() argument
2463 err = ____sys_sendmsg(sock, msg_sys, flags, used_address, in ___sys_sendmsg()
2472 long __sys_sendmsg_sock(struct socket *sock, struct msghdr *msg, in __sys_sendmsg_sock() argument
2475 return ____sys_sendmsg(sock, msg, flags, NULL, 0); in __sys_sendmsg_sock()
2483 struct socket *sock; in __sys_sendmsg() local
2488 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_sendmsg()
2489 if (!sock) in __sys_sendmsg()
2492 err = ___sys_sendmsg(sock, msg, &msg_sys, flags, NULL, 0); in __sys_sendmsg()
2494 fput_light(sock->file, fput_needed); in __sys_sendmsg()
2512 struct socket *sock; in __sys_sendmmsg() local
2527 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_sendmmsg()
2528 if (!sock) in __sys_sendmmsg()
2542 err = ___sys_sendmsg(sock, (struct user_msghdr __user *)compat_entry, in __sys_sendmmsg()
2549 err = ___sys_sendmsg(sock, in __sys_sendmmsg()
2566 fput_light(sock->file, fput_needed); in __sys_sendmmsg()
2602 static int ____sys_recvmsg(struct socket *sock, struct msghdr *msg_sys, in ____sys_recvmsg() argument
2622 if (sock->file->f_flags & O_NONBLOCK) in ____sys_recvmsg()
2626 err = sock_recvmsg_nosec(sock, msg_sys, flags); in ____sys_recvmsg()
2628 err = sock_recvmsg(sock, msg_sys, flags); in ____sys_recvmsg()
2658 static int ___sys_recvmsg(struct socket *sock, struct user_msghdr __user *msg, in ___sys_recvmsg() argument
2670 err = ____sys_recvmsg(sock, msg_sys, msg, uaddr, flags, nosec); in ___sys_recvmsg()
2679 long __sys_recvmsg_sock(struct socket *sock, struct msghdr *msg, in __sys_recvmsg_sock() argument
2683 return ____sys_recvmsg(sock, msg, umsg, uaddr, flags, 0); in __sys_recvmsg_sock()
2691 struct socket *sock; in __sys_recvmsg() local
2696 sock = sockfd_lookup_light(fd, &err, &fput_needed); in __sys_recvmsg()
2697 if (!sock) in __sys_recvmsg()
2700 err = ___sys_recvmsg(sock, msg, &msg_sys, flags, 0); in __sys_recvmsg()
2702 fput_light(sock->file, fput_needed); in __sys_recvmsg()
2722 struct socket *sock; in do_recvmmsg() local
2736 sock = sockfd_lookup_light(fd, &err, &fput_needed); in do_recvmmsg()
2737 if (!sock) in do_recvmmsg()
2741 err = sock_error(sock->sk); in do_recvmmsg()
2756 err = ___sys_recvmsg(sock, (struct user_msghdr __user *)compat_entry, in do_recvmmsg()
2764 err = ___sys_recvmsg(sock, in do_recvmmsg()
2820 sock->sk->sk_err = -err; in do_recvmmsg()
2823 fput_light(sock->file, fput_needed); in do_recvmmsg()
3251 static int compat_sock_ioctl_trans(struct file *file, struct socket *sock, in compat_sock_ioctl_trans() argument
3255 struct sock *sk = sock->sk; in compat_sock_ioctl_trans()
3269 if (!sock->ops->gettstamp) in compat_sock_ioctl_trans()
3271 return sock->ops->gettstamp(sock, argp, cmd == SIOCGSTAMP_OLD, in compat_sock_ioctl_trans()
3341 return sock_do_ioctl(net, sock, cmd, arg); in compat_sock_ioctl_trans()
3350 struct socket *sock = file->private_data; in compat_sock_ioctl() local
3352 struct sock *sk; in compat_sock_ioctl()
3355 sk = sock->sk; in compat_sock_ioctl()
3358 if (sock->ops->compat_ioctl) in compat_sock_ioctl()
3359 ret = sock->ops->compat_ioctl(sock, cmd, arg); in compat_sock_ioctl()
3366 ret = compat_sock_ioctl_trans(file, sock, cmd, arg); in compat_sock_ioctl()
3381 int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen) in kernel_bind() argument
3383 return sock->ops->bind(sock, addr, addrlen); in kernel_bind()
3395 int kernel_listen(struct socket *sock, int backlog) in kernel_listen() argument
3397 return sock->ops->listen(sock, backlog); in kernel_listen()
3412 int kernel_accept(struct socket *sock, struct socket **newsock, int flags) in kernel_accept() argument
3414 struct sock *sk = sock->sk; in kernel_accept()
3422 err = sock->ops->accept(sock, *newsock, flags, true); in kernel_accept()
3429 (*newsock)->ops = sock->ops; in kernel_accept()
3450 int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen, in kernel_connect() argument
3453 return sock->ops->connect(sock, addr, addrlen, flags); in kernel_connect()
3466 int kernel_getsockname(struct socket *sock, struct sockaddr *addr) in kernel_getsockname() argument
3468 return sock->ops->getname(sock, addr, 0); in kernel_getsockname()
3481 int kernel_getpeername(struct socket *sock, struct sockaddr *addr) in kernel_getpeername() argument
3483 return sock->ops->getname(sock, addr, 1); in kernel_getpeername()
3498 int kernel_sendpage(struct socket *sock, struct page *page, int offset, in kernel_sendpage() argument
3501 if (sock->ops->sendpage) { in kernel_sendpage()
3504 return sock->ops->sendpage(sock, page, offset, size, flags); in kernel_sendpage()
3506 return sock_no_sendpage(sock, page, offset, size, flags); in kernel_sendpage()
3522 int kernel_sendpage_locked(struct sock *sk, struct page *page, int offset, in kernel_sendpage_locked()
3525 struct socket *sock = sk->sk_socket; in kernel_sendpage_locked() local
3527 if (sock->ops->sendpage_locked) in kernel_sendpage_locked()
3528 return sock->ops->sendpage_locked(sk, page, offset, size, in kernel_sendpage_locked()
3543 int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how) in kernel_sock_shutdown() argument
3545 return sock->ops->shutdown(sock, how); in kernel_sock_shutdown()
3559 u32 kernel_sock_ip_overhead(struct sock *sk) in kernel_sock_ip_overhead()