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=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 4B7FDC38A2B for ; Fri, 17 Apr 2020 14:04:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 236C921924 for ; Fri, 17 Apr 2020 14:04:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Z9BjD9UJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730765AbgDQOEu (ORCPT ); Fri, 17 Apr 2020 10:04:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42176 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730744AbgDQOEu (ORCPT ); Fri, 17 Apr 2020 10:04:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587132289; h=from:from:reply-to:subject:subject: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=o8foZaTA908TKiqlCeHVCOn2XVeLTmA8LWaRlobZZ4U=; b=Z9BjD9UJ2fi+kr27dht6blCvnJG921ImE0IManixaMa8RUczuwYy4/H4jCWPdu+dQXlJlD GePxanydLnQqzbiKylsj/CSesF92gxHBgJQcqkXRhasZCrr4iR7RvJC30ZB+wZsP7CmYl7 vTYhtdpGLhP2GIuCwbM6+xX6fP3iJLU= 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-162-Q9v-mqkWMqK-jFQWshYwvg-1; Fri, 17 Apr 2020 10:04:47 -0400 X-MC-Unique: Q9v-mqkWMqK-jFQWshYwvg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF10B107ACC9; Fri, 17 Apr 2020 14:04:45 +0000 (UTC) Received: from treble.redhat.com (ovpn-116-146.rdu2.redhat.com [10.10.116.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2039E5C1C5; Fri, 17 Apr 2020 14:04:45 +0000 (UTC) From: Josh Poimboeuf To: live-patching@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Jessica Yu , Miroslav Benes Subject: [PATCH v2 1/9] livepatch: Disallow vmlinux.ko Date: Fri, 17 Apr 2020 09:04:26 -0500 Message-Id: <68b2d27ce7991873ae3932e0f8f3f05c44dbc4f8.1587131959.git.jpoimboe@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Content-Transfer-Encoding: quoted-printable Sender: live-patching-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: live-patching@vger.kernel.org This is purely a theoretical issue, but if there were a module named vmlinux.ko, the livepatch relocation code wouldn't be able to distinguish between vmlinux-specific and vmlinux.o-specific KLP relocations. If CONFIG_LIVEPATCH is enabled, don't allow a module named vmlinux.ko. Suggested-by: Peter Zijlstra Acked-by: Miroslav Benes Signed-off-by: Josh Poimboeuf --- kernel/livepatch/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index c3512e7e0801..40cfac8156fd 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1139,6 +1139,11 @@ int klp_module_coming(struct module *mod) if (WARN_ON(mod->state !=3D MODULE_STATE_COMING)) return -EINVAL; =20 + if (!strcmp(mod->name, "vmlinux")) { + pr_err("vmlinux.ko: invalid module name"); + return -EINVAL; + } + mutex_lock(&klp_mutex); /* * Each module has to know that klp_module_coming() --=20 2.21.1