mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	hsr: Prevent use after free in prp_create_tagged_frame()
The prp_fill_rct() function can fail.  In that situation, it frees the
skb and returns NULL.  Meanwhile on the success path, it returns the
original skb.  So it's straight forward to fix bug by using the returned
value.
Fixes: 451d8123f8 ("net: prp: add packet handling support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/57af1f28-7f57-4a96-bcd3-b7a0f2340845@moroto.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
			
			
This commit is contained in:
		
							parent
							
								
									7b3ba18703
								
							
						
					
					
						commit
						876f8ab523
					
				
					 1 changed files with 1 additions and 3 deletions
				
			
		| 
						 | 
					@ -342,9 +342,7 @@ struct sk_buff *prp_create_tagged_frame(struct hsr_frame_info *frame,
 | 
				
			||||||
	skb = skb_copy_expand(frame->skb_std, 0,
 | 
						skb = skb_copy_expand(frame->skb_std, 0,
 | 
				
			||||||
			      skb_tailroom(frame->skb_std) + HSR_HLEN,
 | 
								      skb_tailroom(frame->skb_std) + HSR_HLEN,
 | 
				
			||||||
			      GFP_ATOMIC);
 | 
								      GFP_ATOMIC);
 | 
				
			||||||
	prp_fill_rct(skb, frame, port);
 | 
						return prp_fill_rct(skb, frame, port);
 | 
				
			||||||
 | 
					 | 
				
			||||||
	return skb;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
 | 
					static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue