From: Cheng Jian <cj.chengjian@huawei.com>
To: <linux-kernel@vger.kernel.org>, <live-patching@vger.kernel.org>
Cc: <jpoimboe@redhat.com>, <tglx@linutronix.de>, <mingo@redhat.com>,
<cj.chengjian@huawei.com>, <huawei.libin@huawei.com>,
<xiexiuqi@huawei.com>, <yangyingliang@huawei.com>,
<bobo.shaobowang@huawei.com>
Subject: [PATCH] Revert "x86/module: Detect and skip invalid relocations"
Date: Thu, 20 Jun 2019 16:24:28 +0800 [thread overview]
Message-ID: <1561019068-132672-1-git-send-email-cj.chengjian@huawei.com> (raw)
This reverts commit eda9cec4c9a12208a6f69fbe68f72a6311d50032.
Since commit (eda9cec4c9a1 'x86/module: Detect and skip invalid
relocations') add some sanity check in apply_relocate_add, borke
re-insmod a kernel module which has been patched before,
The relocation informations of the livepatch module have been
overwritten since first patched, so if we rmmod and insmod the
kernel module, these values are not zero anymore, when
klp_module_coming doing, and that commit marks them as invalid
invalid_relocation.
Then the following error occurs:
module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 2, loc (____ptrval____), val ffffffffc000236c
livepatch: failed to initialize patch 'livepatch_0001_test' for module 'test' (-8)
livepatch: patch 'livepatch_0001_test' failed for module 'test', refusing to load module 'test'
To fix this, just revert that commit.
Signed-off-by: Cheng Jian <cj.chengjian@huawei.com>
---
arch/x86/kernel/module.c | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index d5c72cb..3eb23a8 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -160,28 +160,20 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
case R_X86_64_NONE:
break;
case R_X86_64_64:
- if (*(u64 *)loc != 0)
- goto invalid_relocation;
*(u64 *)loc = val;
break;
case R_X86_64_32:
- if (*(u32 *)loc != 0)
- goto invalid_relocation;
*(u32 *)loc = val;
if (val != *(u32 *)loc)
goto overflow;
break;
case R_X86_64_32S:
- if (*(s32 *)loc != 0)
- goto invalid_relocation;
*(s32 *)loc = val;
if ((s64)val != *(s32 *)loc)
goto overflow;
break;
case R_X86_64_PC32:
case R_X86_64_PLT32:
- if (*(u32 *)loc != 0)
- goto invalid_relocation;
val -= (u64)loc;
*(u32 *)loc = val;
#if 0
@@ -190,8 +182,6 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
#endif
break;
case R_X86_64_PC64:
- if (*(u64 *)loc != 0)
- goto invalid_relocation;
val -= (u64)loc;
*(u64 *)loc = val;
break;
@@ -203,11 +193,6 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
}
return 0;
-invalid_relocation:
- pr_err("x86/modules: Skipping invalid relocation target, existing value is nonzero for type %d, loc %p, val %Lx\n",
- (int)ELF64_R_TYPE(rel[i].r_info), loc, val);
- return -ENOEXEC;
-
overflow:
pr_err("overflow in relocation type %d val %Lx\n",
(int)ELF64_R_TYPE(rel[i].r_info), val);
--
2.7.4
next reply other threads:[~2019-06-20 8:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 8:24 Cheng Jian [this message]
2019-06-20 8:33 ` [PATCH] Revert "x86/module: Detect and skip invalid relocations" Miroslav Benes
2019-06-22 7:28 ` Thomas Gleixner
2019-06-24 10:00 ` Miroslav Benes
2019-06-25 3:31 ` Josh Poimboeuf
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=1561019068-132672-1-git-send-email-cj.chengjian@huawei.com \
--to=cj.chengjian@huawei.com \
--cc=bobo.shaobowang@huawei.com \
--cc=huawei.libin@huawei.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=xiexiuqi@huawei.com \
--cc=yangyingliang@huawei.com \
/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