From: Yu Kuai yukuai3@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6MRB5 CVE: NA
--------------------------------
Include blk.h in ioctl.c will cause kabi broken, because some data structure definitions is exposed. This patch add a separate header file to fix this problem.
Signed-off-by: Yu Kuai yukuai3@huawei.com Reviewed-by: Hou Tao houtao1@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- block/blk.h | 1 - block/blk_extra_api.h | 27 +++++++++++++++++++++++++++ block/ioctl.c | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 block/blk_extra_api.h
diff --git a/block/blk.h b/block/blk.h index 3f1c76b55336..9269bb6b14f8 100644 --- a/block/blk.h +++ b/block/blk.h @@ -214,7 +214,6 @@ unsigned int blk_plug_queued_count(struct request_queue *q); void blk_account_io_start(struct request *req, bool new_io); void blk_account_io_completion(struct request *req, unsigned int bytes); void blk_account_io_done(struct request *req, u64 now); -int disk_scan_partitions(struct gendisk *disk, fmode_t mode);
/* * EH timer and IO completion will both attempt to 'grab' the request, make diff --git a/block/blk_extra_api.h b/block/blk_extra_api.h new file mode 100644 index 000000000000..704d2a61bf12 --- /dev/null +++ b/block/blk_extra_api.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2023. Huawei Technologies Co., Ltd. All rights reserved. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef BLK_EXTRA_API_H +#define BLK_EXTRA_API_H + +/* + * Include blk.h will cause kabi broken in some contexts because it will expose + * definitions for some data structure. This file is used for the apis that + * can't be placed in blk.h. + */ + +#include <linux/genhd.h> + +int disk_scan_partitions(struct gendisk *disk, fmode_t mode); + +#endif /* BLK_EXTRA_API_H */ diff --git a/block/ioctl.c b/block/ioctl.c index da8d09146385..ddc6d340e876 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -10,7 +10,7 @@ #include <linux/pr.h> #include <linux/uaccess.h>
-#include "blk.h" +#include "blk_extra_api.h"
static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg) {