Skip to content

Commit 1b8c8cd

Browse files
committed
Merge tag 'block-6.14-20250214' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - Fix for request rejection for batch addition - Fix a few issues for bogus mac partition tables * tag 'block-6.14-20250214' of git://git.kernel.dk/linux: partitions: mac: fix handling of bogus partition table block: cleanup and fix batch completion adding conditions
2 parents ea71732 + 80e6480 commit 1b8c8cd

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

block/partitions/mac.c

+15-3
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,25 @@ int mac_partition(struct parsed_partitions *state)
5353
}
5454
secsize = be16_to_cpu(md->block_size);
5555
put_dev_sector(sect);
56+
57+
/*
58+
* If the "block size" is not a power of 2, things get weird - we might
59+
* end up with a partition straddling a sector boundary, so we wouldn't
60+
* be able to read a partition entry with read_part_sector().
61+
* Real block sizes are probably (?) powers of two, so just require
62+
* that.
63+
*/
64+
if (!is_power_of_2(secsize))
65+
return -1;
5666
datasize = round_down(secsize, 512);
5767
data = read_part_sector(state, datasize / 512, &sect);
5868
if (!data)
5969
return -1;
6070
partoffset = secsize % 512;
61-
if (partoffset + sizeof(*part) > datasize)
71+
if (partoffset + sizeof(*part) > datasize) {
72+
put_dev_sector(sect);
6273
return -1;
74+
}
6375
part = (struct mac_partition *) (data + partoffset);
6476
if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
6577
put_dev_sector(sect);
@@ -112,8 +124,8 @@ int mac_partition(struct parsed_partitions *state)
112124
int i, l;
113125

114126
goodness++;
115-
l = strlen(part->name);
116-
if (strcmp(part->name, "/") == 0)
127+
l = strnlen(part->name, sizeof(part->name));
128+
if (strncmp(part->name, "/", sizeof(part->name)) == 0)
117129
goodness++;
118130
for (i = 0; i <= l - 4; ++i) {
119131
if (strncasecmp(part->name + i, "root",

include/linux/blk-mq.h

+14-4
Original file line numberDiff line numberDiff line change
@@ -861,12 +861,22 @@ static inline bool blk_mq_add_to_batch(struct request *req,
861861
void (*complete)(struct io_comp_batch *))
862862
{
863863
/*
864-
* blk_mq_end_request_batch() can't end request allocated from
865-
* sched tags
864+
* Check various conditions that exclude batch processing:
865+
* 1) No batch container
866+
* 2) Has scheduler data attached
867+
* 3) Not a passthrough request and end_io set
868+
* 4) Not a passthrough request and an ioerror
866869
*/
867-
if (!iob || (req->rq_flags & RQF_SCHED_TAGS) || ioerror ||
868-
(req->end_io && !blk_rq_is_passthrough(req)))
870+
if (!iob)
869871
return false;
872+
if (req->rq_flags & RQF_SCHED_TAGS)
873+
return false;
874+
if (!blk_rq_is_passthrough(req)) {
875+
if (req->end_io)
876+
return false;
877+
if (ioerror < 0)
878+
return false;
879+
}
870880

871881
if (!iob->complete)
872882
iob->complete = complete;

0 commit comments

Comments
 (0)