Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2241080rdf; Mon, 6 Nov 2023 08:26:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZKe4/L0wsb444UNl/qbVnwFYe/pLlCYSSMSgTl7yte2LxQqy99Vvxs224SC4o64xWUU3u X-Received: by 2002:a05:6870:1290:b0:1bf:df47:7b5e with SMTP id 16-20020a056870129000b001bfdf477b5emr176164oal.16.1699287985960; Mon, 06 Nov 2023 08:26:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699287985; cv=none; d=google.com; s=arc-20160816; b=nra1/tlbY1Fy2XIk4DYGOsYm+wEhMAxL5PA5bvuBoLv81RLuzM2MPhkH7ooDcuFo7N 3KyLoTEWpS4+WbX1Ie/NUs2Vdy0BBFjljuY3lLoYw1IRGqiihJ3daXCXKBQgXicaz2Id YfGad1CRlW8nXljHOsBje3z8aR5LzOm/0F20lKaRXvygvakLYO+wx9NCFAV3XikXToNR Y+6j7RrUYCMrtuySsV1IdLeK8Cv1Pju/eZNt8glagjtb4VmGo6DV2LadShykIVd9C73m StA9aasmRyI9p5vY1JvXVvxoVIjuPAEY90K3ysPcH7cu6zCliYAuYSadk5xUm3wDSP2z /0rw== 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:cc:to:from :dkim-signature:dkim-signature; bh=37EtSuEzhmU45RwRWxfsxLJpp8I7CAOaubIcYziFsEU=; fh=xhPEfvLLMjXYoLIiI5VbsbsTlvtoR/tb3IoiERHw3Yo=; b=PacpnQsvwciCfNKJwvRRyN6iVEU4T383wArOQEKQxFWzHZX+zetIn63kGvWgBf4Xv4 Z72hVcNFIHrjSDQoB8l3MNSFnutKbXNvE41L6PV+1kDvNIfjXJVchgBkU732/eNcd/06 gvxWo80qs8yi1Cd2Oig1CBwRWRZtnbIpW6TdPiuam3t/uUhFCKEV/CpWLRcqyXdNYLug Etp/0j6c6ZaIMInJ4szU5icLUgX54ewtZjTjX12+UnGrg8x3tRs+3Xmkr4ofhsX7tbIx aGZrWCJRqfovo9tnW8bUfai8jtgVK7uooE+0qRV8HbBpjbY+nj+0GhkrEZuLusivTQvH wWvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=PtZKhl94; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="crK/d7wG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id a72-20020a63904b000000b005892fd16947si915pge.546.2023.11.06.08.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 08:26:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=PtZKhl94; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b="crK/d7wG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 065CC80B8F2F; Mon, 6 Nov 2023 08:26:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232345AbjKFQ0L (ORCPT + 99 others); Mon, 6 Nov 2023 11:26:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232032AbjKFQ0J (ORCPT ); Mon, 6 Nov 2023 11:26:09 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A471BC; Mon, 6 Nov 2023 08:26:06 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 62D3F21FAC; Mon, 6 Nov 2023 16:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1699287965; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=37EtSuEzhmU45RwRWxfsxLJpp8I7CAOaubIcYziFsEU=; b=PtZKhl94vwNSH1o9jUF1PuRya994j7rI+zkTzpF1y1vclk22RjwseOMShjSV4KXAVF+wGD Mw9xvsm4jm1e1PU/slemP+fDZ2l2k+HDdImdpP3bGCVrheaOXrE6v6wEaqQsd4RyQdUSYT XEFi2UlNFLMlq4IqBdnM3H9+bajkRZw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1699287965; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=37EtSuEzhmU45RwRWxfsxLJpp8I7CAOaubIcYziFsEU=; b=crK/d7wGA8JSdr8fgEWCJGkIp5/syKti+38j8Rf61XzNk+wEQ5R9Dy/ZrLH1dO/f5mPV/4 JiXWCwiWZvvAy4DA== Received: from localhost.cz (lhruska.udp.ovpn2.prg.suse.de [10.100.204.118]) by relay2.suse.de (Postfix) with ESMTP id F2D0C2CB05; Mon, 6 Nov 2023 16:26:04 +0000 (UTC) From: Lukas Hruska To: Petr Mladek , Miroslav Benes , Josh Poimboeuf Cc: Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, Marcos Paulo de Souza , Josh Poimboeuf , Lukas Hruska Subject: [PATCH v1 1/5] livepatch: Create and include UAPI headers Date: Mon, 6 Nov 2023 17:25:09 +0100 Message-ID: <20231106162513.17556-2-lhruska@suse.cz> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231106162513.17556-1-lhruska@suse.cz> References: <20231106162513.17556-1-lhruska@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 08:26:23 -0800 (PST) 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. Signed-off-by: Josh Poimboeuf Signed-off-by: Lukas Hruska --- MAINTAINERS | 1 + include/uapi/linux/livepatch.h | 15 +++++++++++++++ kernel/livepatch/core.c | 5 +++-- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 include/uapi/linux/livepatch.h diff --git a/MAINTAINERS b/MAINTAINERS index 4cc6bf79fdd8..11a2d84c1277 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12130,6 +12130,7 @@ F: Documentation/ABI/testing/sysfs-kernel-livepatch F: Documentation/livepatch/ F: arch/powerpc/include/asm/livepatch.h F: include/linux/livepatch.h +F: include/uapi/linux/livepatch.h F: kernel/livepatch/ F: kernel/module/livepatch.c F: lib/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 61328328c474..622f1916a5c8 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "core.h" #include "patch.h" @@ -226,7 +227,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab, /* Format: .klp.sym.sym_objname.sym_name,sympos */ cnt = sscanf(strtab + sym->st_name, - ".klp.sym.%55[^.].%511[^,],%lu", + KLP_SYM_PREFIX "%55[^.].%511[^,],%lu", sym_objname, sym_name, &sympos); if (cnt != 3) { pr_err("symbol %s has an incorrectly formatted name\n", @@ -305,7 +306,7 @@ static int klp_write_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.42.0