Comment 4 for bug 1638700

Revision history for this message
Kamal Mostafa (kamalmostafa) wrote :

Side-note about bug in hio driver 2.1.0.26 (#1: bio_endio() shim macro sets bi_error field). This turns out NOT the cause of this data corruption bug per James' testing, but should be corrected (both in the upstream driver and Ubuntu).

The idea behind this change is correct (the macro shim should indeed set bi_error) but the implementation is unsafe:

 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0))
-#define bio_endio(bio, errors) bio_endio(bio)
+#define bio_endio(bio, errors) \
+ bio->bi_error = errors; \
+ bio_endio(bio)
 #endif

Instead, the macro content must resolve to a single expression, e.g.:

+#define bio_endio(bio, errors) \
+ do { bio->bi_error = errors; bio_endio(bio); } while (0)