Skip to content

Commit fe742c0

Browse files
svens-s390Alexander Gordeev
authored andcommitted
s390/os_info: Fix array size in struct os_info
gcc's -Warray-bounds warned about an out-of-bounds access to the entry array contained in struct os_info. This doesn't trigger a bug right now because there's a large reserved space after the array. Nevertheless fix this, and also add a BUILD_BUG_ON to make sure struct os_info is always exactly on page in size. Fixes: f4cac27 ("s390/crash: Use old os_info to create PT_LOAD headers") Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent a2269a6 commit fe742c0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

arch/s390/include/asm/os_info.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#define OS_INFO_IMAGE_START 10
2828
#define OS_INFO_IMAGE_END 11
2929
#define OS_INFO_IMAGE_PHYS 12
30+
#define OS_INFO_MAX 13
3031

3132
#define OS_INFO_FLAG_REIPL_CLEAR (1UL << 0)
3233

@@ -46,8 +47,8 @@ struct os_info {
4647
u16 version_minor;
4748
u64 crashkernel_addr;
4849
u64 crashkernel_size;
49-
struct os_info_entry entry[10];
50-
u8 reserved[3864];
50+
struct os_info_entry entry[OS_INFO_MAX];
51+
u8 reserved[3804];
5152
} __packed;
5253

5354
void os_info_init(void);

arch/s390/kernel/os_info.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ void __init os_info_init(void)
7373
{
7474
struct lowcore *abs_lc;
7575

76+
BUILD_BUG_ON(sizeof(struct os_info) != PAGE_SIZE);
7677
os_info.version_major = OS_INFO_VERSION_MAJOR;
7778
os_info.version_minor = OS_INFO_VERSION_MINOR;
7879
os_info.magic = OS_INFO_MAGIC;

0 commit comments

Comments
 (0)