Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 92a0acce authored by David S. Miller's avatar David S. Miller
Browse files

net: Kill skb_truesize_check(), it only catches false-positives.



A long time ago we had bugs, primarily in TCP, where we would modify
skb->truesize (for TSO queue collapsing) in ways which would corrupt
the socket memory accounting.

skb_truesize_check() was added in order to try and catch this error
more systematically.

However this debugging check has morphed into a Frankenstein of sorts
and these days it does nothing other than catch false-positives.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 34edaa88
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -416,15 +416,6 @@ extern void skb_over_panic(struct sk_buff *skb, int len,
				     void *here);
				     void *here);
extern void	      skb_under_panic(struct sk_buff *skb, int len,
extern void	      skb_under_panic(struct sk_buff *skb, int len,
				      void *here);
				      void *here);
extern void	      skb_truesize_bug(struct sk_buff *skb);

static inline void skb_truesize_check(struct sk_buff *skb)
{
	int len = sizeof(struct sk_buff) + skb->len;

	if (unlikely((int)skb->truesize < len))
		skb_truesize_bug(skb);
}


extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
extern int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
			int getfrag(void *from, char *to, int offset,
			int getfrag(void *from, char *to, int offset,
+0 −1
Original line number Original line Diff line number Diff line
@@ -860,7 +860,6 @@ static inline void sk_mem_uncharge(struct sock *sk, int size)


static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
{
{
	skb_truesize_check(skb);
	sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
	sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
	sk->sk_wmem_queued -= skb->truesize;
	sk->sk_wmem_queued -= skb->truesize;
	sk_mem_uncharge(sk, skb->truesize);
	sk_mem_uncharge(sk, skb->truesize);
+0 −8
Original line number Original line Diff line number Diff line
@@ -143,14 +143,6 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here)
	BUG();
	BUG();
}
}


void skb_truesize_bug(struct sk_buff *skb)
{
	WARN(net_ratelimit(), KERN_ERR "SKB BUG: Invalid truesize (%u) "
	       "len=%u, sizeof(sk_buff)=%Zd\n",
	       skb->truesize, skb->len, sizeof(struct sk_buff));
}
EXPORT_SYMBOL(skb_truesize_bug);

/* 	Allocate a new skbuff. We do this ourselves so we can fill in a few
/* 	Allocate a new skbuff. We do this ourselves so we can fill in a few
 *	'private' fields and also do memory statistics to find all the
 *	'private' fields and also do memory statistics to find all the
 *	[BEEP] leaks.
 *	[BEEP] leaks.
+0 −1
Original line number Original line Diff line number Diff line
@@ -1137,7 +1137,6 @@ void sock_rfree(struct sk_buff *skb)
{
{
	struct sock *sk = skb->sk;
	struct sock *sk = skb->sk;


	skb_truesize_check(skb);
	atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
	atomic_sub(skb->truesize, &sk->sk_rmem_alloc);
	sk_mem_uncharge(skb->sk, skb->truesize);
	sk_mem_uncharge(skb->sk, skb->truesize);
}
}