Commit 92ee3c6
committed
ALSA: pcm: Fix races among concurrent hw_params and hw_free calls
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>1 parent 646b907 commit 92ee3c6
3 files changed
Lines changed: 42 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
404 | 405 | | |
405 | 406 | | |
406 | 407 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
688 | 694 | | |
689 | 695 | | |
690 | 696 | | |
691 | 697 | | |
692 | | - | |
| 698 | + | |
693 | 699 | | |
694 | 700 | | |
695 | 701 | | |
696 | 702 | | |
697 | 703 | | |
698 | 704 | | |
| 705 | + | |
699 | 706 | | |
700 | 707 | | |
701 | 708 | | |
702 | 709 | | |
703 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
704 | 714 | | |
705 | 715 | | |
706 | | - | |
707 | | - | |
| 716 | + | |
| 717 | + | |
708 | 718 | | |
709 | 719 | | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
| 720 | + | |
| 721 | + | |
715 | 722 | | |
716 | 723 | | |
717 | 724 | | |
| |||
799 | 806 | | |
800 | 807 | | |
801 | 808 | | |
802 | | - | |
| 809 | + | |
803 | 810 | | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
811 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
812 | 824 | | |
813 | 825 | | |
814 | 826 | | |
| |||
848 | 860 | | |
849 | 861 | | |
850 | 862 | | |
851 | | - | |
| 863 | + | |
852 | 864 | | |
853 | 865 | | |
854 | 866 | | |
855 | 867 | | |
| 868 | + | |
856 | 869 | | |
857 | 870 | | |
858 | 871 | | |
859 | 872 | | |
| 873 | + | |
| 874 | + | |
860 | 875 | | |
861 | 876 | | |
862 | | - | |
863 | | - | |
| 877 | + | |
| 878 | + | |
864 | 879 | | |
865 | 880 | | |
866 | | - | |
867 | | - | |
| 881 | + | |
| 882 | + | |
868 | 883 | | |
869 | 884 | | |
870 | 885 | | |
| 886 | + | |
| 887 | + | |
871 | 888 | | |
872 | 889 | | |
873 | 890 | | |
| |||
0 commit comments