mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
net: fix lock_sock_bh/unlock_sock_bh
This new sock lock primitive was introduced to speedup some user context socket manipulation. But it is unsafe to protect two threads, one using regular lock_sock/release_sock, one using lock_sock_bh/unlock_sock_bh This patch changes lock_sock_bh to be careful against 'owned' state. If owned is found to be set, we must take the slow path. lock_sock_bh() now returns a boolean to say if the slow path was taken, and this boolean is used at unlock_sock_bh time to call the appropriate unlock function. After this change, BH are either disabled or enabled during the lock_sock_bh/unlock_sock_bh protected section. This might be misleading, so we rename these functions to lock_sock_fast()/unlock_sock_fast(). Reported-by: Anton Blanchard <anton@samba.org> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Tested-by: Anton Blanchard <anton@samba.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a56635a56f
commit
8a74ad60a5
5 changed files with 62 additions and 16 deletions
|
@ -328,6 +328,7 @@ int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
|
|||
int err;
|
||||
int is_udplite = IS_UDPLITE(sk);
|
||||
int is_udp4;
|
||||
bool slow;
|
||||
|
||||
if (addr_len)
|
||||
*addr_len=sizeof(struct sockaddr_in6);
|
||||
|
@ -424,7 +425,7 @@ out:
|
|||
return err;
|
||||
|
||||
csum_copy_err:
|
||||
lock_sock_bh(sk);
|
||||
slow = lock_sock_fast(sk);
|
||||
if (!skb_kill_datagram(sk, skb, flags)) {
|
||||
if (is_udp4)
|
||||
UDP_INC_STATS_USER(sock_net(sk),
|
||||
|
@ -433,7 +434,7 @@ csum_copy_err:
|
|||
UDP6_INC_STATS_USER(sock_net(sk),
|
||||
UDP_MIB_INERRORS, is_udplite);
|
||||
}
|
||||
unlock_sock_bh(sk);
|
||||
unlock_sock_fast(sk, slow);
|
||||
|
||||
if (flags & MSG_DONTWAIT)
|
||||
return -EAGAIN;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue