From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.codeaurora.org by pdx-caf-mail.web.codeaurora.org (Dovecot) with LMTP id Gpn0ABb7GFsqBQAAmS7hNA ; Thu, 07 Jun 2018 09:29:58 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id DF562607DC; Thu, 7 Jun 2018 09:29:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by smtp.codeaurora.org (Postfix) with ESMTP id 61DBD601C3; Thu, 7 Jun 2018 09:29:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 61DBD601C3 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753354AbeFGJ3z (ORCPT + 25 others); Thu, 7 Jun 2018 05:29:55 -0400 Received: from mx2.suse.de ([195.135.220.15]:54607 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752613AbeFGJ3x (ORCPT ); Thu, 7 Jun 2018 05:29:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EDD66AEEA; Thu, 7 Jun 2018 09:29:51 +0000 (UTC) From: Miroslav Benes To: jikos@kernel.org, jpoimboe@redhat.com, jeyu@kernel.org Cc: pmladek@suse.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Miroslav Benes Subject: [PATCH 1/3] livepatch: Nullify obj->mod in klp_module_coming()'s error path Date: Thu, 7 Jun 2018 11:29:47 +0200 Message-Id: <20180607092949.1706-2-mbenes@suse.cz> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180607092949.1706-1-mbenes@suse.cz> References: <20180607092949.1706-1-mbenes@suse.cz> 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, but we're gonna rely on klp_is_object_loaded() and correct obj->mod much more and the bug would be visible then. Signed-off-by: Miroslav Benes --- kernel/livepatch/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 3a4656fb7047..36eb5cf38766 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1015,6 +1015,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.17.0