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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 172F3C352A9 for ; Sun, 29 Sep 2019 17:42:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D950621835 for ; Sun, 29 Sep 2019 17:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569778920; bh=pBQwV3mhbv58jsEbhbzwxQUB2adUWroTzKgDObDMn5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IOkDMgy7RyQmKz8x/uyut9ZzI3kKf2x9+9ZMn/x0cg+/wmOzkAwMagAQrWna2Di+o Vb/4Bxb7/g5ubo5rtTnR4b7IKB4gRs6peTz+0sDb4DtuZ+9gP1sxDTRLoyT/3RuN2l 1m+vwp6EiVSkyUTRfC9T6cWhG4qUITJUFp1EFujA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729977AbfI2RdM (ORCPT ); Sun, 29 Sep 2019 13:33:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:44392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729973AbfI2RdM (ORCPT ); Sun, 29 Sep 2019 13:33:12 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DEB022196E; Sun, 29 Sep 2019 17:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569778391; bh=pBQwV3mhbv58jsEbhbzwxQUB2adUWroTzKgDObDMn5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SQSzDkWBoYA3HCQECrXKCVLG76WgCJECNFGS8nCTKaTpefRG7RrGoDt+wRvL5usk/ x5UYX/M9ZPhrtsywRfL/bz+iuJeH43S9CyCs6jgbld5VpsYBlPQAAzIMPwhrF2p9uK kE0nYTidMWcCwWg3Mim0FaHUi8JoEpNrw0ZoFDeQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Miroslav Benes , Petr Mladek , Josh Poimboeuf , Sasha Levin , live-patching@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 12/42] livepatch: Nullify obj->mod in klp_module_coming()'s error path Date: Sun, 29 Sep 2019 13:32:11 -0400 Message-Id: <20190929173244.8918-12-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190929173244.8918-1-sashal@kernel.org> References: <20190929173244.8918-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: live-patching-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: live-patching@vger.kernel.org From: Miroslav Benes [ Upstream commit 4ff96fb52c6964ad42e0a878be8f86a2e8052ddd ] 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 Acked-by: Josh Poimboeuf Signed-off-by: Petr Mladek Signed-off-by: Sasha Levin --- kernel/livepatch/core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index c4ce08f43bd63..ab4a4606d19b7 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.20.1