Commit 36991c1
ksmbd: Fix UAF in __close_file_table_ids
A use-after-free is possible if one thread destroys the file
via __ksmbd_close_fd while another thread holds a reference to
it. The existing checks on fp->refcount are not sufficient to
prevent this.
The fix takes ft->lock around the section which removes the
file from the file table. This prevents two threads acquiring the
same file pointer via __close_file_table_ids, as well as the other
functions which retrieve a file from the IDR and which already use
this same lock.
Cc: stable@vger.kernel.org
Signed-off-by: Sean Heelan <seanheelan@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>1 parent 0ca6df4 commit 36991c1
1 file changed
+26
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | | - | |
666 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
667 | 675 | | |
668 | | - | |
669 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
670 | 680 | | |
| 681 | + | |
671 | 682 | | |
672 | 683 | | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
673 | 691 | | |
674 | | - | |
675 | | - | |
676 | 692 | | |
| 693 | + | |
677 | 694 | | |
| 695 | + | |
678 | 696 | | |
| 697 | + | |
679 | 698 | | |
680 | 699 | | |
681 | 700 | | |
| |||
0 commit comments