Commit d6c7396
bsg: fix race of bsg_open and bsg_unregister
The existing implementation allows races between bsg_unregister and
bsg_open paths. bsg_unregister and request_queue cleanup and deletion
may start and complete right after bsg_get_device (in bsg_open path)
retrieves bsg_class_device and releases the mutex. Then bsg_open path
touches freed memory of bsg_class_device and request_queue.
One possible fix is to hold the mutex all the way through bsg_get_device
instead of releasing it after bsg_class_device retrieval.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-Off-By: Anatoliy Glagolev <glagolig@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent be7f99c commit d6c7396
1 file changed
+11
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
| 697 | + | |
696 | 698 | | |
697 | 699 | | |
698 | 700 | | |
| |||
707 | 709 | | |
708 | 710 | | |
709 | 711 | | |
710 | | - | |
711 | 712 | | |
712 | 713 | | |
713 | 714 | | |
714 | 715 | | |
715 | 716 | | |
716 | 717 | | |
717 | | - | |
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
724 | 724 | | |
725 | | - | |
| 725 | + | |
726 | 726 | | |
727 | 727 | | |
728 | 728 | | |
| |||
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
735 | | - | |
736 | 735 | | |
737 | 736 | | |
738 | 737 | | |
| |||
746 | 745 | | |
747 | 746 | | |
748 | 747 | | |
749 | | - | |
750 | 748 | | |
751 | | - | |
752 | | - | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
753 | 753 | | |
754 | 754 | | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
| 755 | + | |
| 756 | + | |
759 | 757 | | |
| 758 | + | |
| 759 | + | |
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
| |||
0 commit comments