Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Liu Tao <ltao@redhat.com>
Cc: Greg KH <gregkh@linuxfoundation.org>, Baoquan He <bhe@redhat.com>,
	Patrick Sung <patricksung@gmail.com>,
	sashal@kernel.org, kexec@lists.infradead.org,
	RuiRui Yang <dyoung@redhat.com>,
	horms@verge.net.au
Subject: Re: kexec does not work for kernel version with patch level >= 256
Date: Wed, 07 Apr 2021 12:23:25 -0500	[thread overview]
Message-ID: <m1sg42ggaa.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <CAO7dBbU=Q7yMKv-Hp8cUxgPffE=vxtKYvfP7NLKejf-Q8x+H=w@mail.gmail.com> (Liu Tao's message of "Tue, 6 Apr 2021 18:45:37 +0800")

Liu Tao <ltao@redhat.com> writes:

> Hello Eric,
>
> Please correct me if I'm wrong. After my research, I found that the
> KERNEL_VERSION
> check cannot be removed.
>
> In x86_64 case, function get_kernel_page_offset set different hard coded
> values into
> elf_info->page_offset according to KERNEL_VERSION, then in function
> get_kernel_vaddr_and_size,
> elf_info->page_offset gets refreshed by reading program segments of
> /proc/kcore.
> The refresh can fail when KASLR is off, thus the hard coded values are
> still needed as pre-set
> default values.

I see that the code is conditional upon KASLR, but I don't see any
particular reason why the code in get_kernel_vaddr_and_size is
conditional upon KASLR.

Skimming through arch/x86/kernel/vmlinux.lds.S and fs/proc/kcore.c I
don't see anything that is ASLR specific.  So everything should work
simply by removing the unnecessary gate on the presence of the
page_address_base symbol.

I suspect the code will even correctly compute PAGE_OFFSET on all
architectures, but we don't need to go that far to remove our use of the
kernel version.

> In addition, If I set a wrong value in elf_info->page_offset, readelf -l
> vmcore will give the value I set,
> reading symbols in crash-utility is not affected.

Especially if the reading the symbols is not affected by a wrong value
just auto-detecting the value really seems to make the most sense.

> From my point of view, extending the patch number from 8bit to 16bit is the
> solution. Any thoughts?

My thought is that in general the kernel version can not be depended
upon for anything as there exist enterprise kernels that get feature
backports.  So there very easily could be a kernel where the kernel
version does not accurately reflect what is going on.  So unless we can
say with certainty that there is no other way to detect the base address
of the kernel we really don't want to use the kernel version.

Right now it just looks like one all that is necessary is the removal of
an unnecessary if check.

Eric

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

      parent reply	other threads:[~2021-04-07 17:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24  4:28 kexec does not work for kernel version with patch level >= 256 Patrick Sung
2021-03-31  2:47 ` Baoquan He
2021-03-31  3:04   ` Patrick Sung
2021-03-31  3:48     ` Baoquan He
2021-03-31  8:03       ` Baoquan He
2021-03-31  8:10         ` Greg KH
2021-03-31 14:05           ` Eric W. Biederman
     [not found]             ` <CAO7dBbWPcjOTcugLkpV9S9uOEhetCg=MiW=xDbAX4EAotBMOHg@mail.gmail.com>
2021-04-01 17:50               ` Eric W. Biederman
     [not found]                 ` <CAO7dBbU=Q7yMKv-Hp8cUxgPffE=vxtKYvfP7NLKejf-Q8x+H=w@mail.gmail.com>
2021-04-07 17:23                   ` Eric W. Biederman [this message]

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=m1sg42ggaa.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=bhe@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    --cc=ltao@redhat.com \
    --cc=patricksung@gmail.com \
    --cc=sashal@kernel.org \
    /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