Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dm-flakey: Clean up parsing messages

There were a number of cases where the error message for an invalid
table line did not match the actual problem. Fix these. Additionally,
error out when duplicate corrupt_bio_byte, random_read_corrupt, or
random_write_corrupt features are present. Also, error_reads is
incompatible with random_read_corrupt and corrupt_bio_byte with the READ
flag set, so disallow that.

Reported-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

authored by

Benjamin Marzinski and committed by
Mikulas Patocka
19da6b2c d90e7a50

+24 -9
+24 -9
drivers/md/dm-flakey.c
··· 128 128 * corrupt_bio_byte <Nth_byte> <direction> <value> <bio_flags> 129 129 */ 130 130 if (!strcasecmp(arg_name, "corrupt_bio_byte")) { 131 - if (!argc) { 132 - ti->error = "Feature corrupt_bio_byte requires parameters"; 131 + if (fc->corrupt_bio_byte) { 132 + ti->error = "Feature corrupt_bio_byte duplicated"; 133 + return -EINVAL; 134 + } else if (argc < 4) { 135 + ti->error = "Feature corrupt_bio_byte requires 4 parameters"; 133 136 return -EINVAL; 134 137 } 135 138 ··· 179 176 } 180 177 181 178 if (!strcasecmp(arg_name, "random_read_corrupt")) { 182 - if (!argc) { 179 + if (fc->random_read_corrupt) { 180 + ti->error = "Feature random_read_corrupt duplicated"; 181 + return -EINVAL; 182 + } else if (!argc) { 183 183 ti->error = "Feature random_read_corrupt requires a parameter"; 184 184 return -EINVAL; 185 185 } ··· 195 189 } 196 190 197 191 if (!strcasecmp(arg_name, "random_write_corrupt")) { 198 - if (!argc) { 192 + if (fc->random_write_corrupt) { 193 + ti->error = "Feature random_write_corrupt duplicated"; 194 + return -EINVAL; 195 + } else if (!argc) { 199 196 ti->error = "Feature random_write_corrupt requires a parameter"; 200 197 return -EINVAL; 201 198 } ··· 214 205 return -EINVAL; 215 206 } 216 207 217 - if (test_bit(DROP_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { 218 - ti->error = "drop_writes is incompatible with corrupt_bio_byte with the WRITE flag set"; 208 + if (test_bit(DROP_WRITES, &fc->flags) && 209 + (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) { 210 + ti->error = "drop_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set"; 219 211 return -EINVAL; 220 212 221 - } else if (test_bit(ERROR_WRITES, &fc->flags) && (fc->corrupt_bio_rw == WRITE)) { 222 - ti->error = "error_writes is incompatible with corrupt_bio_byte with the WRITE flag set"; 213 + } else if (test_bit(ERROR_WRITES, &fc->flags) && 214 + (fc->corrupt_bio_rw == WRITE || fc->random_write_corrupt)) { 215 + ti->error = "error_writes is incompatible with random_write_corrupt or corrupt_bio_byte with the WRITE flag set"; 216 + return -EINVAL; 217 + } else if (test_bit(ERROR_READS, &fc->flags) && 218 + (fc->corrupt_bio_rw == READ || fc->random_read_corrupt)) { 219 + ti->error = "error_reads is incompatible with random_read_corrupt or corrupt_bio_byte with the READ flag set"; 223 220 return -EINVAL; 224 221 } 225 222 ··· 293 278 if (r) 294 279 goto bad; 295 280 296 - r = dm_read_arg(_args, &as, &fc->down_interval, &ti->error); 281 + r = dm_read_arg(_args + 1, &as, &fc->down_interval, &ti->error); 297 282 if (r) 298 283 goto bad; 299 284