Skip to content

Commit 5dfd283

Browse files
q2vengregkh
authored andcommitted
af_unix: Replace garbage collection algorithm.
commit 4090fa373f0e763c43610853d2774b5979915959 upstream. If we find a dead SCC during iteration, we call unix_collect_skb() to splice all skb in the SCC to the global sk_buff_head, hitlist. After iterating all SCC, we unlock unix_gc_lock and purge the queue. Signed-off-by: Kuniyuki Iwashima <[email protected]> Acked-by: Paolo Abeni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Lee Jones <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9734d33 commit 5dfd283

File tree

3 files changed

+64
-274
lines changed

3 files changed

+64
-274
lines changed

include/net/af_unix.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ static inline struct unix_sock *unix_get_socket(struct file *filp)
1919

2020
extern spinlock_t unix_gc_lock;
2121
extern unsigned int unix_tot_inflight;
22-
23-
void unix_inflight(struct user_struct *user, struct file *fp);
24-
void unix_notinflight(struct user_struct *user, struct file *fp);
2522
void unix_add_edges(struct scm_fp_list *fpl, struct unix_sock *receiver);
2623
void unix_del_edges(struct scm_fp_list *fpl);
2724
void unix_update_edges(struct unix_sock *receiver);
@@ -85,12 +82,7 @@ struct unix_sock {
8582
struct sock *peer;
8683
struct sock *listener;
8784
struct unix_vertex *vertex;
88-
struct list_head link;
89-
unsigned long inflight;
9085
spinlock_t lock;
91-
unsigned long gc_flags;
92-
#define UNIX_GC_CANDIDATE 0
93-
#define UNIX_GC_MAYBE_CYCLE 1
9486
struct socket_wq peer_wq;
9587
wait_queue_entry_t peer_wake;
9688
struct scm_stat scm_stat;

net/unix/af_unix.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -955,12 +955,10 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern,
955955
sk->sk_destruct = unix_sock_destructor;
956956
u = unix_sk(sk);
957957
u->listener = NULL;
958-
u->inflight = 0;
959958
u->vertex = NULL;
960959
u->path.dentry = NULL;
961960
u->path.mnt = NULL;
962961
spin_lock_init(&u->lock);
963-
INIT_LIST_HEAD(&u->link);
964962
mutex_init(&u->iolock); /* single task reading lock */
965963
mutex_init(&u->bindlock); /* single task binding lock */
966964
init_waitqueue_head(&u->peer_wait);
@@ -1744,8 +1742,6 @@ static inline bool too_many_unix_fds(struct task_struct *p)
17441742

17451743
static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
17461744
{
1747-
int i;
1748-
17491745
if (too_many_unix_fds(current))
17501746
return -ETOOMANYREFS;
17511747

@@ -1757,9 +1753,6 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
17571753
if (!UNIXCB(skb).fp)
17581754
return -ENOMEM;
17591755

1760-
for (i = scm->fp->count - 1; i >= 0; i--)
1761-
unix_inflight(scm->fp->user, scm->fp->fp[i]);
1762-
17631756
if (unix_prepare_fpl(UNIXCB(skb).fp))
17641757
return -ENOMEM;
17651758

@@ -1768,15 +1761,10 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)
17681761

17691762
static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb)
17701763
{
1771-
int i;
1772-
17731764
scm->fp = UNIXCB(skb).fp;
17741765
UNIXCB(skb).fp = NULL;
17751766

17761767
unix_destroy_fpl(scm->fp);
1777-
1778-
for (i = scm->fp->count - 1; i >= 0; i--)
1779-
unix_notinflight(scm->fp->user, scm->fp->fp[i]);
17801768
}
17811769

17821770
static void unix_peek_fds(struct scm_cookie *scm, struct sk_buff *skb)

0 commit comments

Comments
 (0)