Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec-tools: fix failure when kernel version patchlevel >255
@ 2021-04-09 15:46 Joe Korty
  2021-04-09 16:22 ` [CFT][PATCH] kexec: Remove the error prone kernel_version function Eric W. Biederman
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Korty @ 2021-04-09 15:46 UTC (permalink / raw)
  To: Simon Horman
  Cc: kexec, Eric Biederman, Khalid Aziz, Hariprasad Nellitheertha,
	Tim Deegan, Hongyan Xia, David Hildenbrand, Geert Uytterhoeven

[PATCH] kexec-tools: fix kexec failure when kernel version patchlevel >255

[ 2nd try, to a larger cc: list, and this time submitted
  with a patch rather than just a bug report   ]

Kexec blows up when the kernel version patchlevel is >255.
This was first noticed when a 4.4.262 kernel was booted
on a CentOS 7 system.  The message on the console is of
the form:

  Unsupported utsname.release: 4.4.262

The attached patch should fix this.  Untested.  There might
be a few places where a hardcoded constant rather than
KERNEL_VERSION is used, but I did not see any.

Signed-off-by: Joe Korty <joe.korty@concurrent-rt.com

diff --git a/kexec/kernel_version.c b/kexec/kernel_version.c
index 21fb13adf095..36c06ffd603d 100644
--- a/kexec/kernel_version.c
+++ b/kexec/kernel_version.c
@@ -47,7 +47,7 @@ long kernel_version(void)
 		patch = 0;
 	}
 
-	if (major >= 256 || minor >= 256 || patch >= 256) {
+	if (major >= 256 || minor >= 256 || patch >= 65536) {
 		fprintf(stderr, "Unsupported utsname.release: %s\n",
 			utsname.release);
 		return -1;
diff --git a/kexec/kexec.h b/kexec/kexec.h
index f0f347d5e9e0..b388475ffa5a 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -180,7 +180,7 @@ extern const struct arch_map_entry arches[];
 long physical_arch(void);
 
 #define KERNEL_VERSION(major, minor, patch) \
-	(((major) << 16) | ((minor) << 8) | patch)
+	(((major) << 24) | ((minor) << 16) | patch)
 long kernel_version(void);
 
 void usage(void);

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-17  7:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-09 15:46 [PATCH] kexec-tools: fix failure when kernel version patchlevel >255 Joe Korty
2021-04-09 16:22 ` [CFT][PATCH] kexec: Remove the error prone kernel_version function Eric W. Biederman
2021-04-12 17:24   ` Joe Korty
2021-04-17  7:18     ` Simon Horman
2021-04-14  8:39   ` Tao Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox