Commit 0daa99d
IB/umad: Fix use-after-free on close
commit 60e1751 upstream.
Avoid that closing /dev/infiniband/umad<n> or /dev/infiniband/issm<n>
triggers a use-after-free. __fput() invokes f_op->release() before it
invokes cdev_put(). Make sure that the ib_umad_device structure is
freed by the cdev_put() call instead of f_op->release(). This avoids
that changing the port mode from IB into Ethernet and back to IB
followed by restarting opensmd triggers the following kernel oops:
general protection fault: 0000 [#1] PREEMPT SMP
RIP: 0010:[<ffffffff810cc65c>] [<ffffffff810cc65c>] module_put+0x2c/0x170
Call Trace:
[<ffffffff81190f20>] cdev_put+0x20/0x30
[<ffffffff8118e2ce>] __fput+0x1ae/0x1f0
[<ffffffff8118e35e>] ____fput+0xe/0x10
[<ffffffff810723bc>] task_work_run+0xac/0xe0
[<ffffffff81002a9f>] do_notify_resume+0x9f/0xc0
[<ffffffff814b8398>] int_signal+0x12/0x17
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=75051
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>1 parent 1e798f4 commit 0daa99d
1 file changed
+19
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
137 | | - | |
| 137 | + | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
145 | 149 | | |
146 | 150 | | |
147 | 151 | | |
| |||
812 | 816 | | |
813 | 817 | | |
814 | 818 | | |
815 | | - | |
| 819 | + | |
816 | 820 | | |
817 | 821 | | |
818 | 822 | | |
| |||
851 | 855 | | |
852 | 856 | | |
853 | 857 | | |
854 | | - | |
| 858 | + | |
855 | 859 | | |
856 | 860 | | |
857 | 861 | | |
| |||
902 | 906 | | |
903 | 907 | | |
904 | 908 | | |
905 | | - | |
| 909 | + | |
906 | 910 | | |
907 | 911 | | |
908 | 912 | | |
| |||
932 | 936 | | |
933 | 937 | | |
934 | 938 | | |
935 | | - | |
| 939 | + | |
936 | 940 | | |
937 | 941 | | |
938 | 942 | | |
| |||
1000 | 1004 | | |
1001 | 1005 | | |
1002 | 1006 | | |
| 1007 | + | |
1003 | 1008 | | |
1004 | 1009 | | |
1005 | 1010 | | |
| |||
1032 | 1037 | | |
1033 | 1038 | | |
1034 | 1039 | | |
| 1040 | + | |
1035 | 1041 | | |
1036 | 1042 | | |
1037 | 1043 | | |
| |||
1050 | 1056 | | |
1051 | 1057 | | |
1052 | 1058 | | |
| 1059 | + | |
1053 | 1060 | | |
1054 | 1061 | | |
1055 | 1062 | | |
| |||
1143 | 1150 | | |
1144 | 1151 | | |
1145 | 1152 | | |
1146 | | - | |
| 1153 | + | |
1147 | 1154 | | |
1148 | 1155 | | |
1149 | 1156 | | |
1150 | 1157 | | |
1151 | 1158 | | |
1152 | 1159 | | |
1153 | 1160 | | |
1154 | | - | |
| 1161 | + | |
| 1162 | + | |
1155 | 1163 | | |
1156 | 1164 | | |
1157 | 1165 | | |
| |||
1163 | 1171 | | |
1164 | 1172 | | |
1165 | 1173 | | |
1166 | | - | |
| 1174 | + | |
1167 | 1175 | | |
1168 | 1176 | | |
1169 | 1177 | | |
| |||
1177 | 1185 | | |
1178 | 1186 | | |
1179 | 1187 | | |
1180 | | - | |
| 1188 | + | |
1181 | 1189 | | |
1182 | 1190 | | |
1183 | 1191 | | |
| |||
0 commit comments