[PATCH OLK-6.6] block: mark GFP_NOIO around sysfs ->store()

From: Ming Lei <tom.leiming@gmail.com> mainline inclusion from mainline-v6.14-rc1 commit 7c0be4ead1f8f5f8be0803f347de0de81e3b8e1c category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBPLKB CVE: CVE-2025-21817 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- sysfs ->store is called with queue freezed, meantime we have several ->store() callbacks(update_nr_requests, wbt, scheduler) to allocate memory with GFP_KERNEL which may run into direct reclaim code path, then potential deadlock can be caused. Fix the issue by marking NOIO around sysfs ->store() Reported-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: stable@vger.kernel.org Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: John Garry <john.g.garry@oracle.com> Link: https://lore.kernel.org/r/20250113015833.698458-1-ming.lei@redhat.com Link: https://lore.kernel.org/linux-block/Z4RkemI9f6N5zoEF@fedora/T/#mc774c65eeca5... Signed-off-by: Jens Axboe <axboe@kernel.dk> Conflicts: block/blk-sysfs.c [Commit a16230649ce27f8ac7dd8a5b079d9657aa96de16 ("block: add a store_limit operations for sysfs entries") add check of store_limit in queue_attr_store; commit af2814149883 ("block: freeze the queue in queue_attr_store") move blk_mq_freeze_queue to queue_attr_store.] Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com> --- block/blk-sysfs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 2de6c14dfecf..8d1bab14b83a 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -773,13 +773,16 @@ queue_attr_store(struct kobject *kobj, struct attribute *attr, struct queue_sysfs_entry *entry = to_queue(attr); struct gendisk *disk = container_of(kobj, struct gendisk, queue_kobj); struct request_queue *q = disk->queue; + unsigned int noio_flag; ssize_t res; if (!entry->store) return -EIO; mutex_lock(&q->sysfs_lock); + noio_flag = memalloc_noio_save(); res = entry->store(q, page, length); + memalloc_noio_restore(noio_flag); mutex_unlock(&q->sysfs_lock); return res; } -- 2.31.1

反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/15346 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/646... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/15346 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/646...
participants (2)
-
Li Lingfeng
-
patchwork bot