diff options
| author | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
|---|---|---|
| committer | Dmitry Torokhov <[email protected]> | 2023-08-30 16:06:38 -0700 | 
| commit | 1ac731c529cd4d6adbce134754b51ff7d822b145 (patch) | |
| tree | 143ab3f35ca5f3b69f583c84e6964b17139c2ec1 /drivers/net/tun.c | |
| parent | 07b4c950f27bef0362dc6ad7ee713aab61d58149 (diff) | |
| parent | 54116d442e001e1b6bd482122043b1870998a1f3 (diff) | |
Merge branch 'next' into for-linus
Prepare input updates for 6.6 merge window.
Diffstat (limited to 'drivers/net/tun.c')
| -rw-r--r-- | drivers/net/tun.c | 20 | 
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index ad653b32b2f0..d75456adc62a 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1486,7 +1486,8 @@ static struct sk_buff *tun_napi_alloc_frags(struct tun_file *tfile,  	skb->truesize += skb->data_len;  	for (i = 1; i < it->nr_segs; i++) { -		size_t fragsz = it->iov[i].iov_len; +		const struct iovec *iov = iter_iov(it); +		size_t fragsz = iov->iov_len;  		struct page *page;  		void *frag; @@ -1976,6 +1977,14 @@ napi_busy:  		int queue_len;  		spin_lock_bh(&queue->lock); + +		if (unlikely(tfile->detached)) { +			spin_unlock_bh(&queue->lock); +			rcu_read_unlock(); +			err = -EBUSY; +			goto free_skb; +		} +  		__skb_queue_tail(queue, skb);  		queue_len = skb_queue_len(queue);  		spin_unlock(&queue->lock); @@ -2511,6 +2520,13 @@ build:  	if (tfile->napi_enabled) {  		queue = &tfile->sk.sk_write_queue;  		spin_lock(&queue->lock); + +		if (unlikely(tfile->detached)) { +			spin_unlock(&queue->lock); +			kfree_skb(skb); +			return -EBUSY; +		} +  		__skb_queue_tail(queue, skb);  		spin_unlock(&queue->lock);  		ret = 1; @@ -3463,6 +3479,8 @@ static int tun_chr_open(struct inode *inode, struct file * file)  	sock_set_flag(&tfile->sk, SOCK_ZEROCOPY); +	/* tun groks IOCB_NOWAIT just fine, mark it as such */ +	file->f_mode |= FMODE_NOWAIT;  	return 0;  }  |