Commit 0f6947f
ALSA: pcm: Fix races among concurrent hw_params and hw_free calls
commit 92ee3c6 upstream.
Currently we have neither proper check nor protection against the
concurrent calls of PCM hw_params and hw_free ioctls, which may result
in a UAF. Since the existing PCM stream lock can't be used for
protecting the whole ioctl operations, we need a new mutex to protect
those racy calls.
This patch introduced a new mutex, runtime->buffer_mutex, and applies
it to both hw_params and hw_free ioctl code paths. Along with it, the
both functions are slightly modified (the mmap_count check is moved
into the state-check block) for code simplicity.
Reported-by: Hu Jiahui <kirin.say@gmail.com>
Cc: <stable@vger.kernel.org>
Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20220322170720.3529-2-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 014c81d commit 0f6947f
3 files changed
Lines changed: 42 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
401 | 402 | | |
402 | 403 | | |
403 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
969 | 969 | | |
970 | 970 | | |
971 | 971 | | |
| 972 | + | |
972 | 973 | | |
973 | 974 | | |
974 | 975 | | |
| |||
1002 | 1003 | | |
1003 | 1004 | | |
1004 | 1005 | | |
| 1006 | + | |
1005 | 1007 | | |
1006 | 1008 | | |
1007 | 1009 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
667 | 667 | | |
668 | 668 | | |
669 | 669 | | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
670 | 676 | | |
671 | 677 | | |
672 | 678 | | |
673 | 679 | | |
674 | | - | |
| 680 | + | |
675 | 681 | | |
676 | 682 | | |
677 | 683 | | |
678 | 684 | | |
679 | 685 | | |
680 | 686 | | |
| 687 | + | |
681 | 688 | | |
682 | 689 | | |
683 | 690 | | |
684 | 691 | | |
685 | 692 | | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
686 | 696 | | |
687 | 697 | | |
688 | | - | |
689 | | - | |
| 698 | + | |
| 699 | + | |
690 | 700 | | |
691 | 701 | | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
| 702 | + | |
| 703 | + | |
697 | 704 | | |
698 | 705 | | |
699 | 706 | | |
| |||
780 | 787 | | |
781 | 788 | | |
782 | 789 | | |
783 | | - | |
| 790 | + | |
784 | 791 | | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
793 | 805 | | |
794 | 806 | | |
795 | 807 | | |
| |||
829 | 841 | | |
830 | 842 | | |
831 | 843 | | |
832 | | - | |
| 844 | + | |
833 | 845 | | |
834 | 846 | | |
835 | 847 | | |
836 | 848 | | |
| 849 | + | |
837 | 850 | | |
838 | 851 | | |
839 | 852 | | |
840 | 853 | | |
| 854 | + | |
| 855 | + | |
841 | 856 | | |
842 | 857 | | |
843 | | - | |
844 | | - | |
| 858 | + | |
| 859 | + | |
845 | 860 | | |
846 | 861 | | |
847 | | - | |
848 | | - | |
| 862 | + | |
| 863 | + | |
849 | 864 | | |
850 | 865 | | |
851 | 866 | | |
| 867 | + | |
| 868 | + | |
852 | 869 | | |
853 | 870 | | |
854 | 871 | | |
| |||
0 commit comments