Commit 2ee5c10
tun: fix use after free for ptr_ring
We used to initialize ptr_ring during TUNSETIFF, this is because its
size depends on the tx_queue_len of netdevice. And we try to clean it
up when socket were detached from netdevice. A race were spotted when
trying to do uninit during a read which will lead a use after free for
pointer ring. Solving this by always initialize a zero size ptr_ring
in open() and do resizing during TUNSETIFF, and then we can safely do
cleanup during close(). With this, there's no need for the workaround
that was introduced by commit 14d4a88 ("tun: fix a memory leak
for tfile->tx_array").
Reported-by: [email protected]
Cc: Eric Dumazet <[email protected]>
Cc: Cong Wang <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>
Fixes: 078ba52 ("tun: switch to use skb array for tx")
Signed-off-by: Jason Wang <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>1 parent 9fd8ff1 commit 2ee5c10
1 file changed
+12
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | 684 | | |
694 | 685 | | |
695 | 686 | | |
| |||
736 | 727 | | |
737 | 728 | | |
738 | 729 | | |
739 | | - | |
| 730 | + | |
| 731 | + | |
740 | 732 | | |
741 | 733 | | |
742 | 734 | | |
| |||
783 | 775 | | |
784 | 776 | | |
785 | 777 | | |
| 778 | + | |
786 | 779 | | |
787 | | - | |
788 | 780 | | |
789 | 781 | | |
790 | 782 | | |
791 | 783 | | |
| 784 | + | |
792 | 785 | | |
793 | | - | |
794 | 786 | | |
795 | 787 | | |
796 | 788 | | |
| |||
834 | 826 | | |
835 | 827 | | |
836 | 828 | | |
837 | | - | |
| 829 | + | |
| 830 | + | |
838 | 831 | | |
839 | 832 | | |
840 | 833 | | |
| |||
3219 | 3212 | | |
3220 | 3213 | | |
3221 | 3214 | | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
3222 | 3220 | | |
3223 | 3221 | | |
3224 | 3222 | | |
| |||
3239 | 3237 | | |
3240 | 3238 | | |
3241 | 3239 | | |
3242 | | - | |
3243 | | - | |
3244 | 3240 | | |
3245 | 3241 | | |
3246 | 3242 | | |
| |||
3249 | 3245 | | |
3250 | 3246 | | |
3251 | 3247 | | |
| 3248 | + | |
3252 | 3249 | | |
3253 | 3250 | | |
3254 | 3251 | | |
| |||
0 commit comments