mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-19 13:11:14 +00:00
net: add __rcu annotations to sk_wq and wq
Add proper RCU annotations/verbs to sk_wq and wq members Fix __sctp_write_space() sk_sleep() abuse (and sock->wq access) Fix sunrpc sk_sleep() abuse too Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
04cfa852ff
commit
eaefd1105b
6 changed files with 46 additions and 30 deletions
23
net/socket.c
23
net/socket.c
|
@ -240,17 +240,19 @@ static struct kmem_cache *sock_inode_cachep __read_mostly;
|
|||
static struct inode *sock_alloc_inode(struct super_block *sb)
|
||||
{
|
||||
struct socket_alloc *ei;
|
||||
struct socket_wq *wq;
|
||||
|
||||
ei = kmem_cache_alloc(sock_inode_cachep, GFP_KERNEL);
|
||||
if (!ei)
|
||||
return NULL;
|
||||
ei->socket.wq = kmalloc(sizeof(struct socket_wq), GFP_KERNEL);
|
||||
if (!ei->socket.wq) {
|
||||
wq = kmalloc(sizeof(*wq), GFP_KERNEL);
|
||||
if (!wq) {
|
||||
kmem_cache_free(sock_inode_cachep, ei);
|
||||
return NULL;
|
||||
}
|
||||
init_waitqueue_head(&ei->socket.wq->wait);
|
||||
ei->socket.wq->fasync_list = NULL;
|
||||
init_waitqueue_head(&wq->wait);
|
||||
wq->fasync_list = NULL;
|
||||
RCU_INIT_POINTER(ei->socket.wq, wq);
|
||||
|
||||
ei->socket.state = SS_UNCONNECTED;
|
||||
ei->socket.flags = 0;
|
||||
|
@ -273,9 +275,11 @@ static void wq_free_rcu(struct rcu_head *head)
|
|||
static void sock_destroy_inode(struct inode *inode)
|
||||
{
|
||||
struct socket_alloc *ei;
|
||||
struct socket_wq *wq;
|
||||
|
||||
ei = container_of(inode, struct socket_alloc, vfs_inode);
|
||||
call_rcu(&ei->socket.wq->rcu, wq_free_rcu);
|
||||
wq = rcu_dereference_protected(ei->socket.wq, 1);
|
||||
call_rcu(&wq->rcu, wq_free_rcu);
|
||||
kmem_cache_free(sock_inode_cachep, ei);
|
||||
}
|
||||
|
||||
|
@ -524,7 +528,7 @@ void sock_release(struct socket *sock)
|
|||
module_put(owner);
|
||||
}
|
||||
|
||||
if (sock->wq->fasync_list)
|
||||
if (rcu_dereference_protected(sock->wq, 1)->fasync_list)
|
||||
printk(KERN_ERR "sock_release: fasync list not empty!\n");
|
||||
|
||||
percpu_sub(sockets_in_use, 1);
|
||||
|
@ -1108,15 +1112,16 @@ static int sock_fasync(int fd, struct file *filp, int on)
|
|||
{
|
||||
struct socket *sock = filp->private_data;
|
||||
struct sock *sk = sock->sk;
|
||||
struct socket_wq *wq;
|
||||
|
||||
if (sk == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
lock_sock(sk);
|
||||
wq = rcu_dereference_protected(sock->wq, sock_owned_by_user(sk));
|
||||
fasync_helper(fd, filp, on, &wq->fasync_list);
|
||||
|
||||
fasync_helper(fd, filp, on, &sock->wq->fasync_list);
|
||||
|
||||
if (!sock->wq->fasync_list)
|
||||
if (!wq->fasync_list)
|
||||
sock_reset_flag(sk, SOCK_FASYNC);
|
||||
else
|
||||
sock_set_flag(sk, SOCK_FASYNC);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue