Repository navigation
Commit 6050fa4
loop: don't hold lo_mutex during __loop_clr_fd()
syzbot is reporting circular locking problem at __loop_clr_fd() [1], for
commit 87579e9 ("loop: use worker per cgroup instead of kworker")
is calling destroy_workqueue() with lo->lo_mutex held.
Since all functions where lo->lo_state matters are already checking
lo->lo_state with lo->lo_mutex held (in order to avoid racing with e.g.
ioctl(LOOP_CTL_REMOVE)), and __loop_clr_fd() can be called from either
ioctl(LOOP_CLR_FD) xor close(), lo->lo_state == Lo_rundown is considered
as an exclusive lock for __loop_clr_fd(). Therefore, hold lo->lo_mutex
inside __loop_clr_fd() only when asserting/updating lo->lo_state.
Since ioctl(LOOP_CLR_FD) depends on lo->lo_state == Lo_bound, a valid
lo->lo_backing_file must have been assigned by ioctl(LOOP_SET_FD) or
ioctl(LOOP_CONFIGURE). Thus, we can remove lo->lo_backing_file test,
and convert __loop_clr_fd() into a void function.
Link: https://syzkaller.appspot.com/bug?extid=63614029dfb79abd4383 [1]
Reported-by: syzbot <syzbot+63614029dfb79abd4383@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/8ebe3b2e-8975-7f26-0620-7144a3b8b8cd@i-love.sakura.ne.jp
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent a30e344 commit 6050fa4
1 file changed
Lines changed: 22 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1082 | 1082 | | |
1083 | 1083 | | |
1084 | 1084 | | |
1085 | | - | |
| 1085 | + | |
1086 | 1086 | | |
1087 | | - | |
| 1087 | + | |
1088 | 1088 | | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | 1089 | | |
1093 | 1090 | | |
1094 | 1091 | | |
| |||
1103 | 1100 | | |
1104 | 1101 | | |
1105 | 1102 | | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
1106 | 1108 | | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
1110 | | - | |
1111 | | - | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
| 1109 | + | |
| 1110 | + | |
1117 | 1111 | | |
1118 | 1112 | | |
1119 | 1113 | | |
| |||
1134 | 1128 | | |
1135 | 1129 | | |
1136 | 1130 | | |
| 1131 | + | |
1137 | 1132 | | |
1138 | 1133 | | |
1139 | 1134 | | |
| |||
1153 | 1148 | | |
1154 | 1149 | | |
1155 | 1150 | | |
1156 | | - | |
1157 | | - | |
1158 | 1151 | | |
1159 | | - | |
1160 | | - | |
1161 | | - | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
1162 | 1156 | | |
1163 | 1157 | | |
1164 | 1158 | | |
| |||
1174 | 1168 | | |
1175 | 1169 | | |
1176 | 1170 | | |
1177 | | - | |
| 1171 | + | |
1178 | 1172 | | |
1179 | | - | |
1180 | 1173 | | |
1181 | 1174 | | |
1182 | 1175 | | |
1183 | 1176 | | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
1190 | 1180 | | |
1191 | | - | |
1192 | 1181 | | |
1193 | 1182 | | |
1194 | 1183 | | |
| 1184 | + | |
1195 | 1185 | | |
1196 | 1186 | | |
1197 | 1187 | | |
| |||
1200 | 1190 | | |
1201 | 1191 | | |
1202 | 1192 | | |
1203 | | - | |
1204 | | - | |
1205 | | - | |
| 1193 | + | |
1206 | 1194 | | |
1207 | 1195 | | |
1208 | 1196 | | |
| |||
1234 | 1222 | | |
1235 | 1223 | | |
1236 | 1224 | | |
1237 | | - | |
| 1225 | + | |
| 1226 | + | |
1238 | 1227 | | |
1239 | 1228 | | |
1240 | 1229 | | |
| |||
0 commit comments