From b513c435b417e960833bd4d885174b2e847f5319 Mon Sep 17 00:00:00 2001
Date: Mon, 11 Sep 2017 12:42:28 +0000
Subject: [PATCH 24/25] fix kabi broken by "struct scsi_disk and struct
queue_limits and enum rq_flag_bits"
euler inclusion
category: bugfix
bugzilla: N/A
DTS: N/A
CVE: N/A
-----------------------------------
The new struct member introduces some kabi broken,fix it as follow
crash> struct scsi_disk -o
struct scsi_disk {
[0] struct scsi_driver *driver; /* always &sd_template */
[8] struct scsi_device *device;
[16] struct device dev;
[688] struct gendisk *disk;
[696] atomic_t openers;
[704] sector_t capacity; /* size in logical blocks */
[712] u32 max_ws_blocks;
[716] u32 max_unmap_blocks;
[720] u32 unmap_granularity;
[724] u32 unmap_alignment;
[728] u32 index;
[732] unsigned int physical_block_size;
[736] unsigned int max_medium_access_timeouts;
[740] unsigned int medium_access_timed_out;
[744] u8 media_present;
[745] u8 write_prot;
[746] u8 protection_type;/* Data Integrity Field */
[747] u8 provisioning_mode;
unsigned ATO : 1; /* state of disk ATO bit */
unsigned cache_override : 1; /* temp override of WCE,RCD */
unsigned WCE : 1; /* state of disk WCE bit */
unsigned RCD : 1; /* state of disk RCD bit, unused */
unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
unsigned first_scan : 1;
unsigned lbpme : 1;
unsigned lbprz : 1;
unsigned lbpu : 1;
unsigned lbpws : 1;
unsigned lbpws10 : 1;
unsigned lbpvpd : 1;
unsigned ws10 : 1;
unsigned ws16 : 1;
/* FOR RH USE ONLY
*
* The following padding has been inserted before ABI freeze to
* allow extending the structure while preserving ABI.
*/
[752] u32 xcopy_reserved;
/*This is 4bytes space here*/
[760] RH_KABI_USE(1, u32 max_xfer_blocks)
[768] RH_KABI_USE(2, u32 opt_xfer_blocks)
};
SIZE: 776
crash> strut queue_limits -o
struct queue_limits {
[0] unsigned long bounce_pfn;
[8] unsigned long seg_boundary_mask;
[16] unsigned int max_hw_sectors;
[20] unsigned int max_sectors;
[24] unsigned int max_segment_size;
[28] unsigned int physical_block_size;
[32] unsigned int alignment_offset;
[36] unsigned int io_min;
[40] unsigned int io_opt;
[44] unsigned int max_discard_sectors;
[48] unsigned int max_write_same_sectors;
[52] unsigned int discard_granularity;
[56] unsigned int discard_alignment;
[60] unsigned short logical_block_size;
[62] unsigned short max_segments;
[64] unsigned short max_integrity_segments;
[66] unsigned char misaligned;
[67] unsigned char discard_misaligned;
[68] unsigned char cluster;
[69] unsigned char discard_zeroes_data;
/* FOR RH USE ONLY
*
* The following padding has been inserted before ABI freeze to
* allow extending the structure while preserving ABI.
*/
[72] unsigned int xcopy_reserved;
/*This is 4bytes space here*/
[80] RH_KABI_USE(1, unsigned int chunk_sectors)
[88] RH_KABI_USE(2, unsigned int max_dev_sectors)
[96] RH_KABI_USE(3, struct queue_limits_aux *limits_aux)
};
SIZE:104
[
1.increase the member u32 scsi_disk_flags in scsi_disk with "#ifndef __GENKSYMS__", because of the struct address hole,then increase struct scsi_disk_zoned include scsi_disk and all new member,
so this solution could avoid the kabi problem;
2.the same about queue_limits
3.replace the enum increased member to the define to realizing
]
---
drivers/scsi/sd.h | 36 ++++++++++++++++++++++++------------
include/linux/blk_types.h | 4 ++--
include/linux/blkdev.h | 15 ++++++++++++++-
3 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 835012c..7c78683 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -66,15 +66,6 @@ struct scsi_disk {
struct scsi_device *device;
struct device dev;
struct gendisk *disk;
-#ifdef CONFIG_BLK_DEV_ZONED
- unsigned int nr_zones;
- unsigned int zone_blocks;
- unsigned int zone_shift;
- unsigned long *zones_wlock;
- unsigned int zones_optimal_open;
- unsigned int zones_optimal_nonseq;
- unsigned int zones_max_open;
-#endif
atomic_t openers;
sector_t capacity; /* size in logical blocks */
u32 max_ws_blocks;
@@ -103,9 +94,6 @@ struct scsi_disk {
unsigned lbpvpd : 1;
unsigned ws10 : 1;
unsigned ws16 : 1;
- unsigned rc_basis: 2;
- unsigned zoned: 2;
- unsigned urswrz : 1;
/* FOR RH USE ONLY
*
@@ -114,10 +102,34 @@ struct scsi_disk {
*/
u32 xcopy_reserved;
+#ifndef __GENKSYMS__
+ u32 scsi_disk_flag;
+#endif
RH_KABI_USE(1, u32 max_xfer_blocks)
RH_KABI_USE(2, u32 opt_xfer_blocks)
};
#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
+struct scsi_disk_zoned {
+ struct scsi_disk sdkp;
+#ifdef CONFIG_BLK_DEV_ZONED
+ unsigned int nr_zones;
+ unsigned int zone_blocks;
+ unsigned int zone_shift;
+ unsigned long *zones_wlock;
+ unsigned int zones_optimal_open;
+ unsigned int zones_optimal_nonseq;
+ unsigned int zones_max_open;
+#endif
+ unsigned rc_basis:2;
+ unsigned zoned:2;
+ unsigned urswrz:1;
+};
+#define S_SCSI_DISK_FLAGS 0x534D52
+#define IS_SCSI_DISK_ZONED(scsi_disk) ((scsi_disk)->scsi_disk_flag == S_SCSI_DISK_FLAGS)
+static inline struct scsi_disk_zoned *get_sdkp_zoned(struct scsi_disk *sdkp, unsigned version)
+{
+ return container_of(sdkp, struct scsi_disk_zoned, sdkp);
+}
static inline struct scsi_disk *scsi_disk(struct gendisk *disk)
{
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index ce57a5f..5e585cb 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -210,8 +210,6 @@ enum rq_flag_bits {
#else
rh_reserved__REQ_NO_TIMEOUT_orig,
#endif
- __REQ_ZONE_REPORT, /* Get zone information */
- __REQ_ZONE_RESET, /* Reset a zone write pointer */
__REQ_NR_BITS, /* stops here */
};
@@ -257,6 +255,8 @@ enum rq_flag_bits {
#define REQ_ALLOCED (1ULL << __REQ_ALLOCED)
#define REQ_COPY_USER (1ULL << __REQ_COPY_USER)
#define REQ_FLUSH (1ULL << __REQ_FLUSH)
+#define __REQ_ZONE_REPORT 62 /* Get zone information */
+#define __REQ_ZONE_RESET 63 /* Reset a zone write pointer */
#define REQ_OP_ZONE_REPORT (1ULL << __REQ_ZONE_REPORT)
#define REQ_OP_ZONE_RESET (1ULL << __REQ_ZONE_RESET)
#define REQ_FLUSH_SEQ (1ULL << __REQ_FLUSH_SEQ)
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 099fd49..4d5f30b 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -336,7 +336,6 @@ struct queue_limits {
unsigned char discard_misaligned;
unsigned char cluster;
unsigned char
kenel里解决kabi的问题
最新推荐文章于 2024-02-28 17:45:40 发布
本文详细探讨了Kernel Application Binary Interface (KABI)问题的起因,阐述了KABI保持稳定对于Linux内核的重要性。通过实例分析,解释了如何识别KABI不兼容性,并提供了详细的步骤来定位和解决这些问题,确保系统的安全性和稳定性。
摘要由CSDN通过智能技术生成