From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71F0BC3815B for ; Mon, 20 Apr 2020 19:51:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4F3122084D for ; Mon, 20 Apr 2020 19:51:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bCQSCeE3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726294AbgDTTvV (ORCPT ); Mon, 20 Apr 2020 15:51:21 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:26780 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725897AbgDTTvU (ORCPT ); Mon, 20 Apr 2020 15:51:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587412279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TWPS8Ag7vK66l0A1WZiPeQ8HRASExb1Zd/J41NjFSx4=; b=bCQSCeE3kHWNQt8EjEIlXUABatiKDng0YkWPgQjhJCwbSbt7Is0qOK+UMgeye1lBghBeYu fNhn+jMhwGTZqegR9qN8OVmz1LC3LQkMQv+tzXmoyvblYAhjuVfgEGTEx7TXuytF6VB6T/ hfpLGjyUZb05n6iCZ8ExwcNbmeDoIio= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-32-C1aiVMz-M62ucoynYrtO3A-1; Mon, 20 Apr 2020 15:51:17 -0400 X-MC-Unique: C1aiVMz-M62ucoynYrtO3A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7F4E1922020; Mon, 20 Apr 2020 19:51:16 +0000 (UTC) Received: from treble (ovpn-118-158.rdu2.redhat.com [10.10.118.158]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B98FB9A253; Mon, 20 Apr 2020 19:51:13 +0000 (UTC) Date: Mon, 20 Apr 2020 14:51:11 -0500 From: Josh Poimboeuf To: Joe Lawrence Cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Jessica Yu Subject: Re: [PATCH v2 2/9] livepatch: Apply vmlinux-specific KLP relocations early Message-ID: <20200420195111.ob7jnhs7wqp6d56g@treble> References: <83eb0be61671eab05e2d7bcd0aa848f6e20087b0.1587131959.git.jpoimboe@redhat.com> <20200420175751.GA13807@redhat.com> <20200420182516.6awwwbvoen62gwbr@treble> <20200420190141.GB13807@redhat.com> <20200420191117.wrjauayeutkpvkwd@treble> <20200420194900.GC13807@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200420194900.GC13807@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: live-patching-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: live-patching@vger.kernel.org On Mon, Apr 20, 2020 at 03:49:00PM -0400, Joe Lawrence wrote: > On Mon, Apr 20, 2020 at 02:11:17PM -0500, Josh Poimboeuf wrote: > > On Mon, Apr 20, 2020 at 03:01:41PM -0400, Joe Lawrence wrote: > > > > > ... apply_relocations() is also iterating over the section headers (the > > > > > diff context doesn't show it here, but i is an incrementing index over > > > > > sechdrs[]). > > > > > > > > > > So if there is more than one KLP relocation section, we'll process them > > > > > multiple times. At least the x86 relocation code will detect this and > > > > > fail the module load with an invalid relocation (existing value not > > > > > zero). > > > > > > > > Ah, yes, good catch! > > > > > > > > > > The same test case passed with a small modification to push the foreach > > > KLP section part to a kernel/livepatch/core.c local function and > > > exposing the klp_resolve_symbols() + apply_relocate_add() for a given > > > section to kernel/module.c. Something like following... > > > > I came up with something very similar, though I named them > > klp_apply_object_relocs() and klp_apply_section_relocs() and changed the > > argument order a bit (module first). Since it sounds like you have a > > test, could you try this one? > > > > LGTM. I have a few klp-convert selftests that I've been slowly > tinkering on and they all load/run successfully with this version. :) Good to hear, thanks! Hooray selftests :-) -- Josh