mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	tls: rx: clear ctx->recv_pkt earlier
Whatever we do in the loop the skb should not remain on as ctx->recv_pkt afterwards. We can clear that pointer and restart strparser earlier. This adds overhead of extra linking and unlinking to rx_list but that's not large (upcoming change will switch to unlocked skb list operations). Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									465ea73535
								
							
						
					
					
						commit
						b1a2c17863
					
				
					 1 changed files with 7 additions and 9 deletions
				
			
		| 
						 | 
					@ -1826,6 +1826,10 @@ int tls_sw_recvmsg(struct sock *sk,
 | 
				
			||||||
		if (err <= 0)
 | 
							if (err <= 0)
 | 
				
			||||||
			goto recv_end;
 | 
								goto recv_end;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ctx->recv_pkt = NULL;
 | 
				
			||||||
 | 
							__strp_unpause(&ctx->strp);
 | 
				
			||||||
 | 
							skb_queue_tail(&ctx->rx_list, skb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (async) {
 | 
							if (async) {
 | 
				
			||||||
			/* TLS 1.2-only, to_decrypt must be text length */
 | 
								/* TLS 1.2-only, to_decrypt must be text length */
 | 
				
			||||||
			chunk = min_t(int, to_decrypt, len);
 | 
								chunk = min_t(int, to_decrypt, len);
 | 
				
			||||||
| 
						 | 
					@ -1840,10 +1844,9 @@ int tls_sw_recvmsg(struct sock *sk,
 | 
				
			||||||
				if (err != __SK_PASS) {
 | 
									if (err != __SK_PASS) {
 | 
				
			||||||
					rxm->offset = rxm->offset + rxm->full_len;
 | 
										rxm->offset = rxm->offset + rxm->full_len;
 | 
				
			||||||
					rxm->full_len = 0;
 | 
										rxm->full_len = 0;
 | 
				
			||||||
 | 
										skb_unlink(skb, &ctx->rx_list);
 | 
				
			||||||
					if (err == __SK_DROP)
 | 
										if (err == __SK_DROP)
 | 
				
			||||||
						consume_skb(skb);
 | 
											consume_skb(skb);
 | 
				
			||||||
					ctx->recv_pkt = NULL;
 | 
					 | 
				
			||||||
					__strp_unpause(&ctx->strp);
 | 
					 | 
				
			||||||
					continue;
 | 
										continue;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
| 
						 | 
					@ -1869,14 +1872,9 @@ int tls_sw_recvmsg(struct sock *sk,
 | 
				
			||||||
		len -= chunk;
 | 
							len -= chunk;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* For async or peek case, queue the current skb */
 | 
							/* For async or peek case, queue the current skb */
 | 
				
			||||||
		if (async || is_peek || retain_skb) {
 | 
							if (!(async || is_peek || retain_skb)) {
 | 
				
			||||||
			skb_queue_tail(&ctx->rx_list, skb);
 | 
								skb_unlink(skb, &ctx->rx_list);
 | 
				
			||||||
			ctx->recv_pkt = NULL;
 | 
					 | 
				
			||||||
			__strp_unpause(&ctx->strp);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			consume_skb(skb);
 | 
								consume_skb(skb);
 | 
				
			||||||
			ctx->recv_pkt = NULL;
 | 
					 | 
				
			||||||
			__strp_unpause(&ctx->strp);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			/* Return full control message to
 | 
								/* Return full control message to
 | 
				
			||||||
			 * userspace before trying to parse
 | 
								 * userspace before trying to parse
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue