Skip to content

Commit d7ad058

Browse files
committed
Merge tag 'block-6.9-20240412' of git://git.kernel.dk/linux
Pull block fixes from Jens Axboe: - MD pull request via Song: - UAF fix (Yu) - Avoid out-of-bounds shift in blk-iocost (Rik) - Fix for q->blkg_list corruption (Ming) - Relax virt boundary mask/size segment checking (Ming) * tag 'block-6.9-20240412' of git://git.kernel.dk/linux: block: fix that blk_time_get_ns() doesn't update time after schedule block: allow device to have both virt_boundary_mask and max segment size block: fix q->blkg_list corruption during disk rebind blk-iocost: avoid out of bounds shift raid1: fix use-after-free for original bio in raid1_write_request()
2 parents c7adbe2 + 3ec4848 commit d7ad058

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

block/blk-cgroup.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,16 +1409,19 @@ static int blkcg_css_online(struct cgroup_subsys_state *css)
14091409
return 0;
14101410
}
14111411

1412+
void blkg_init_queue(struct request_queue *q)
1413+
{
1414+
INIT_LIST_HEAD(&q->blkg_list);
1415+
mutex_init(&q->blkcg_mutex);
1416+
}
1417+
14121418
int blkcg_init_disk(struct gendisk *disk)
14131419
{
14141420
struct request_queue *q = disk->queue;
14151421
struct blkcg_gq *new_blkg, *blkg;
14161422
bool preloaded;
14171423
int ret;
14181424

1419-
INIT_LIST_HEAD(&q->blkg_list);
1420-
mutex_init(&q->blkcg_mutex);
1421-
14221425
new_blkg = blkg_alloc(&blkcg_root, disk, GFP_KERNEL);
14231426
if (!new_blkg)
14241427
return -ENOMEM;

block/blk-cgroup.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ struct blkcg_policy {
189189
extern struct blkcg blkcg_root;
190190
extern bool blkcg_debug_stats;
191191

192+
void blkg_init_queue(struct request_queue *q);
192193
int blkcg_init_disk(struct gendisk *disk);
193194
void blkcg_exit_disk(struct gendisk *disk);
194195

@@ -482,6 +483,7 @@ struct blkcg {
482483
};
483484

484485
static inline struct blkcg_gq *blkg_lookup(struct blkcg *blkcg, void *key) { return NULL; }
486+
static inline void blkg_init_queue(struct request_queue *q) { }
485487
static inline int blkcg_init_disk(struct gendisk *disk) { return 0; }
486488
static inline void blkcg_exit_disk(struct gendisk *disk) { }
487489
static inline int blkcg_policy_register(struct blkcg_policy *pol) { return 0; }

block/blk-core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ struct request_queue *blk_alloc_queue(struct queue_limits *lim, int node_id)
442442
init_waitqueue_head(&q->mq_freeze_wq);
443443
mutex_init(&q->mq_freeze_lock);
444444

445+
blkg_init_queue(q);
446+
445447
/*
446448
* Init percpu_ref in atomic mode so that it's faster to shutdown.
447449
* See blk_register_queue() for details.
@@ -1195,6 +1197,7 @@ void __blk_flush_plug(struct blk_plug *plug, bool from_schedule)
11951197
if (unlikely(!rq_list_empty(plug->cached_rq)))
11961198
blk_mq_free_plug_rqs(plug);
11971199

1200+
plug->cur_ktime = 0;
11981201
current->flags &= ~PF_BLOCK_TS;
11991202
}
12001203

block/blk-iocost.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ static bool iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now)
13471347
{
13481348
struct ioc *ioc = iocg->ioc;
13491349
struct blkcg_gq *blkg = iocg_to_blkg(iocg);
1350-
u64 tdelta, delay, new_delay;
1350+
u64 tdelta, delay, new_delay, shift;
13511351
s64 vover, vover_pct;
13521352
u32 hwa;
13531353

@@ -1362,8 +1362,9 @@ static bool iocg_kick_delay(struct ioc_gq *iocg, struct ioc_now *now)
13621362

13631363
/* calculate the current delay in effect - 1/2 every second */
13641364
tdelta = now->now - iocg->delay_at;
1365-
if (iocg->delay)
1366-
delay = iocg->delay >> div64_u64(tdelta, USEC_PER_SEC);
1365+
shift = div64_u64(tdelta, USEC_PER_SEC);
1366+
if (iocg->delay && shift < BITS_PER_LONG)
1367+
delay = iocg->delay >> shift;
13671368
else
13681369
delay = 0;
13691370

block/blk-settings.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,13 @@ static int blk_validate_limits(struct queue_limits *lim)
182182
return -EINVAL;
183183

184184
/*
185-
* Devices that require a virtual boundary do not support scatter/gather
186-
* I/O natively, but instead require a descriptor list entry for each
187-
* page (which might not be identical to the Linux PAGE_SIZE). Because
188-
* of that they are not limited by our notion of "segment size".
185+
* Stacking device may have both virtual boundary and max segment
186+
* size limit, so allow this setting now, and long-term the two
187+
* might need to move out of stacking limits since we have immutable
188+
* bvec and lower layer bio splitting is supposed to handle the two
189+
* correctly.
189190
*/
190-
if (lim->virt_boundary_mask) {
191-
if (WARN_ON_ONCE(lim->max_segment_size &&
192-
lim->max_segment_size != UINT_MAX))
193-
return -EINVAL;
194-
lim->max_segment_size = UINT_MAX;
195-
} else {
191+
if (!lim->virt_boundary_mask) {
196192
/*
197193
* The maximum segment size has an odd historic 64k default that
198194
* drivers probably should override. Just like the I/O size we

drivers/md/raid1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
15581558
for (j = 0; j < i; j++)
15591559
if (r1_bio->bios[j])
15601560
rdev_dec_pending(conf->mirrors[j].rdev, mddev);
1561-
free_r1bio(r1_bio);
1561+
mempool_free(r1_bio, &conf->r1bio_pool);
15621562
allow_barrier(conf, bio->bi_iter.bi_sector);
15631563

15641564
if (bio->bi_opf & REQ_NOWAIT) {

0 commit comments

Comments
 (0)