Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1140053pxb; Wed, 16 Feb 2022 11:56:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwMhIokEbzB0gkskKvMJ7WI4pclHmPj0QPc8RQBgSkNceUmB+udwTeb5sJMek+v3c7WTEbV X-Received: by 2002:a05:6402:4243:b0:412:32f0:c5a with SMTP id g3-20020a056402424300b0041232f00c5amr4249040edb.266.1645041386627; Wed, 16 Feb 2022 11:56:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645041386; cv=none; d=google.com; s=arc-20160816; b=oJoOyB8BFrAmW3bU7BlLMdw0uzomxEkGOVKMfCBpuantH9RJWwATkLNJybaylAnPu2 hyNfStjerDObgeMRRtaj7mA0zZFXKjKXKAs7L0A2PasPryCfXSPK9H7LP6wmS/Hyujes eOu8kJnwduzp6cKv3NUYQJt7h3O2kMV4aFri2ebo+UueIsM+2nycb7cmpG+li6PzRtvH ftnIkuoOVCX1GXi30hMRGbvL3g3VhDUkhyIl/Bwa0eyVVDUbRl1oRDn6VDLsHM+9hjdQ giY4LenDNtgz76vPZtEvAxnPBPQ12pXF95Go6+ulcq7ERPcRPAc6bxrl5UlybZk8kEKb TSVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=UnLsFu3vyZphxwHHHdwxMjSDYtO6CMRyLJ43oelKoN0=; b=mVB/Xty2lYLOJ76zQ447/e/O2Xwe3t7Usze/fjxKEZP/eY0MMywKuxkmUQaaEZKkFX dQNv911DkkJ3Us4oO3d1/MED/dSUCrW27ZPNKiC5IJOcAHbbzQf59+rQ0XR5tjeVO08B uymkDOyrH8ElEoCE4zxbr7GawcZi6DRVWQa1Tk2t8ye+F+P6zgr4FXzPDO6LiJN0Kj0i pDZ5Llx/yJq3Y6Zdo5w6zWODHyLmw/VkK/CjqpcxwUu3rOrCEi23Ybegds8tcZl5ZkM4 CQH3bob/G31qNy1RDzeXxycN2qkOpdsyNtimJCWqOA7ux6Bg3TdkGp91ArCLQVQhasSL J+Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MNxvegHn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb3si550744ejc.287.2022.02.16.11.56.03; Wed, 16 Feb 2022 11:56:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MNxvegHn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236509AbiBPQkB (ORCPT + 99 others); Wed, 16 Feb 2022 11:40:01 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236489AbiBPQj6 (ORCPT ); Wed, 16 Feb 2022 11:39:58 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4D0D825BD74 for ; Wed, 16 Feb 2022 08:39:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645029585; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UnLsFu3vyZphxwHHHdwxMjSDYtO6CMRyLJ43oelKoN0=; b=MNxvegHnSH7zjw/jm0nyqxBjk+iNVstYzT7DLTlGwg4roQeRriDRxQrwimRz2qJ8zydq7Q NAX7lVTmjHCWszdnESK5CyuwdgcX31+8PuPC+BsQi76EmHGxr4hHzNwhsMLItgRPbcUcOD uUmpUBvNXbiGPUBTA/FaxGGUu5d2s+8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-45-zP8iqoRqOky-XyakbyFxsg-1; Wed, 16 Feb 2022 11:39:44 -0500 X-MC-Unique: zP8iqoRqOky-XyakbyFxsg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 045F980D680; Wed, 16 Feb 2022 16:39:43 +0000 (UTC) Received: from jlaw-desktop.redhat.com (unknown [10.22.8.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86B3D753CD; Wed, 16 Feb 2022 16:39:42 +0000 (UTC) From: Joe Lawrence To: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [RFC PATCH v6 01/12] livepatch: Create and include UAPI headers Date: Wed, 16 Feb 2022 11:39:29 -0500 Message-Id: <20220216163940.228309-2-joe.lawrence@redhat.com> In-Reply-To: <20220216163940.228309-1-joe.lawrence@redhat.com> References: <20220216163940.228309-1-joe.lawrence@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josh Poimboeuf Define klp prefixes in include/uapi/linux/livepatch.h, and use them for replacing hard-coded values in kernel/livepatch/core.c. Update MAINTAINERS. Note: Add defines to uapi as these are also to be used by a newly introduced klp-convert script. Signed-off-by: Josh Poimboeuf Signed-off-by: Joao Moreira Signed-off-by: Joe Lawrence --- MAINTAINERS | 1 + include/linux/livepatch.h | 1 + include/uapi/linux/livepatch.h | 15 +++++++++++++++ kernel/livepatch/core.c | 4 ++-- 4 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 include/uapi/linux/livepatch.h diff --git a/MAINTAINERS b/MAINTAINERS index f41088418aae..3fce79715663 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11132,6 +11132,7 @@ F: arch/powerpc/include/asm/livepatch.h F: arch/s390/include/asm/livepatch.h F: arch/x86/include/asm/livepatch.h F: include/linux/livepatch.h +F: include/uapi/linux/livepatch.h F: kernel/livepatch/ F: lib/livepatch/ F: samples/livepatch/ diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h index 2614247a9781..0fb05aae091a 100644 --- a/include/linux/livepatch.h +++ b/include/linux/livepatch.h @@ -13,6 +13,7 @@ #include #include #include +#include #if IS_ENABLED(CONFIG_LIVEPATCH) diff --git a/include/uapi/linux/livepatch.h b/include/uapi/linux/livepatch.h new file mode 100644 index 000000000000..e19430918a07 --- /dev/null +++ b/include/uapi/linux/livepatch.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ + +/* + * livepatch.h - Kernel Live Patching Core + * + * Copyright (C) 2016 Josh Poimboeuf + */ + +#ifndef _UAPI_LIVEPATCH_H +#define _UAPI_LIVEPATCH_H + +#define KLP_RELA_PREFIX ".klp.rela." +#define KLP_SYM_PREFIX ".klp.sym." + +#endif /* _UAPI_LIVEPATCH_H */ diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 585494ec464f..79b380777a0b 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -227,7 +227,7 @@ static int klp_resolve_symbols(Elf64_Shdr *sechdrs, const char *strtab, /* Format: .klp.sym.sym_objname.sym_name,sympos */ cnt = sscanf(strtab + sym->st_name, - ".klp.sym.%55[^.].%127[^,],%lu", + KLP_SYM_PREFIX "%55[^.].%127[^,],%lu", sym_objname, sym_name, &sympos); if (cnt != 3) { pr_err("symbol %s has an incorrectly formatted name\n", @@ -298,7 +298,7 @@ int klp_apply_section_relocs(struct module *pmod, Elf_Shdr *sechdrs, * See comment in klp_resolve_symbols() for an explanation * of the selected field width value. */ - cnt = sscanf(shstrtab + sec->sh_name, ".klp.rela.%55[^.]", + cnt = sscanf(shstrtab + sec->sh_name, KLP_RELA_PREFIX "%55[^.]", sec_objname); if (cnt != 1) { pr_err("section %s has an incorrectly formatted name\n", -- 2.26.3