Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757217AbbKFGbJ (ORCPT ); Fri, 6 Nov 2015 01:31:09 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:4103 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750924AbbKFGbG (ORCPT ); Fri, 6 Nov 2015 01:31:06 -0500 From: Zhou Chengming To: , , , CC: , , , , , , Subject: [PATCH v2] livepatch: x86: bugfix about kASLR Date: Fri, 6 Nov 2015 14:25:00 +0800 Message-ID: <1446791100-41585-1-git-send-email-zhouchengming1@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.563C4925.00D7,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: f72b463ec828ddfe2d6ae75f4a2e28fd Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1189 Lines: 36 When enable KASLR, livepatch will adjust old_addr of changed function accordingly. So do the same thing for reloc. [PATCH v1] https://lkml.org/lkml/2015/11/4/91 Reported-by: Cyril B. Signed-off-by: Zhou Chengming --- kernel/livepatch/core.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 6e53441..db545cb 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -294,6 +294,12 @@ static int klp_write_object_relocations(struct module *pmod, for (reloc = obj->relocs; reloc->name; reloc++) { if (!klp_is_module(obj)) { + +#if defined(CONFIG_RANDOMIZE_BASE) + /* If KASLR has been enabled, adjust old value accordingly */ + if (kaslr_enabled()) + reloc->val += kaslr_offset(); +#endif ret = klp_verify_vmlinux_symbol(reloc->name, reloc->val); if (ret) -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/