net: add a temporary sanity check in skb_orphan()
David suggested to add a BUG_ON() to catch if some layer
sets skb->sk pointer without a corresponding destructor.
As skb can sit in a queue, it's mandatory to make sure the
socket cannot disappear, and it's usually done by taking a
reference on the socket, then releasing it from the skb
destructor.
This patch is a follow-up to commit c34a761231
("net: skb_orphan() changes") and will be reverted after
catching all possible offenders if any.
Suggested-by: David Miller <davem@davemloft.net>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
	
	
This commit is contained in:
		
					parent
					
						
							
								46b3a42190
							
						
					
				
			
			
				commit
				
					
						376c7311bd
					
				
			
		
					 1 changed files with 2 additions and 0 deletions
				
			
		|  | @ -1809,6 +1809,8 @@ static inline void skb_orphan(struct sk_buff *skb) | ||||||
| 		skb->destructor(skb); | 		skb->destructor(skb); | ||||||
| 		skb->destructor = NULL; | 		skb->destructor = NULL; | ||||||
| 		skb->sk		= NULL; | 		skb->sk		= NULL; | ||||||
|  | 	} else { | ||||||
|  | 		BUG_ON(skb->sk); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Eric Dumazet
				Eric Dumazet