d180b0 Rebase kexec-tools to v2.0.24

Authored and Committed by liutgnu 2 years ago
    Rebase kexec-tools to v2.0.24
    
    Resolves: bz2076157
    
    Signed-off-by: Tao Liu <ltao@redhat.com>
    
        
kexec-tools-2.0.22-01-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch DELETED
@@ -1,95 +0,0 @@
1
- commit 186e7b0752d8fce1618fa37519671c834c46340e
2
- Author: Alexander Egorenkov <egorenar@linux.ibm.com>
3
- Date: Wed Dec 15 18:48:53 2021 +0100
4
-
5
- s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel()
6
-
7
- Starting with gcc 11.3, the C compiler will generate PLT-relative function
8
- calls even if they are local and do not require it. Later on during linking,
9
- the linker will replace all PLT-relative calls to local functions with
10
- PC-relative ones. Unfortunately, the purgatory code of kexec/kdump is
11
- not being linked as a regular executable or shared library would have been,
12
- and therefore, all PLT-relative addresses remain in the generated purgatory
13
- object code unresolved. This in turn lets kexec-tools fail with
14
- "Unknown rela relocation: 0x14 0x73c0901c" for such relocation types.
15
-
16
- Furthermore, the clang C compiler has always behaved like described above
17
- and this commit should fix the purgatory code built with the latter.
18
-
19
- Because the purgatory code is no regular executable or shared library,
20
- contains only calls to local functions and has no PLT, all R_390_PLT32DBL
21
- relocation entries can be resolved just like a R_390_PC32DBL one.
22
-
23
- * https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1633.html#AEN1699
24
-
25
- Relocation entries of purgatory code generated with gcc 11.3
26
- ------------------------------------------------------------
27
-
28
- $ readelf -r purgatory/purgatory.o
29
-
30
- Relocation section '.rela.text' at offset 0x6e8 contains 27 entries:
31
- Offset Info Type Sym. Value Sym. Name + Addend
32
- 00000000000c 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
33
- 00000000001a 001000000014 R_390_PLT32DBL 0000000000000000 sha256_starts + 2
34
- 000000000030 001100000014 R_390_PLT32DBL 0000000000000000 sha256_update + 2
35
- 000000000046 001200000014 R_390_PLT32DBL 0000000000000000 sha256_finish + 2
36
- 000000000050 000300000013 R_390_PC32DBL 0000000000000000 .data + 102
37
- 00000000005a 001300000014 R_390_PLT32DBL 0000000000000000 memcmp + 2
38
- ...
39
- 000000000118 001600000014 R_390_PLT32DBL 0000000000000000 setup_arch + 2
40
- 00000000011e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
41
- 00000000012c 000f00000014 R_390_PLT32DBL 0000000000000000 verify_sha256_digest + 2
42
- 000000000142 001700000014 R_390_PLT32DBL 0000000000000000
43
- post_verification[...] + 2
44
-
45
- Relocation entries of purgatory code generated with gcc 11.2
46
- ------------------------------------------------------------
47
-
48
- $ readelf -r purgatory/purgatory.o
49
-
50
- Relocation section '.rela.text' at offset 0x6e8 contains 27 entries:
51
- Offset Info Type Sym. Value Sym. Name + Addend
52
- 00000000000e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
53
- 00000000001c 001000000013 R_390_PC32DBL 0000000000000000 sha256_starts + 2
54
- 000000000036 001100000013 R_390_PC32DBL 0000000000000000 sha256_update + 2
55
- 000000000048 001200000013 R_390_PC32DBL 0000000000000000 sha256_finish + 2
56
- 000000000052 000300000013 R_390_PC32DBL 0000000000000000 .data + 102
57
- 00000000005c 001300000013 R_390_PC32DBL 0000000000000000 memcmp + 2
58
- ...
59
- 00000000011a 001600000013 R_390_PC32DBL 0000000000000000 setup_arch + 2
60
- 000000000120 000300000013 R_390_PC32DBL 0000000000000000 .data + 122
61
- 000000000130 000f00000013 R_390_PC32DBL 0000000000000000 verify_sha256_digest + 2
62
- 000000000146 001700000013 R_390_PC32DBL 0000000000000000 post_verification[...] + 2
63
-
64
- Corresponding s390 kernel discussion:
65
- * https://lore.kernel.org/linux-s390/20211208105801.188140-1-egorenar@linux.ibm.com/T/#u
66
-
67
- Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
68
- Reported-by: Tao Liu <ltao@redhat.com>
69
- Suggested-by: Philipp Rudo <prudo@redhat.com>
70
- Reviewed-by: Philipp Rudo <prudo@redhat.com>
71
- [hca@linux.ibm.com: changed commit message as requested by Philipp Rudo]
72
- Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
73
- Signed-off-by: Simon Horman <horms@verge.net.au>
74
-
75
- diff --git a/kexec/arch/s390/kexec-elf-rel-s390.c b/kexec/arch/s390/kexec-elf-rel-s390.c
76
- index a5e1b73455785ae3bc3aa72b3beee13ae202e82f..91ba86a9991dad4271b834fc3b24861c40309e52 100644
77
- --- a/kexec/arch/s390/kexec-elf-rel-s390.c
78
- +++ b/kexec/arch/s390/kexec-elf-rel-s390.c
79
- @@ -56,6 +56,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr),
80
- case R_390_PC16: /* PC relative 16 bit. */
81
- case R_390_PC16DBL: /* PC relative 16 bit shifted by 1. */
82
- case R_390_PC32DBL: /* PC relative 32 bit shifted by 1. */
83
- + case R_390_PLT32DBL: /* 32 bit PC rel. PLT shifted by 1. */
84
- case R_390_PC32: /* PC relative 32 bit. */
85
- case R_390_PC64: /* PC relative 64 bit. */
86
- val -= address;
87
- @@ -63,7 +64,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr),
88
- *(unsigned short *) loc = val;
89
- else if (r_type == R_390_PC16DBL)
90
- *(unsigned short *) loc = val >> 1;
91
- - else if (r_type == R_390_PC32DBL)
92
- + else if (r_type == R_390_PC32DBL || r_type == R_390_PLT32DBL)
93
- *(unsigned int *) loc = val >> 1;
94
- else if (r_type == R_390_PC32)
95
- *(unsigned int *) loc = val;
kexec-tools-2.0.23-01-_PATCH_v2_1_3_add_generic_cycle_detection.patch DELETED
@@ -1,191 +0,0 @@
1
- commit feae3d1754d2b0788ce1f18b0cd4b40098ff52ff
2
- Author: Philipp Rudo <prudo@redhat.com>
3
- Date: Mon Mar 14 17:04:29 2022 +0100
4
-
5
- [PATCH v2 1/3] add generic cycle detection
6
-
7
- In order to work makedumpfile needs to interpret data read from the
8
- dump. This can cause problems as the data from the dump cannot be
9
- trusted (otherwise the kernel wouldn't have panicked in the first
10
- place). This also means that every loop which stop condition depend on
11
- data read from the dump has a chance to loop forever. Thus add a generic
12
- cycle detection mechanism that allows to detect and handle such
13
- situations appropriately.
14
-
15
- For cycle detection use Brent's algorithm [1] as it has constant memory
16
- usage. With this it can also be used in the kdump kernel without the
17
- danger that it runs oom when iterating large data structures.
18
- Furthermore it only depends on some pointer arithmetic. Thus the
19
- performance impact (as long as no cycle was detected) should be
20
- comparatively small.
21
-
22
- [1] https://en.wikipedia.org/wiki/Cycle_detection#Brent's_algorithm
23
-
24
- Suggested-by: Dave Wysochanski <dwysocha@redhat.com>
25
- Signed-off-by: Philipp Rudo <prudo@redhat.com>
26
- Reviewed-and-tested-by: Dave Wysochanski <dwysocha@redhat.com>
27
-
28
- diff --git a/makedumpfile-1.7.0/Makefile b/makedumpfile-1.7.0/Makefile
29
- index f118b31e45989d9590ae075fb9b8ed2f27353a92..3441364cb6c7103a20072bd50ec58f1eed01ab69 100644
30
- --- a/makedumpfile-1.7.0/Makefile
31
- +++ b/makedumpfile-1.7.0/Makefile
32
- @@ -45,7 +45,7 @@ CFLAGS_ARCH += -m32
33
- endif
34
-
35
- SRC_BASE = makedumpfile.c makedumpfile.h diskdump_mod.h sadump_mod.h sadump_info.h
36
- -SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c
37
- +SRC_PART = print_info.c dwarf_info.c elf_info.c erase_info.c sadump_info.c cache.c tools.c printk.c detect_cycle.c
38
- OBJ_PART=$(patsubst %.c,%.o,$(SRC_PART))
39
- SRC_ARCH = arch/arm.c arch/arm64.c arch/x86.c arch/x86_64.c arch/ia64.c arch/ppc64.c arch/s390x.c arch/ppc.c arch/sparc64.c arch/mips64.c
40
- OBJ_ARCH=$(patsubst %.c,%.o,$(SRC_ARCH))
41
- diff --git a/makedumpfile-1.7.0/detect_cycle.c b/makedumpfile-1.7.0/detect_cycle.c
42
- new file mode 100644
43
- index 0000000000000000000000000000000000000000..6b551a75d1c83d64fba2c078be8133efbc791fbe
44
- --- /dev/null
45
- +++ b/makedumpfile-1.7.0/detect_cycle.c
46
- @@ -0,0 +1,99 @@
47
- +/*
48
- + * detect_cycle.c -- Generic cycle detection using Brent's algorithm
49
- + *
50
- + * Created by: Philipp Rudo <prudo@redhat.com>
51
- + *
52
- + * Copyright (c) 2022 Red Hat, Inc. All rights reserved.
53
- + *
54
- + * This program is free software; you can redistribute it and/or modify
55
- + * it under the terms of the GNU General Public License as published by
56
- + * the Free Software Foundation; either version 2 of the License, or
57
- + * (at your option) any later version.
58
- + *
59
- + * This program is distributed in the hope that it will be useful,
60
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
61
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62
- + * GNU General Public License for more details.
63
- + */
64
- +
65
- +#include <stdlib.h>
66
- +
67
- +#include "detect_cycle.h"
68
- +
69
- +struct detect_cycle {
70
- + /* First entry of the list */
71
- + void *head;
72
- +
73
- + /* Variables required by Brent's algorithm */
74
- + void *fast_p;
75
- + void *slow_p;
76
- + unsigned long length;
77
- + unsigned long power;
78
- +
79
- + /* Function to get the next entry in the list */
80
- + dc_next_t next;
81
- +
82
- + /* Private data passed to next */
83
- + void *data;
84
- +};
85
- +
86
- +struct detect_cycle *dc_init(void *head, void *data, dc_next_t next)
87
- +{
88
- + struct detect_cycle *new;
89
- +
90
- + new = malloc(sizeof(*new));
91
- + if (!new)
92
- + return NULL;
93
- +
94
- + new->next = next;
95
- + new->data = data;
96
- +
97
- + new->head = head;
98
- + new->slow_p = head;
99
- + new->fast_p = head;
100
- + new->length = 0;
101
- + new->power = 2;
102
- +
103
- + return new;
104
- +}
105
- +
106
- +int dc_next(struct detect_cycle *dc, void **next)
107
- +{
108
- +
109
- + if (dc->length == dc->power) {
110
- + dc->length = 0;
111
- + dc->power *= 2;
112
- + dc->slow_p = dc->fast_p;
113
- + }
114
- +
115
- + dc->fast_p = dc->next(dc->fast_p, dc->data);
116
- + dc->length++;
117
- +
118
- + if (dc->slow_p == dc->fast_p)
119
- + return 1;
120
- +
121
- + *next = dc->fast_p;
122
- + return 0;
123
- +}
124
- +
125
- +void dc_find_start(struct detect_cycle *dc, void **first, unsigned long *len)
126
- +{
127
- + void *slow_p, *fast_p;
128
- + unsigned long tmp;
129
- +
130
- + slow_p = fast_p = dc->head;
131
- + tmp = dc->length;
132
- +
133
- + while (tmp) {
134
- + fast_p = dc->next(fast_p, dc->data);
135
- + tmp--;
136
- + }
137
- +
138
- + while (slow_p != fast_p) {
139
- + slow_p = dc->next(slow_p, dc->data);
140
- + fast_p = dc->next(fast_p, dc->data);
141
- + }
142
- +
143
- + *first = slow_p;
144
- + *len = dc->length;
145
- +}
146
- diff --git a/makedumpfile-1.7.0/detect_cycle.h b/makedumpfile-1.7.0/detect_cycle.h
147
- new file mode 100644
148
- index 0000000000000000000000000000000000000000..2ca75c78b59a98274fc5a98666b1be74f7bbfc2c
149
- --- /dev/null
150
- +++ b/makedumpfile-1.7.0/detect_cycle.h
151
- @@ -0,0 +1,40 @@
152
- +/*
153
- + * detect_cycle.h -- Generic cycle detection using Brent's algorithm
154
- + *
155
- + * Created by: Philipp Rudo <prudo@redhat.com>
156
- + *
157
- + * Copyright (c) 2022 Red Hat, Inc. All rights reserved.
158
- + *
159
- + * This program is free software; you can redistribute it and/or modify
160
- + * it under the terms of the GNU General Public License as published by
161
- + * the Free Software Foundation; either version 2 of the License, or
162
- + * (at your option) any later version.
163
- + *
164
- + * This program is distributed in the hope that it will be useful,
165
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
166
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
167
- + * GNU General Public License for more details.
168
- + */
169
- +
170
- +struct detect_cycle;
171
- +
172
- +typedef void *(*dc_next_t)(void *prev, void *data);
173
- +
174
- +/*
175
- + * Initialize cycle detection.
176
- + * Returns a pointer to allocated struct detect_cycle. The caller is
177
- + * responsible to free the memory after use.
178
- + */
179
- +struct detect_cycle *dc_init(void *head, void *data, dc_next_t next);
180
- +
181
- +/*
182
- + * Get next entry in the list using dc->next.
183
- + * Returns 1 when cycle was detected, 0 otherwise.
184
- + */
185
- +int dc_next(struct detect_cycle *dc, void **next);
186
- +
187
- +/*
188
- + * Get the start and length of the cycle. Must only be called after cycle was
189
- + * detected by dc_next.
190
- + */
191
- +void dc_find_start(struct detect_cycle *dc, void **first, unsigned long *len);
kexec-tools-2.0.23-01-s390_add_variable_command_line_size.patch DELETED
@@ -1,224 +0,0 @@
1
- commit defb80a20bf1e4d778596ce2447e19d44f31ae5a
2
- Author: Sven Schnelle <svens@linux.ibm.com>
3
- Date: Thu Dec 16 12:43:52 2021 +0100
4
-
5
- s390: add variable command line size
6
-
7
- Newer s390 kernels support a command line size longer than 896
8
- bytes. Such kernels contain a new member in the parameter area,
9
- which might be utilized by tools like kexec. Older kernels have
10
- the location initialized to zero, so we check whether there's a
11
- non-zero number present and use that. If there isn't, we fallback
12
- to the legacy command line size of 896 bytes.
13
-
14
- Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
15
- Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
16
- Signed-off-by: Simon Horman <horms@verge.net.au>
17
-
18
- diff --git a/kexec/arch/s390/crashdump-s390.c b/kexec/arch/s390/crashdump-s390.c
19
- index 10f4d607bbcc1aea362de3de687b0e7b2401d879..3bd9efe6dafebab2f364c656ae703c71c4494c35 100644
20
- --- a/kexec/arch/s390/crashdump-s390.c
21
- +++ b/kexec/arch/s390/crashdump-s390.c
22
- @@ -52,7 +52,8 @@ static int create_elf_header(struct kexec_info *info, unsigned long crash_base,
23
- elfcorehdr_size = bufsz;
24
- snprintf(str, sizeof(str), " elfcorehdr=%ld@%ldK\n",
25
- elfcorehdr_size, elfcorehdr / 1024);
26
- - command_line_add(str);
27
- + if (command_line_add(info, str))
28
- + return -1;
29
- #endif
30
- return 0;
31
- }
32
- diff --git a/kexec/arch/s390/kexec-image.c b/kexec/arch/s390/kexec-image.c
33
- index 3c24fdfe3c7ccafddee9fb4a68c0d8874cf6a61e..a52399eafd2abd4a24142f0512251598ea812ca5 100644
34
- --- a/kexec/arch/s390/kexec-image.c
35
- +++ b/kexec/arch/s390/kexec-image.c
36
- @@ -25,7 +25,6 @@
37
- #include <fcntl.h>
38
-
39
- static uint64_t crash_base, crash_end;
40
- -static char command_line[COMMAND_LINESIZE];
41
-
42
- static void add_segment_check(struct kexec_info *info, const void *buf,
43
- size_t bufsz, unsigned long base, size_t memsz)
44
- @@ -36,13 +35,18 @@ static void add_segment_check(struct kexec_info *info, const void *buf,
45
- add_segment(info, buf, bufsz, crash_base + base, memsz);
46
- }
47
-
48
- -int command_line_add(const char *str)
49
- +int command_line_add(struct kexec_info *info, const char *str)
50
- {
51
- - if (strlen(command_line) + strlen(str) + 1 > COMMAND_LINESIZE) {
52
- - fprintf(stderr, "Command line too long.\n");
53
- + char *tmp = NULL;
54
- +
55
- + tmp = concat_cmdline(info->command_line, str);
56
- + if (!tmp) {
57
- + fprintf(stderr, "out of memory\n");
58
- return -1;
59
- }
60
- - strcat(command_line, str);
61
- +
62
- + free(info->command_line);
63
- + info->command_line = tmp;
64
- return 0;
65
- }
66
-
67
- @@ -64,7 +68,7 @@ int image_s390_load_file(int argc, char **argv, struct kexec_info *info)
68
- while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
69
- switch(opt) {
70
- case OPT_APPEND:
71
- - if (command_line_add(optarg))
72
- + if (command_line_add(info, optarg))
73
- return -1;
74
- break;
75
- case OPT_RAMDISK:
76
- @@ -78,13 +82,16 @@ int image_s390_load_file(int argc, char **argv, struct kexec_info *info)
77
- if (info->initrd_fd == -1) {
78
- fprintf(stderr, "Could not open initrd file %s:%s\n",
79
- ramdisk, strerror(errno));
80
- + free(info->command_line);
81
- + info->command_line = NULL;
82
- return -1;
83
- }
84
- }
85
-
86
- - info->command_line = command_line;
87
- - info->command_line_len = strlen (command_line) + 1;
88
- -
89
- + if (info->command_line)
90
- + info->command_line_len = strlen(info->command_line) + 1;
91
- + else
92
- + info->command_line_len = 0;
93
- return 0;
94
- }
95
-
96
- @@ -97,7 +104,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
97
- const char *ramdisk;
98
- off_t ramdisk_len;
99
- unsigned int ramdisk_origin;
100
- - int opt;
101
- + int opt, ret = -1;
102
-
103
- if (info->file_mode)
104
- return image_s390_load_file(argc, argv, info);
105
- @@ -112,7 +119,6 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
106
- };
107
- static const char short_options[] = KEXEC_OPT_STR "";
108
-
109
- - command_line[0] = 0;
110
- ramdisk = NULL;
111
- ramdisk_len = 0;
112
- ramdisk_origin = 0;
113
- @@ -120,7 +126,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
114
- while ((opt = getopt_long(argc,argv,short_options,options,0)) != -1) {
115
- switch(opt) {
116
- case OPT_APPEND:
117
- - if (command_line_add(optarg))
118
- + if (command_line_add(info, optarg))
119
- return -1;
120
- break;
121
- case OPT_RAMDISK:
122
- @@ -132,7 +138,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
123
- if (info->kexec_flags & KEXEC_ON_CRASH) {
124
- if (parse_iomem_single("Crash kernel\n", &crash_base,
125
- &crash_end))
126
- - return -1;
127
- + goto out;
128
- }
129
-
130
- /* Add kernel segment */
131
- @@ -151,7 +157,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
132
- rd_buffer = slurp_file_mmap(ramdisk, &ramdisk_len);
133
- if (rd_buffer == NULL) {
134
- fprintf(stderr, "Could not read ramdisk.\n");
135
- - return -1;
136
- + goto out;
137
- }
138
- ramdisk_origin = MAX(RAMDISK_ORIGIN_ADDR, kernel_size);
139
- ramdisk_origin = _ALIGN_UP(ramdisk_origin, 0x100000);
140
- @@ -160,7 +166,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
141
- }
142
- if (info->kexec_flags & KEXEC_ON_CRASH) {
143
- if (load_crashdump_segments(info, crash_base, crash_end))
144
- - return -1;
145
- + goto out;
146
- } else {
147
- info->entry = (void *) IMAGE_READ_OFFSET;
148
- }
149
- @@ -183,15 +189,28 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
150
- *tmp = crash_end - crash_base + 1;
151
- }
152
- }
153
- - /*
154
- - * We will write a probably given command line.
155
- - * First, erase the old area, then setup the new parameters:
156
- - */
157
- - if (strlen(command_line) != 0) {
158
- - memset(krnl_buffer + COMMAND_LINE_OFFS, 0, COMMAND_LINESIZE);
159
- - memcpy(krnl_buffer + COMMAND_LINE_OFFS, command_line, strlen(command_line));
160
- +
161
- + if (info->command_line) {
162
- + unsigned long maxsize;
163
- + char *dest = krnl_buffer + COMMAND_LINE_OFFS;
164
- +
165
- + maxsize = *(unsigned long *)(krnl_buffer + MAX_COMMAND_LINESIZE_OFFS);
166
- + if (!maxsize)
167
- + maxsize = LEGACY_COMMAND_LINESIZE;
168
- +
169
- + if (strlen(info->command_line) > maxsize-1) {
170
- + fprintf(stderr, "command line too long, maximum allowed size %ld\n",
171
- + maxsize-1);
172
- + goto out;
173
- + }
174
- + strncpy(dest, info->command_line, maxsize-1);
175
- + dest[maxsize-1] = '\0';
176
- }
177
- - return 0;
178
- + ret = 0;
179
- +out:
180
- + free(info->command_line);
181
- + info->command_line = NULL;
182
- + return ret;
183
- }
184
-
185
- int
186
- diff --git a/kexec/arch/s390/kexec-s390.h b/kexec/arch/s390/kexec-s390.h
187
- index ef53b111e16719d15e5364c18435e272f98b9086..6a99518c1c9e411ed853489daf0de6463972ab6f 100644
188
- --- a/kexec/arch/s390/kexec-s390.h
189
- +++ b/kexec/arch/s390/kexec-s390.h
190
- @@ -10,16 +10,17 @@
191
- #ifndef KEXEC_S390_H
192
- #define KEXEC_S390_H
193
-
194
- -#define IMAGE_READ_OFFSET 0x10000
195
- +#define IMAGE_READ_OFFSET 0x10000
196
-
197
- -#define RAMDISK_ORIGIN_ADDR 0x800000
198
- -#define INITRD_START_OFFS 0x408
199
- -#define INITRD_SIZE_OFFS 0x410
200
- -#define OLDMEM_BASE_OFFS 0x418
201
- -#define OLDMEM_SIZE_OFFS 0x420
202
- -#define COMMAND_LINE_OFFS 0x480
203
- -#define COMMAND_LINESIZE 896
204
- -#define MAX_MEMORY_RANGES 1024
205
- +#define RAMDISK_ORIGIN_ADDR 0x800000
206
- +#define INITRD_START_OFFS 0x408
207
- +#define INITRD_SIZE_OFFS 0x410
208
- +#define OLDMEM_BASE_OFFS 0x418
209
- +#define OLDMEM_SIZE_OFFS 0x420
210
- +#define MAX_COMMAND_LINESIZE_OFFS 0x430
211
- +#define COMMAND_LINE_OFFS 0x480
212
- +#define LEGACY_COMMAND_LINESIZE 896
213
- +#define MAX_MEMORY_RANGES 1024
214
-
215
- #define MAX(x, y) ((x) > (y) ? (x) : (y))
216
- #define MIN(x, y) ((x) < (y) ? (x) : (y))
217
- @@ -32,6 +33,6 @@ extern int load_crashdump_segments(struct kexec_info *info,
218
- unsigned long crash_end);
219
- extern int get_memory_ranges_s390(struct memory_range range[], int *ranges,
220
- int with_crashk);
221
- -extern int command_line_add(const char *str);
222
- +extern int command_line_add(struct kexec_info *info, const char *str);
223
-
224
- #endif /* KEXEC_S390_H */
kexec-tools-2.0.23-02-_PATCH_v2_2_3_use_pointer_arithmetics_for_dump_dmesg.patch DELETED
@@ -1,102 +0,0 @@
1
- commit e1d2e5302b016c6f7942f46ffa27aa31326686c5
2
- Author: Philipp Rudo <prudo@redhat.com>
3
- Date: Mon Mar 14 17:04:30 2022 +0100
4
-
5
- [PATCH v2 2/3] use pointer arithmetics for dump_dmesg
6
-
7
- When parsing the printk buffer for the old printk mechanism (> v3.5.0+ and
8
- < 5.10.0) a log entry is currently specified by the offset into the
9
- buffer where the entry starts. Change this to use a pointers instead.
10
- This is done in preparation for using the new cycle detection mechanism.
11
-
12
- Signed-off-by: Philipp Rudo <prudo@redhat.com>
13
- Reviewed-and-tested-by: Dave Wysochanski <dwysocha@redhat.com>
14
- Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
15
-
16
- diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c
17
- index 7ed9756a8c43ae4a2b6770e86dc81763796c2187..e72dba219eec198ec865045562f39a14b5a092eb 100644
18
- --- a/makedumpfile-1.7.0/makedumpfile.c
19
- +++ b/makedumpfile-1.7.0/makedumpfile.c
20
- @@ -5482,13 +5482,10 @@ dump_log_entry(char *logptr, int fp, const char *file_name)
21
- * get log record by index; idx must point to valid message.
22
- */
23
- static char *
24
- -log_from_idx(unsigned int idx, char *logbuf)
25
- +log_from_ptr(char *logptr, char *logbuf)
26
- {
27
- - char *logptr;
28
- unsigned int msglen;
29
-
30
- - logptr = logbuf + idx;
31
- -
32
- /*
33
- * A length == 0 record is the end of buffer marker.
34
- * Wrap around and return the message at the start of
35
- @@ -5497,19 +5494,16 @@ log_from_idx(unsigned int idx, char *logbuf)
36
-
37
- msglen = USHORT(logptr + OFFSET(printk_log.len));
38
- if (!msglen)
39
- - logptr = logbuf;
40
- + return logbuf;
41
-
42
- return logptr;
43
- }
44
-
45
- -static long
46
- -log_next(unsigned int idx, char *logbuf)
47
- +static void *
48
- +log_next(void *logptr, void *logbuf)
49
- {
50
- - char *logptr;
51
- unsigned int msglen;
52
-
53
- - logptr = logbuf + idx;
54
- -
55
- /*
56
- * A length == 0 record is the end of buffer marker. Wrap around and
57
- * read the message at the start of the buffer as *this* one, and
58
- @@ -5519,10 +5513,10 @@ log_next(unsigned int idx, char *logbuf)
59
- msglen = USHORT(logptr + OFFSET(printk_log.len));
60
- if (!msglen) {
61
- msglen = USHORT(logbuf + OFFSET(printk_log.len));
62
- - return msglen;
63
- + return logbuf + msglen;
64
- }
65
-
66
- - return idx + msglen;
67
- + return logptr + msglen;
68
- }
69
-
70
- int
71
- @@ -5530,11 +5524,12 @@ dump_dmesg()
72
- {
73
- int log_buf_len, length_log, length_oldlog, ret = FALSE;
74
- unsigned long index, log_buf, log_end;
75
- - unsigned int idx, log_first_idx, log_next_idx;
76
- + unsigned int log_first_idx, log_next_idx;
77
- unsigned long long first_idx_sym;
78
- unsigned long log_end_2_6_24;
79
- unsigned log_end_2_6_25;
80
- char *log_buffer = NULL, *log_ptr = NULL;
81
- + char *ptr;
82
-
83
- /*
84
- * log_end has been changed to "unsigned" since linux-2.6.25.
85
- @@ -5681,13 +5676,13 @@ dump_dmesg()
86
- ERRMSG("Can't open output file.\n");
87
- goto out;
88
- }
89
- - idx = log_first_idx;
90
- - while (idx != log_next_idx) {
91
- - log_ptr = log_from_idx(idx, log_buffer);
92
- + ptr = log_buffer + log_first_idx;
93
- + while (ptr != log_buffer + log_next_idx) {
94
- + log_ptr = log_from_ptr(ptr, log_buffer);
95
- if (!dump_log_entry(log_ptr, info->fd_dumpfile,
96
- info->name_dumpfile))
97
- goto out;
98
- - idx = log_next(idx, log_buffer);
99
- + ptr = log_next(ptr, log_buffer);
100
- }
101
- if (!close_files_for_creating_dumpfile())
102
- goto out;
kexec-tools-2.0.23-02-s390_use_KEXEC_ALL_OPTIONS.patch DELETED
@@ -1,43 +0,0 @@
1
- commit 91a3d0e00a5c18ee9bdd2c6c03ac64a6471e2559
2
- Author: Sven Schnelle <svens@linux.ibm.com>
3
- Date: Thu Dec 16 12:43:53 2021 +0100
4
-
5
- s390: use KEXEC_ALL_OPTIONS
6
-
7
- KEXEC_ALL_OPTIONS could be used instead defining the same
8
- array several times. This makes code easier to maintain when
9
- new options are added.
10
-
11
- Suggested-by: Alexander Egorenkov <egorenar@linux.ibm.com>
12
- Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
13
- Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
14
- Signed-off-by: Simon Horman <horms@verge.net.au>
15
-
16
- diff --git a/kexec/arch/s390/kexec-image.c b/kexec/arch/s390/kexec-image.c
17
- index a52399eafd2abd4a24142f0512251598ea812ca5..209ab77ddccbd60f10989e2d9fc273324aefa76d 100644
18
- --- a/kexec/arch/s390/kexec-image.c
19
- +++ b/kexec/arch/s390/kexec-image.c
20
- @@ -57,10 +57,7 @@ int image_s390_load_file(int argc, char **argv, struct kexec_info *info)
21
-
22
- static const struct option options[] =
23
- {
24
- - KEXEC_OPTIONS
25
- - {"command-line", 1, 0, OPT_APPEND},
26
- - {"append", 1, 0, OPT_APPEND},
27
- - {"initrd", 1, 0, OPT_RAMDISK},
28
- + KEXEC_ALL_OPTIONS
29
- {0, 0, 0, 0},
30
- };
31
- static const char short_options[] = KEXEC_OPT_STR "";
32
- @@ -111,10 +108,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
33
-
34
- static const struct option options[] =
35
- {
36
- - KEXEC_OPTIONS
37
- - {"command-line", 1, 0, OPT_APPEND},
38
- - {"append", 1, 0, OPT_APPEND},
39
- - {"initrd", 1, 0, OPT_RAMDISK},
40
- + KEXEC_ALL_OPTIONS
41
- {0, 0, 0, 0},
42
- };
43
- static const char short_options[] = KEXEC_OPT_STR "";
kexec-tools-2.0.23-03-_PATCH_v2_3_3_use_cycle_detection_when_parsing_the_prink_log_buf.patch DELETED
@@ -1,118 +0,0 @@
1
- commit 68d120b30af5e930afafed81e79712af3c1a278c
2
- Author: Philipp Rudo <prudo@redhat.com>
3
- Date: Mon Mar 14 17:04:31 2022 +0100
4
-
5
- [PATCH v2 3/3] use cycle detection when parsing the prink log_buf
6
-
7
- The old printk mechanism (> v3.5.0 and < v5.10.0) had a fixed size
8
- buffer (log_buf) that contains all messages. The location for the next
9
- message is stored in log_next_idx. In case the log_buf runs full
10
- log_next_idx wraps around and starts overwriting old messages at the
11
- beginning of the buffer. The wraparound is denoted by a message with
12
- msg->len == 0.
13
-
14
- Following the behavior described above blindly in makedumpfile is
15
- dangerous as e.g. a memory corruption could overwrite (parts of) the
16
- log_buf. If the corruption adds a message with msg->len == 0 this leads
17
- to an endless loop when dumping the dmesg with makedumpfile appending
18
- the messages up to the corruption over and over again to the output file
19
- until file system is full. Fix this by using cycle detection and aboard
20
- once one is detected.
21
-
22
- While at it also verify that the index is within the log_buf and thus
23
- guard against corruptions with msg->len != 0.
24
-
25
- Reported-by: Audra Mitchell <aubaker@redhat.com>
26
- Suggested-by: Dave Wysochanski <dwysocha@redhat.com>
27
- Signed-off-by: Philipp Rudo <prudo@redhat.com>
28
- Reviewed-and-tested-by: Dave Wysochanski <dwysocha@redhat.com>
29
-
30
- diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c
31
- index e72dba219eec198ec865045562f39a14b5a092eb..2b94446b8f2ad513da060e15821544ae32e1a2c6 100644
32
- --- a/makedumpfile-1.7.0/makedumpfile.c
33
- +++ b/makedumpfile-1.7.0/makedumpfile.c
34
- @@ -15,6 +15,7 @@
35
- */
36
- #include "makedumpfile.h"
37
- #include "print_info.h"
38
- +#include "detect_cycle.h"
39
- #include "dwarf_info.h"
40
- #include "elf_info.h"
41
- #include "erase_info.h"
42
- @@ -5526,10 +5527,11 @@ dump_dmesg()
43
- unsigned long index, log_buf, log_end;
44
- unsigned int log_first_idx, log_next_idx;
45
- unsigned long long first_idx_sym;
46
- + struct detect_cycle *dc = NULL;
47
- unsigned long log_end_2_6_24;
48
- unsigned log_end_2_6_25;
49
- char *log_buffer = NULL, *log_ptr = NULL;
50
- - char *ptr;
51
- + char *ptr, *next_ptr;
52
-
53
- /*
54
- * log_end has been changed to "unsigned" since linux-2.6.25.
55
- @@ -5677,12 +5679,55 @@ dump_dmesg()
56
- goto out;
57
- }
58
- ptr = log_buffer + log_first_idx;
59
- + dc = dc_init(ptr, log_buffer, log_next);
60
- while (ptr != log_buffer + log_next_idx) {
61
- log_ptr = log_from_ptr(ptr, log_buffer);
62
- if (!dump_log_entry(log_ptr, info->fd_dumpfile,
63
- info->name_dumpfile))
64
- goto out;
65
- ptr = log_next(ptr, log_buffer);
66
- + if (dc_next(dc, (void **) &next_ptr)) {
67
- + unsigned long len;
68
- + int in_cycle;
69
- + char *first;
70
- +
71
- + /* Clear everything we have already written... */
72
- + ftruncate(info->fd_dumpfile, 0);
73
- + lseek(info->fd_dumpfile, 0, SEEK_SET);
74
- +
75
- + /* ...and only write up to the corruption. */
76
- + dc_find_start(dc, (void **) &first, &len);
77
- + ptr = log_buffer + log_first_idx;
78
- + in_cycle = FALSE;
79
- + while (len) {
80
- + log_ptr = log_from_ptr(ptr, log_buffer);
81
- + if (!dump_log_entry(log_ptr,
82
- + info->fd_dumpfile,
83
- + info->name_dumpfile))
84
- + goto out;
85
- + ptr = log_next(ptr, log_buffer);
86
- +
87
- + if (log_ptr == first)
88
- + in_cycle = TRUE;
89
- +
90
- + if (in_cycle)
91
- + len--;
92
- + }
93
- + ERRMSG("Cycle when parsing dmesg detected.\n");
94
- + ERRMSG("The printk log_buf is most likely corrupted.\n");
95
- + ERRMSG("log_buf = 0x%lx, idx = 0x%lx\n", log_buf, ptr - log_buffer);
96
- + close_files_for_creating_dumpfile();
97
- + goto out;
98
- + }
99
- + if (next_ptr < log_buffer ||
100
- + next_ptr > log_buffer + log_buf_len - SIZE(printk_log)) {
101
- + ERRMSG("Index outside log_buf detected.\n");
102
- + ERRMSG("The printk log_buf is most likely corrupted.\n");
103
- + ERRMSG("log_buf = 0x%lx, idx = 0x%lx\n", log_buf, ptr - log_buffer);
104
- + close_files_for_creating_dumpfile();
105
- + goto out;
106
- + }
107
- + ptr = next_ptr;
108
- }
109
- if (!close_files_for_creating_dumpfile())
110
- goto out;
111
- @@ -5692,6 +5737,7 @@ dump_dmesg()
112
- out:
113
- if (log_buffer)
114
- free(log_buffer);
115
- + free(dc);
116
-
117
- return ret;
118
- }
kexec-tools-2.0.23-03-add_slurp_proc_file_.patch DELETED
@@ -1,76 +0,0 @@
1
- commit 193e51deccc62544f6423eb5e5eefc8a23aad679
2
- Author: Sven Schnelle <svens@linux.ibm.com>
3
- Date: Thu Dec 16 12:43:54 2021 +0100
4
-
5
- add slurp_proc_file()
6
-
7
- slurp_file() cannot be used to read proc files, as they are returning
8
- a size of zero in stat(). Add a function slurp_proc_file() which is
9
- similar to slurp_file(), but doesn't require the size of the file to
10
- be known.
11
-
12
- Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
13
- Signed-off-by: Simon Horman <horms@verge.net.au>
14
-
15
- diff --git a/kexec/kexec.c b/kexec/kexec.c
16
- index f63b36b771eb95a93f07a7c286c4974a558aec8d..f3adac517161d448552a16fd79488c1df100d356 100644
17
- --- a/kexec/kexec.c
18
- +++ b/kexec/kexec.c
19
- @@ -1106,6 +1106,57 @@ static void remove_parameter(char *line, const char *param_name)
20
- }
21
- }
22
-
23
- +static ssize_t _read(int fd, void *buf, size_t count)
24
- +{
25
- + ssize_t ret, offset = 0;
26
- +
27
- + do {
28
- + ret = read(fd, buf + offset, count - offset);
29
- + if (ret < 0) {
30
- + if ((errno == EINTR) || (errno == EAGAIN))
31
- + continue;
32
- + return ret;
33
- + }
34
- + offset += ret;
35
- + } while (ret && offset < count);
36
- +
37
- + return offset;
38
- +}
39
- +
40
- +static char *slurp_proc_file(const char *filename, size_t *len)
41
- +{
42
- + ssize_t ret, startpos = 0;
43
- + unsigned int size = 64;
44
- + char *buf = NULL, *tmp;
45
- + int fd;
46
- +
47
- + fd = open(filename, O_RDONLY);
48
- + if (fd == -1)
49
- + return NULL;
50
- +
51
- + do {
52
- + size *= 2;
53
- + tmp = realloc(buf, size);
54
- + if (!tmp) {
55
- + free(buf);
56
- + return NULL;
57
- + }
58
- + buf = tmp;
59
- +
60
- + ret = _read(fd, buf + startpos, size - startpos);
61
- + if (ret < 0) {
62
- + free(buf);
63
- + return NULL;
64
- + }
65
- +
66
- + startpos += ret;
67
- +
68
- + } while(ret);
69
- +
70
- + *len = startpos;
71
- + return buf;
72
- +}
73
- +
74
- /*
75
- * Returns the contents of the current command line to be used with
76
- * --reuse-cmdline option. The function gets called from architecture specific
kexec-tools-2.0.23-04-_PATCH_print_error_when_reading_with_unsupported_compression.patch DELETED
@@ -1,150 +0,0 @@
1
- commit 5035c0821f07da3badda645cd0064d4b80e1667d
2
- Author: Philipp Rudo <prudo@redhat.com>
3
- Date: Mon Mar 14 17:04:32 2022 +0100
4
-
5
- [PATCH] print error when reading with unsupported compression
6
-
7
- Currently makedumpfile only checks if the required compression algorithm
8
- was enabled during build when compressing a dump but not when reading
9
- from one. This can lead to situations where, one version of makedumpfile
10
- creates the dump using a compression algorithm an other version of
11
- makedumpfile doesn't support. When the second version now tries to, e.g.
12
- extract the dmesg from the dump it will fail with an error similar to
13
-
14
- # makedumpfile --dump-dmesg vmcore dmesg.txt
15
- __vtop4_x86_64: Can't get a valid pgd.
16
- readmem: Can't convert a virtual address(ffffffff92e18284) to physical address.
17
- readmem: type_addr: 0, addr:ffffffff92e18284, size:390
18
- check_release: Can't get the address of system_utsname.
19
-
20
- makedumpfile Failed.
21
-
22
- That's because readpage_kdump_compressed{_parallel} does not return
23
- with an error if the page it is trying to read is compressed with an
24
- unsupported compression algorithm. Thus readmem copies random data from
25
- the (uninitialized) cachebuf to its caller and thus causing the error
26
- above.
27
-
28
- Fix this by checking if the required compression algorithm is supported
29
- in readpage_kdump_compressed{_parallel} and print a proper error message
30
- if it isn't.
31
-
32
- Reported-by: Dave Wysochanski <dwysocha@redhat.com>
33
- Signed-off-by: Philipp Rudo <prudo@redhat.com>
34
- Reviewed-and-tested-by: Dave Wysochanski <dwysocha@redhat.com>
35
- Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
36
-
37
- diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c
38
- index 2b94446b8f2ad513da060e15821544ae32e1a2c6..14556db15627617cb394bba85bb7ebec6b35fb34 100644
39
- --- a/makedumpfile-1.7.0/makedumpfile.c
40
- +++ b/makedumpfile-1.7.0/makedumpfile.c
41
- @@ -865,9 +865,13 @@ readpage_kdump_compressed(unsigned long long paddr, void *bufptr)
42
- ERRMSG("Uncompress failed: %d\n", ret);
43
- return FALSE;
44
- }
45
- + } else if ((pd.flags & DUMP_DH_COMPRESSED_LZO)) {
46
- #ifdef USELZO
47
- - } else if (info->flag_lzo_support
48
- - && (pd.flags & DUMP_DH_COMPRESSED_LZO)) {
49
- + if (!info->flag_lzo_support) {
50
- + ERRMSG("lzo compression unsupported\n");
51
- + return FALSE;
52
- + }
53
- +
54
- retlen = info->page_size;
55
- ret = lzo1x_decompress_safe((unsigned char *)buf, pd.size,
56
- (unsigned char *)bufptr, &retlen,
57
- @@ -876,9 +880,13 @@ readpage_kdump_compressed(unsigned long long paddr, void *bufptr)
58
- ERRMSG("Uncompress failed: %d\n", ret);
59
- return FALSE;
60
- }
61
- +#else
62
- + ERRMSG("lzo compression unsupported\n");
63
- + ERRMSG("Try `make USELZO=on` when building.\n");
64
- + return FALSE;
65
- #endif
66
- -#ifdef USESNAPPY
67
- } else if ((pd.flags & DUMP_DH_COMPRESSED_SNAPPY)) {
68
- +#ifdef USESNAPPY
69
-
70
- ret = snappy_uncompressed_length(buf, pd.size, (size_t *)&retlen);
71
- if (ret != SNAPPY_OK) {
72
- @@ -891,14 +899,22 @@ readpage_kdump_compressed(unsigned long long paddr, void *bufptr)
73
- ERRMSG("Uncompress failed: %d\n", ret);
74
- return FALSE;
75
- }
76
- +#else
77
- + ERRMSG("snappy compression unsupported\n");
78
- + ERRMSG("Try `make USESNAPPY=on` when building.\n");
79
- + return FALSE;
80
- #endif
81
- -#ifdef USEZSTD
82
- } else if ((pd.flags & DUMP_DH_COMPRESSED_ZSTD)) {
83
- +#ifdef USEZSTD
84
- ret = ZSTD_decompress(bufptr, info->page_size, buf, pd.size);
85
- if (ZSTD_isError(ret) || (ret != info->page_size)) {
86
- ERRMSG("Uncompress failed: %d\n", ret);
87
- return FALSE;
88
- }
89
- +#else
90
- + ERRMSG("zstd compression unsupported\n");
91
- + ERRMSG("Try `make USEZSTD=on` when building.\n");
92
- + return FALSE;
93
- #endif
94
- }
95
-
96
- @@ -964,9 +980,13 @@ readpage_kdump_compressed_parallel(int fd_memory, unsigned long long paddr,
97
- ERRMSG("Uncompress failed: %d\n", ret);
98
- return FALSE;
99
- }
100
- + } else if ((pd.flags & DUMP_DH_COMPRESSED_LZO)) {
101
- #ifdef USELZO
102
- - } else if (info->flag_lzo_support
103
- - && (pd.flags & DUMP_DH_COMPRESSED_LZO)) {
104
- + if (!info->flag_lzo_support) {
105
- + ERRMSG("lzo compression unsupported\n");
106
- + return FALSE;
107
- + }
108
- +
109
- retlen = info->page_size;
110
- ret = lzo1x_decompress_safe((unsigned char *)buf, pd.size,
111
- (unsigned char *)bufptr, &retlen,
112
- @@ -975,9 +995,13 @@ readpage_kdump_compressed_parallel(int fd_memory, unsigned long long paddr,
113
- ERRMSG("Uncompress failed: %d\n", ret);
114
- return FALSE;
115
- }
116
- +#else
117
- + ERRMSG("lzo compression unsupported\n");
118
- + ERRMSG("Try `make USELZO=on` when building.\n");
119
- + return FALSE;
120
- #endif
121
- -#ifdef USESNAPPY
122
- } else if ((pd.flags & DUMP_DH_COMPRESSED_SNAPPY)) {
123
- +#ifdef USESNAPPY
124
-
125
- ret = snappy_uncompressed_length(buf, pd.size, (size_t *)&retlen);
126
- if (ret != SNAPPY_OK) {
127
- @@ -990,14 +1014,22 @@ readpage_kdump_compressed_parallel(int fd_memory, unsigned long long paddr,
128
- ERRMSG("Uncompress failed: %d\n", ret);
129
- return FALSE;
130
- }
131
- +#else
132
- + ERRMSG("snappy compression unsupported\n");
133
- + ERRMSG("Try `make USESNAPPY=on` when building.\n");
134
- + return FALSE;
135
- #endif
136
- -#ifdef USEZSTD
137
- } else if ((pd.flags & DUMP_DH_COMPRESSED_ZSTD)) {
138
- +#ifdef USEZSTD
139
- ret = ZSTD_decompress(bufptr, info->page_size, buf, pd.size);
140
- if (ZSTD_isError(ret) || (ret != info->page_size)) {
141
- ERRMSG("Uncompress failed: %d\n", ret);
142
- return FALSE;
143
- }
144
- +#else
145
- + ERRMSG("zstd compression unsupported\n");
146
- + ERRMSG("Try `make USEZSTD=on` when building.\n");
147
- + return FALSE;
148
- #endif
149
- }
150
-
kexec-tools-2.0.23-04-use_slurp_proc_file_in_get_command_line_.patch DELETED
@@ -1,52 +0,0 @@
1
- commit d6516ba4c88f217fe14455db92c60cd0e9af18f8
2
- Author: Sven Schnelle <svens@linux.ibm.com>
3
- Date: Thu Dec 16 12:43:55 2021 +0100
4
-
5
- use slurp_proc_file() in get_command_line()
6
-
7
- This way the size of the command line that get_command_line() can handle
8
- is no longer fixed.
9
-
10
- Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
11
- Signed-off-by: Simon Horman <horms@verge.net.au>
12
-
13
- diff --git a/kexec/kexec.c b/kexec/kexec.c
14
- index f3adac517161d448552a16fd79488c1df100d356..7e4787bc821107b7af66ebdbcfc31f4e7e1d48cd 100644
15
- --- a/kexec/kexec.c
16
- +++ b/kexec/kexec.c
17
- @@ -1172,25 +1172,19 @@ static char *slurp_proc_file(const char *filename, size_t *len)
18
- */
19
- char *get_command_line(void)
20
- {
21
- - FILE *fp;
22
- - char *line;
23
- - const int sizeof_line = 2048;
24
- -
25
- - line = malloc(sizeof_line);
26
- - if (line == NULL)
27
- - die("Could not allocate memory to read /proc/cmdline.");
28
- -
29
- - fp = fopen("/proc/cmdline", "r");
30
- - if (!fp)
31
- - die("Could not open /proc/cmdline.");
32
- -
33
- - if (fgets(line, sizeof_line, fp) == NULL)
34
- - die("Can't read /proc/cmdline.");
35
- + char *p, *line;
36
- + size_t size;
37
-
38
- - fclose(fp);
39
- + line = slurp_proc_file("/proc/cmdline", &size);
40
- + if (!line || !size)
41
- + die("Failed to read /proc/cmdline\n");
42
-
43
- /* strip newline */
44
- - line[strlen(line) - 1] = '\0';
45
- + line[size-1] = '\0';
46
- +
47
- + p = strpbrk(line, "\r\n");
48
- + if (p)
49
- + *p = '\0';
50
-
51
- remove_parameter(line, "BOOT_IMAGE");
52
- if (kexec_flags & KEXEC_ON_CRASH)
kexec-tools-2.0.23-05-s390_add_support_for_reuse_cmdline.patch DELETED
@@ -1,75 +0,0 @@
1
- commit 2e1ec106dc5aac951ba884ebe4cca036e9a2d45f
2
- Author: Sven Schnelle <svens@linux.ibm.com>
3
- Date: Thu Dec 16 12:43:56 2021 +0100
4
-
5
- s390: add support for --reuse-cmdline
6
-
7
- --reuse-cmdline reads the command line of the currently
8
- running kernel from /proc/cmdline and uses that for the
9
- kernel that should be kexec'd.
10
-
11
- Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
12
- Reviewed-by: Alexander Egorenkov <egorenar@linux.ibm.com>
13
- Signed-off-by: Simon Horman <horms@verge.net.au>
14
-
15
- diff --git a/kexec/arch/s390/include/arch/options.h b/kexec/arch/s390/include/arch/options.h
16
- index 76044a301ceb3cca013f70dff330a8ad343d808a..c150244996c79165cf1e83e331f728432b752652 100644
17
- --- a/kexec/arch/s390/include/arch/options.h
18
- +++ b/kexec/arch/s390/include/arch/options.h
19
- @@ -1,9 +1,10 @@
20
- #ifndef KEXEC_ARCH_S390_OPTIONS_H
21
- #define KEXEC_ARCH_S390_OPTIONS_H
22
-
23
- -#define OPT_ARCH_MAX (OPT_MAX+0)
24
- -#define OPT_APPEND OPT_MAX+0
25
- -#define OPT_RAMDISK OPT_MAX+1
26
- +#define OPT_ARCH_MAX (OPT_MAX+0)
27
- +#define OPT_APPEND (OPT_MAX+0)
28
- +#define OPT_RAMDISK (OPT_MAX+1)
29
- +#define OPT_REUSE_CMDLINE (OPT_MAX+2)
30
-
31
- /* Options relevant to the architecture (excluding loader-specific ones),
32
- * in this case none:
33
- @@ -31,7 +32,8 @@
34
- KEXEC_ARCH_OPTIONS \
35
- {"command-line", 1, 0, OPT_APPEND}, \
36
- {"append", 1, 0, OPT_APPEND}, \
37
- - {"initrd", 1, 0, OPT_RAMDISK},
38
- + {"initrd", 1, 0, OPT_RAMDISK}, \
39
- + {"reuse-cmdline", 0, 0, OPT_REUSE_CMDLINE },
40
-
41
- #define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR
42
-
43
- diff --git a/kexec/arch/s390/kexec-image.c b/kexec/arch/s390/kexec-image.c
44
- index 209ab77ddccbd60f10989e2d9fc273324aefa76d..69aaf96812f741110bf323b4bb8d5dda155f293a 100644
45
- --- a/kexec/arch/s390/kexec-image.c
46
- +++ b/kexec/arch/s390/kexec-image.c
47
- @@ -71,6 +71,10 @@ int image_s390_load_file(int argc, char **argv, struct kexec_info *info)
48
- case OPT_RAMDISK:
49
- ramdisk = optarg;
50
- break;
51
- + case OPT_REUSE_CMDLINE:
52
- + free(info->command_line);
53
- + info->command_line = get_command_line();
54
- + break;
55
- }
56
- }
57
-
58
- @@ -123,6 +127,10 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,
59
- if (command_line_add(info, optarg))
60
- return -1;
61
- break;
62
- + case OPT_REUSE_CMDLINE:
63
- + free(info->command_line);
64
- + info->command_line = get_command_line();
65
- + break;
66
- case OPT_RAMDISK:
67
- ramdisk = optarg;
68
- break;
69
- @@ -223,5 +231,6 @@ image_s390_usage(void)
70
- printf("--command-line=STRING Set the kernel command line to STRING.\n"
71
- "--append=STRING Set the kernel command line to STRING.\n"
72
- "--initrd=FILENAME Use the file FILENAME as a ramdisk.\n"
73
- + "--reuse-cmdline Use kernel command line from running system.\n"
74
- );
75
- }
kexec-tools-2.0.23-05-util_lib_elf_info_harden_parsing_of_printk_buffer.patch DELETED
@@ -1,86 +0,0 @@
1
- commit f4c59879b830c7d574a953e6ce970ddaf20910d7
2
- Author: Philipp Rudo <prudo@redhat.com>
3
- Date: Wed Mar 23 16:35:36 2022 +0100
4
-
5
- util_lib/elf_info: harden parsing of printk buffer
6
-
7
- The old printk mechanism (> v3.5.0 and < v5.10.0) had a fixed size
8
- buffer (log_buf) that contains all messages. The location for the next
9
- message is stored in log_next_idx. In case the log_buf runs full
10
- log_next_idx wraps around and starts overwriting old messages at the
11
- beginning of the buffer. The wraparound is denoted by a message with
12
- msg->len == 0.
13
-
14
- Following the behavior described above blindly is dangerous as e.g. a
15
- memory corruption could overwrite (parts of) the log_buf. If the
16
- corruption adds a message with msg->len == 0 this leads to an endless
17
- loop when dumping the dmesg. Fix this by verifying that not wrapped
18
- around before when it encounters a message with msg->len == 0.
19
-
20
- While at it also verify that the index is within the log_buf and thus
21
- guard against corruptions with msg->len != 0.
22
-
23
- The same bug has been reported and fixed in makedumpfile [1].
24
-
25
- [1] http://lists.infradead.org/pipermail/kexec/2022-March/024272.html
26
-
27
- Signed-off-by: Philipp Rudo <prudo@redhat.com>
28
- Signed-off-by: Simon Horman <horms@verge.net.au>
29
-
30
- diff --git a/util_lib/elf_info.c b/util_lib/elf_info.c
31
- index d252eff5bd582837595a22aa387f53675c402121..ce71c6055c3a6ce8698d35960a8448be1dc8adc1 100644
32
- --- a/util_lib/elf_info.c
33
- +++ b/util_lib/elf_info.c
34
- @@ -763,8 +763,9 @@ static void dump_dmesg_structured(int fd, void (*handler)(char*, unsigned int))
35
- {
36
- #define OUT_BUF_SIZE 4096
37
- uint64_t log_buf, log_buf_offset, ts_nsec;
38
- - uint32_t log_first_idx, log_next_idx, current_idx, len = 0, i;
39
- + uint32_t log_buf_len, log_first_idx, log_next_idx, current_idx, len = 0, i;
40
- char *buf, out_buf[OUT_BUF_SIZE];
41
- + bool has_wrapped_around = false;
42
- ssize_t ret;
43
- char *msg;
44
- uint16_t text_len;
45
- @@ -811,6 +812,7 @@ static void dump_dmesg_structured(int fd, void (*handler)(char*, unsigned int))
46
- }
47
-
48
- log_buf = read_file_pointer(fd, vaddr_to_offset(log_buf_vaddr));
49
- + log_buf_len = read_file_s32(fd, vaddr_to_offset(log_buf_len_vaddr));
50
-
51
- log_first_idx = read_file_u32(fd, vaddr_to_offset(log_first_idx_vaddr));
52
- log_next_idx = read_file_u32(fd, vaddr_to_offset(log_next_idx_vaddr));
53
- @@ -882,11 +884,31 @@ static void dump_dmesg_structured(int fd, void (*handler)(char*, unsigned int))
54
- * and read the message at the start of the buffer.
55
- */
56
- loglen = struct_val_u16(buf, log_offset_len);
57
- - if (!loglen)
58
- + if (!loglen) {
59
- + if (has_wrapped_around) {
60
- + if (len && handler)
61
- + handler(out_buf, len);
62
- + fprintf(stderr, "Cycle when parsing dmesg detected.\n");
63
- + fprintf(stderr, "The prink log_buf is most likely corrupted.\n");
64
- + fprintf(stderr, "log_buf = 0x%lx, idx = 0x%x\n",
65
- + log_buf, current_idx);
66
- + exit(68);
67
- + }
68
- current_idx = 0;
69
- - else
70
- + has_wrapped_around = true;
71
- + } else {
72
- /* Move to next record */
73
- current_idx += loglen;
74
- + if(current_idx > log_buf_len - log_sz) {
75
- + if (len && handler)
76
- + handler(out_buf, len);
77
- + fprintf(stderr, "Index outside log_buf detected.\n");
78
- + fprintf(stderr, "The prink log_buf is most likely corrupted.\n");
79
- + fprintf(stderr, "log_buf = 0x%lx, idx = 0x%x\n",
80
- + log_buf, current_idx);
81
- + exit(69);
82
- + }
83
- + }
84
- }
85
- free(buf);
86
- if (len && handler)
kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch CHANGED
@@ -19,10 +19,10 @@
19
19
Reviewed-and-Tested-by: Philipp Rudo <prudo@redhat.com>
20
20
Reviewed-by: Pingfan Liu <piliu@redhat.com>
21
21
22
- diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c
22
+ diff --git a/makedumpfile-1.7.1/makedumpfile.c b/makedumpfile-1.7.1/makedumpfile.c
23
23
index a2f45c84cee3ba57ce3d3cf3f1905e6a03f4fd09..65d1c7c2f02c9ae8ead9de0f0217235fe72b3ca7 100644
24
- --- a/makedumpfile-1.7.0/makedumpfile.c
25
- +++ b/makedumpfile-1.7.0/makedumpfile.c
24
+ --- a/makedumpfile-1.7.1/makedumpfile.c
25
+ +++ b/makedumpfile-1.7.1/makedumpfile.c
26
26
@@ -3698,6 +3698,22 @@ validate_mem_section(unsigned long *mem_sec,
27
27
return ret;
28
28
}
kexec-tools-2.0.23-makedumpfile-sadump-kaslr-fix-failure-of-calculating-kaslr_.patch DELETED
@@ -1,49 +0,0 @@
1
- From 59b1726fbcc251155140c8a1972384498fee4daf Mon Sep 17 00:00:00 2001
2
- From: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
3
- Date: Tue, 25 Jan 2022 12:55:15 +0000
4
- Subject: [PATCH] [PATCH] sadump, kaslr: fix failure of calculating
5
- kaslr_offset
6
-
7
- On kernels v5.8 or later, makedumpfile fails for memory dumps in the
8
- sadump-related formats as follows:
9
-
10
- # makedumpfile -f -l -d 31 -x ./vmlinux /dev/sdd4 /root/vmcore-ld31
11
- __vtop4_x86_64: Can't get a valid pud_pte.
12
- ...110 lines of the same message...
13
- __vtop4_x86_64: Can't get a valid pud_pte.
14
- calc_kaslr_offset: failed to calculate kaslr_offset and phys_base; default to 0
15
- readmem: type_addr: 1, addr:ffffffff85411858, size:8
16
- __vtop4_x86_64: Can't get pgd (page_dir:ffffffff85411858).
17
- readmem: Can't convert a virtual address(ffffffff059be980) to physical address.
18
- readmem: type_addr: 0, addr:ffffffff059be980, size:1024
19
- cpu_online_mask_init: Can't read cpu_online_mask memory.
20
-
21
- makedumpfile Failed.
22
-
23
- This is caused by the kernel commit 9d06c4027f21 ("x86/entry: Convert
24
- Divide Error to IDTENTRY") that renamed divide_error to
25
- asm_exc_divide_error, breaking logic for calculating kaslr offset.
26
-
27
- Fix this by adding initialization of asm_exc_divide_error.
28
-
29
- Signed-off-by: HATAYAMA Daisuke <d.hatayama@fujitsu.com>
30
- ---
31
- makedumpfile.c | 2 ++
32
- 1 file changed, 2 insertions(+)
33
-
34
- diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c
35
- index a51bdaf..7ed9756 100644
36
- --- a/makedumpfile-1.7.0/makedumpfile.c
37
- +++ b/makedumpfile-1.7.0/makedumpfile.c
38
- @@ -1667,6 +1667,8 @@ get_symbol_info(void)
39
- SYMBOL_INIT(cur_cpu_spec, "cur_cpu_spec");
40
-
41
- SYMBOL_INIT(divide_error, "divide_error");
42
- + if (SYMBOL(divide_error) == NOT_FOUND_SYMBOL)
43
- + SYMBOL_INIT(divide_error, "asm_exc_divide_error");
44
- SYMBOL_INIT(idt_table, "idt_table");
45
- SYMBOL_INIT(saved_command_line, "saved_command_line");
46
- SYMBOL_INIT(pti_init, "pti_init");
47
- --
48
- 2.33.1
49
-
file modified
+3 -17
kexec-tools.spec CHANGED
@@ -4,8 +4,8 @@
4
4
%global mkdf_shortver %(c=%{mkdf_ver}; echo ${c:0:7})
5
5
6
6
Name: kexec-tools
7
- Version: 2.0.23
8
- Release: 10%{?dist}
7
+ Version: 2.0.24
8
+ Release: 1%{?dist}
9
9
License: GPLv2
10
10
Summary: The kexec/kdump userspace component
11
11
@@ -104,11 +104,6 @@ Requires: systemd-udev%{?_isa}
104
104
#
105
105
# Patches 401 through 500 are meant for s390 kexec-tools enablement
106
106
#
107
- Patch401: ./kexec-tools-2.0.23-01-s390_add_variable_command_line_size.patch
108
- Patch402: ./kexec-tools-2.0.23-02-s390_use_KEXEC_ALL_OPTIONS.patch
109
- Patch403: ./kexec-tools-2.0.23-03-add_slurp_proc_file_.patch
110
- Patch404: ./kexec-tools-2.0.23-04-use_slurp_proc_file_in_get_command_line_.patch
111
- Patch405: ./kexec-tools-2.0.23-05-s390_add_support_for_reuse_cmdline.patch
112
107
113
108
#
114
109
# Patches 501 through 600 are meant for ARM kexec-tools enablement
@@ -117,9 +112,7 @@ Patch405: ./kexec-tools-2.0.23-05-s390_add_support_for_reuse_cmdline.patch
117
112
#
118
113
# Patches 601 onward are generic patches
119
114
#
120
- Patch601: ./kexec-tools-2.0.22-01-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
115
+ Patch601: ./kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch
121
- Patch607: ./kexec-tools-2.0.23-05-util_lib_elf_info_harden_parsing_of_printk_buffer.patch
122
- Patch608: ./kexec-tools-2.0.23-makedumpfile-Avoid_false_positive_mem_section_validation_with_vmlinux.patch
123
116
124
117
%description
125
118
kexec-tools provides /sbin/kexec binary that facilitates a new
@@ -135,14 +128,7 @@ mkdir -p -m755 kcp
135
128
tar -z -x -v -f %{SOURCE9}
136
129
tar -z -x -v -f %{SOURCE19}
137
130
138
- %patch401 -p1
139
- %patch402 -p1
140
- %patch403 -p1
141
- %patch404 -p1
142
- %patch405 -p1
143
131
%patch601 -p1
144
- %patch607 -p1
145
- %patch608 -p1
146
132
147
133
%ifarch ppc
148
134
%define archdef ARCH=ppc
file modified
+1 -1
sources CHANGED
@@ -1,3 +1,3 @@
1
1
SHA512 (eppic-e8844d3.tar.gz) = d86b9f90c57e694107272d8f71b87f66a30743b9530480fb6f665026bbada4c6b0205a83e40b5383663a945681cfbfcf1ee79469fc219ddf679473c4b2290763
2
- SHA512 (kexec-tools-2.0.23.tar.xz) = b6e3b967cacc31c434b185d25da4d53c822ae4bbcec26ef9d6cb171f294fdcc80913d381e686a0a41e025187835f4dc088052ff88efe75a021d7624c8b1a1ed8
3
2
SHA512 (makedumpfile-1.7.1.tar.gz) = 93e36487b71f567d3685b151459806cf36017e52bf3ee68dd448382b279a422d1a8abef72e291ccb8206f2149ccd08ba484ec0027d1caab3fa1edbc3d28c3632
3
+ SHA512 (kexec-tools-2.0.24.tar.xz) = ef7cf78246e2d729d81a3649791a5a23c385353cc75cbe8ef279616329fdaccc876d614c7f51e1456822a13a11520296070d9897467d24310399909e049c3822