Commit 9abee47
ceph: improve error handling and short/overflow-read logic in __ceph_sync_read()
This patch refines the read logic in __ceph_sync_read() to ensure more
predictable and efficient behavior in various edge cases.
- Return early if the requested read length is zero or if the file size
(`i_size`) is zero.
- Initialize the index variable (`idx`) where needed and reorder some
code to ensure it is always set before use.
- Improve error handling by checking for negative return values earlier.
- Remove redundant encrypted file checks after failures. Only attempt
filesystem-level decryption if the read succeeded.
- Simplify leftover calculations to correctly handle cases where the
read extends beyond the end of the file or stops short. This can be
hit by continuously reading a file while, on another client, we keep
truncating and writing new data into it.
- This resolves multiple issues caused by integer and consequent buffer
overflow (`pages` array being accessed beyond `num_pages`):
- https://tracker.ceph.com/issues/67524
- https://tracker.ceph.com/issues/68980
- https://tracker.ceph.com/issues/68981
Cc: [email protected]
Fixes: 1065da2 ("ceph: stop copying to iter at EOF on sync reads")
Reported-by: Luis Henriques (SUSE) <[email protected]>
Signed-off-by: Alex Markuze <[email protected]>
Reviewed-by: Viacheslav Dubeyko <[email protected]>
Signed-off-by: Ilya Dryomov <[email protected]>1 parent 12eb22a commit 9abee47
1 file changed
+14
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
1069 | | - | |
| 1069 | + | |
1070 | 1070 | | |
1071 | 1071 | | |
1072 | 1072 | | |
| |||
1086 | 1086 | | |
1087 | 1087 | | |
1088 | 1088 | | |
1089 | | - | |
| 1089 | + | |
1090 | 1090 | | |
1091 | 1091 | | |
1092 | 1092 | | |
| |||
1160 | 1160 | | |
1161 | 1161 | | |
1162 | 1162 | | |
1163 | | - | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
1164 | 1171 | | |
1165 | 1172 | | |
1166 | 1173 | | |
| |||
1187 | 1194 | | |
1188 | 1195 | | |
1189 | 1196 | | |
1190 | | - | |
| 1197 | + | |
1191 | 1198 | | |
1192 | 1199 | | |
1193 | 1200 | | |
| |||
1197 | 1204 | | |
1198 | 1205 | | |
1199 | 1206 | | |
1200 | | - | |
1201 | | - | |
1202 | | - | |
1203 | | - | |
1204 | | - | |
| 1207 | + | |
| 1208 | + | |
1205 | 1209 | | |
1206 | 1210 | | |
| 1211 | + | |
1207 | 1212 | | |
1208 | 1213 | | |
1209 | 1214 | | |
| |||
1222 | 1227 | | |
1223 | 1228 | | |
1224 | 1229 | | |
1225 | | - | |
1226 | | - | |
1227 | | - | |
1228 | | - | |
1229 | | - | |
1230 | | - | |
1231 | 1230 | | |
1232 | 1231 | | |
1233 | 1232 | | |
| |||
0 commit comments