From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Konrad Rzeszutek Wilk <konrad@kernel.org>,
xen-devel@lists.xenproject.org, julien.grall@arm.com,
sstabellini@kernel.org
Cc: jbeulich@suse.com
Subject: Re: [PATCH v2 3/5] xen/livepatch/ARM32: Don't load and crash on livepatches loaded with wrong alignment.
Date: Wed, 26 Jul 2017 23:27:37 +0100 [thread overview]
Message-ID: <77f98fa5-d14b-7f32-afd2-2d11563ae4ae@citrix.com> (raw)
In-Reply-To: <20170726194756.20265-4-konrad@kernel.org>
On 26/07/2017 20:47, Konrad Rzeszutek Wilk wrote:
> diff --git a/xen/arch/arm/arm64/livepatch.c b/xen/arch/arm/arm64/livepatch.c
> index 2247b925a0..7b36210ccd 100644
> --- a/xen/arch/arm/arm64/livepatch.c
> +++ b/xen/arch/arm/arm64/livepatch.c
> @@ -86,6 +86,12 @@ bool arch_livepatch_symbol_deny(const struct livepatch_elf *elf,
> return false;
> }
>
> +bool arch_livepatch_verify_alignment(const struct livepatch_elf_sec *sec)
> +{
Semantically, "verify_alignment" implies "the alignment is correct", but
the return value is the opposite.
I'd recommend inverting the sense of these functions, returning true for
x86/arm64, and == 0 for arm32...
> + /* Unaligned access on ARM 64 is OK. */
> + return false;
> +}
> +
> enum aarch64_reloc_op {
> RELOC_OP_NONE,
> RELOC_OP_ABS,
> diff --git a/xen/arch/x86/livepatch.c b/xen/arch/x86/livepatch.c
> index 406eb910cc..b3cbdac9b7 100644
> --- a/xen/arch/x86/livepatch.c
> +++ b/xen/arch/x86/livepatch.c
> @@ -148,6 +148,12 @@ bool arch_livepatch_symbol_deny(const struct livepatch_elf *elf,
> return false;
> }
>
> +bool arch_livepatch_verify_alignment(const struct livepatch_elf_sec *sec)
> +{
> + /* Unaligned access on x86 is fine. */
> + return false;
> +}
> +
> int arch_livepatch_perform_rel(struct livepatch_elf *elf,
> const struct livepatch_elf_sec *base,
> const struct livepatch_elf_sec *rela)
> diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
> index 40ff6b3a27..13d8f25a4b 100644
> --- a/xen/common/livepatch.c
> +++ b/xen/common/livepatch.c
> @@ -472,6 +472,13 @@ static int check_section(const struct livepatch_elf *elf,
> return -EINVAL;
> }
>
> + if ( arch_livepatch_verify_alignment(sec) )
> + {
> + dprintk(XENLOG_ERR, LIVEPATCH "%s: %s is not aligned properly!\n",
> + elf->name, sec->name);
It also means this would read as
if ( !arch_livepatch_verify_alignment(sec) )
{
"$blah not properly aligned"
which is also the usual way around to think.
(Also, bool functions and int functions really do have opposite success
cases, and should be kept that way.)
~Andrew
> + return -EINVAL;
> + }
> +
> return 0;
> }
>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-07-26 22:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-26 19:47 [PATCH v2] Livepatch fixes for v4.10 (v2) Konrad Rzeszutek Wilk
2017-07-26 19:47 ` [PATCH v2 1/5] livepatch: Tighten alignment checks Konrad Rzeszutek Wilk
2017-07-31 13:46 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 2/5] livepatch: Include sizes when an mismatch occurs Konrad Rzeszutek Wilk
2017-07-31 13:51 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 3/5] xen/livepatch/ARM32: Don't load and crash on livepatches loaded with wrong alignment Konrad Rzeszutek Wilk
2017-07-26 22:27 ` Andrew Cooper [this message]
2017-07-31 13:55 ` Jan Beulich
2017-07-31 16:04 ` Konrad Rzeszutek Wilk
2017-08-02 9:20 ` Jan Beulich
2017-09-07 17:36 ` Konrad Rzeszutek Wilk
2017-09-08 9:30 ` Jan Beulich
2017-09-09 12:05 ` Konrad Rzeszutek Wilk
2017-09-11 9:01 ` Jan Beulich
2017-09-12 0:22 ` Konrad Rzeszutek Wilk
2017-09-12 8:57 ` Jan Beulich
2017-09-18 19:37 ` Konrad Rzeszutek Wilk
2017-09-19 15:04 ` Jan Beulich
2017-09-20 15:12 ` Konrad Rzeszutek Wilk
2017-09-20 15:51 ` Jan Beulich
2017-07-26 19:47 ` [PATCH v2 4/5] alternative/x86/arm32: Align altinstructions (and altinstr_replacement) sections Konrad Rzeszutek Wilk
2017-07-31 14:01 ` Jan Beulich
2017-09-11 18:59 ` Konrad Rzeszutek Wilk
2017-07-26 19:47 ` [PATCH v2 5/5] livepatch: Declare live patching as a supported feature Konrad Rzeszutek Wilk
2017-07-31 14:03 ` Jan Beulich
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=77f98fa5-d14b-7f32-afd2-2d11563ae4ae@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=julien.grall@arm.com \
--cc=konrad@kernel.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).