Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Korty <joe.korty@concurrent-rt.com>
To: Simon Horman <horms@verge.net.au>
Cc: kexec@lists.infradead.org, Eric Biederman <ebiederm@xmission.com>,
	Khalid Aziz <khalid@gonehiking.org>,
	Hariprasad Nellitheertha <hari@in.ibm.com>,
	Tim Deegan <tjd21@cl.cam.ac.uk>,
	Hongyan Xia <hongyxia@amazon.com>,
	David Hildenbrand <david@redhat.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH] kexec-tools: fix failure when kernel version patchlevel >255
Date: Fri, 9 Apr 2021 11:46:42 -0400	[thread overview]
Message-ID: <20210409154642.GA30739@zipoli.concurrrent-rt.com> (raw)

[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

             reply	other threads:[~2021-04-09 15:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 15:46 Joe Korty [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210409154642.GA30739@zipoli.concurrrent-rt.com \
    --to=joe.korty@concurrent-rt.com \
    --cc=david@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=geert+renesas@glider.be \
    --cc=hari@in.ibm.com \
    --cc=hongyxia@amazon.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=khalid@gonehiking.org \
    --cc=tjd21@cl.cam.ac.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox