Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3631936ybi; Fri, 19 Jul 2019 06:29:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDIlW+vnE6R0SIrEYphAs+JI7wC/kjLu+SXsjNrYnzHWaQH6jb/jvfTvCTTqA65lryFJcW X-Received: by 2002:a17:902:9f8e:: with SMTP id g14mr11115597plq.67.1563542952611; Fri, 19 Jul 2019 06:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563542952; cv=none; d=google.com; s=arc-20160816; b=w+Uim7nNTazSJsWDRo9LEM4Y7caRTapS4v5RCvk/gXX3vUoGge98yX5WK3TeRyjz/U /rw8UwghHsafTg5OJx3xrW/GbfNjSjG972lv+CqRYR1J1JxXy9PT507XLFAnGIdUpzUa ATO9FGVFn9NQQ2v5d2y6OvhkpOFIQSQ1MUVqPSL4D8si2elipJv/IQ+ZVsF+9vj7wALu /jUBYkuCVNX933/FG7EvDgeKjym2BpDtM33SpE756yGVtiK4jbGTxI2Dh6h0x+IdXim8 fZr6gVebEnmaDmWyYkrc+Cae4PkCgo64LcPJ5xTwximBeEcoahfo4vaMAQ0onTtw539Q PkdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3nlfz7fg3jDTtpEW5fGaB932C13nW+H7oqdnUxK+HXU=; b=rKtGUkR0MVyOJpPTzPWsV2y8vRypAClNeW/0CehbTihw94jXuN4VvyhA/w96oxuoPm kdE/fz4zz9/z4J62kyodTpl01aJlyTF7J+KB4TbhKa4hqQwUM7u+MTzCzZeCCxdUx+8e sZob0WNxA2bNwyeXToRF4gywnRpd80tHQeDwf4Y9hbJUepqt6EiktYXrJqSij/UAlesK hs6otGXbimVN9EPw4AYqQPtZEyj9k8NvJoiq93CKYLsNM2AwjqLsaTbc1uEr2EFm+xTY /vBA8XycOJrsYOrxPZ3QN/UyDDNQQwym6+JPMMS5AV3P8mkPm0zT8HGvSVCbHHY7o8TN 2g3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u9si1969416pjn.86.2019.07.19.06.28.44; Fri, 19 Jul 2019 06:29:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728377AbfGSM2p (ORCPT + 99 others); Fri, 19 Jul 2019 08:28:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:49126 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727637AbfGSM2o (ORCPT ); Fri, 19 Jul 2019 08:28:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DFDCAAECD; Fri, 19 Jul 2019 12:28:42 +0000 (UTC) From: Miroslav Benes To: jikos@kernel.org, jpoimboe@redhat.com, pmladek@suse.com Cc: joe.lawrence@redhat.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Miroslav Benes Subject: [PATCH 1/2] livepatch: Nullify obj->mod in klp_module_coming()'s error path Date: Fri, 19 Jul 2019 14:28:39 +0200 Message-Id: <20190719122840.15353-2-mbenes@suse.cz> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190719122840.15353-1-mbenes@suse.cz> References: <20190719122840.15353-1-mbenes@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org klp_module_coming() is called for every module appearing in the system. It sets obj->mod to a patched module for klp_object obj. Unfortunately it leaves it set even if an error happens later in the function and the patched module is not allowed to be loaded. klp_is_object_loaded() uses obj->mod variable and could currently give a wrong return value. The bug is probably harmless as of now. Signed-off-by: Miroslav Benes Reviewed-by: Petr Mladek --- kernel/livepatch/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index c4ce08f43bd6..ab4a4606d19b 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1175,6 +1175,7 @@ int klp_module_coming(struct module *mod) pr_warn("patch '%s' failed for module '%s', refusing to load module '%s'\n", patch->mod->name, obj->mod->name, obj->mod->name); mod->klp_alive = false; + obj->mod = NULL; klp_cleanup_module_patches_limited(mod, patch); mutex_unlock(&klp_mutex); -- 2.22.0