Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3396206ybp; Sun, 6 Oct 2019 11:01:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPhDW7wtov70B5POkoYk0EN+JZiaIdTpZdKMwe5NoXnxOqR3PEAcfUn1p+i7ZXs3NPG46K X-Received: by 2002:a50:e691:: with SMTP id z17mr25520009edm.84.1570384891021; Sun, 06 Oct 2019 11:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384891; cv=none; d=google.com; s=arc-20160816; b=Ep1qFFDaZ6bJQJbN9s+Fu6eko0x4ZzkymhFJ+jgVSmpWtR04r8iNY6nU84umgnGSyD NFYXo4sPZ5LTbyoWQ3rHeFUHc5A1WKe/H931B7mcAjB1vI92argR91sacBbkZRrTuGmZ yQR6wPP5ItHqOA2ieAp1WCddkR3XJYDJ+TKWlnBYfgDlOPRbWbSQ0WPh4KBiXtJTWzX2 zYVBQiE0dAIpTj39D4irLZYXq+1uKTE8IM/GN8CaB8ml/Khl7KsgTnvfScLMCX/tHKP1 Sm/mPl7/U2ubdDnG14ovpjzBmd3VDWs3+gkEdNgFKGU1zCBiyYK6xbMnz4bSMEWRn1Hd tmdw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=49MkZq4O51O6FF6w4l+OnWAXe1bjQuBLe/K00orSnuY=; b=F/sHZmamwWKdJ3CExW00LxluU1nbBFjbzTWUNk/hvRPd1Hww4BRB2XeAMGX5Upt4iH ES7o2i0fu+5b0j1lTmXjw51BoxSCFHboYyg4Mr1qMJzPfGlhMnla9b1OgcWCeHpjib4P UCChinrtvIvtdjXqFtDOXgWUrQVGfrYd7c1Tz0jFOaXDE9qGqmi59CRYZmpOEmah+D0g pLVpnc7vezxtqXtdLhQBR0c47lsQdRPvAZCIFQbqM46VVhOuEx5GqE1p/kScAJ4xHczG bnsppcDUetf+CzjMdhkoIqQ7OURzehkHaH3/MCuAb/hY9UhPxixPYl52VoxkvgVqNX77 mjpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0ah3djOm; 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 27si7330082edz.186.2019.10.06.11.01.07; Sun, 06 Oct 2019 11:01:31 -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; dkim=pass header.i=@kernel.org header.s=default header.b=0ah3djOm; 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 S1728107AbfJFRaN (ORCPT + 99 others); Sun, 6 Oct 2019 13:30:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:56070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729039AbfJFRaL (ORCPT ); Sun, 6 Oct 2019 13:30:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83B9C2133F; Sun, 6 Oct 2019 17:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383011; bh=DoSnJE+/AIJVHkubvDdh3iKIiYc9vRFb+UuVLRPUBj0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ah3djOm4uAHnqP3E0oxHjiW/9kU60tjOjn+PxQ+no7uDAKa1i3P/pZWNfNNdH+H7 UMGf4OJnDShk+CbFcP/qrPLG9dp/WUShcn1KVTkRMFWdpOEtPZfDfV87n9o+s7B2kF xJHj2rxMA/tvLXmXZ2J6rImOs5brq2Cq/ERgzIMk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miroslav Benes , Petr Mladek , Josh Poimboeuf , Sasha Levin Subject: [PATCH 4.19 054/106] livepatch: Nullify obj->mod in klp_module_coming()s error path Date: Sun, 6 Oct 2019 19:21:00 +0200 Message-Id: <20191006171146.174243201@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 722c27c40e5b3..a1250ad591c1d 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1027,6 +1027,7 @@ err: 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