Repository navigation
Commit 6d6f332
commoncap: don't alloc the credential unless needed in cap_task_prctl
In function cap_task_prctl(), we would allocate a credential
unconditionally and then check if we support the requested function.
If not we would release this credential with abort_creds() by using
RCU method. But on some archs such as powerpc, the sys_prctl is heavily
used to get/set the floating point exception mode. So the unnecessary
allocating/releasing of credential not only introduce runtime overhead
but also do cause OOM due to the RCU implementation.
This patch removes abort_creds() from cap_task_prctl() by calling
prepare_creds() only when we need to modify it.
Reported-by: Kevin Hao <haokexin@gmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Paul Moore <paul@paul-moore.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: James Morris <james.l.morris@oracle.com>1 parent fd33c43 commit 6d6f332
1 file changed
Lines changed: 30 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
822 | 822 | | |
823 | 823 | | |
824 | 824 | | |
825 | | - | |
| 825 | + | |
826 | 826 | | |
| 827 | + | |
| 828 | + | |
827 | 829 | | |
828 | 830 | | |
829 | 831 | | |
830 | 832 | | |
831 | 833 | | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
832 | 837 | | |
833 | | - | |
| 838 | + | |
834 | 839 | | |
835 | 840 | | |
836 | 841 | | |
| |||
848 | 853 | | |
849 | 854 | | |
850 | 855 | | |
| 856 | + | |
851 | 857 | | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | 858 | | |
858 | 859 | | |
859 | 860 | | |
860 | | - | |
861 | 861 | | |
862 | | - | |
863 | | - | |
864 | | - | |
| 862 | + | |
| 863 | + | |
865 | 864 | | |
866 | 865 | | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
| 866 | + | |
871 | 867 | | |
872 | 868 | | |
873 | 869 | | |
| |||
889 | 885 | | |
890 | 886 | | |
891 | 887 | | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
896 | 891 | | |
897 | 892 | | |
898 | 893 | | |
| |||
906 | 901 | | |
907 | 902 | | |
908 | 903 | | |
909 | | - | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
910 | 909 | | |
911 | | - | |
| 910 | + | |
912 | 911 | | |
913 | 912 | | |
914 | | - | |
915 | | - | |
| 913 | + | |
916 | 914 | | |
917 | 915 | | |
918 | | - | |
919 | | - | |
920 | | - | |
| 916 | + | |
921 | 917 | | |
922 | 918 | | |
923 | | - | |
924 | 919 | | |
925 | | - | |
926 | | - | |
| 920 | + | |
927 | 921 | | |
928 | | - | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
929 | 927 | | |
930 | 928 | | |
931 | 929 | | |
932 | 930 | | |
933 | | - | |
| 931 | + | |
934 | 932 | | |
935 | 933 | | |
936 | 934 | | |
937 | | - | |
938 | | - | |
| 935 | + | |
939 | 936 | | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | 937 | | |
950 | 938 | | |
951 | 939 | | |
| |||
0 commit comments