Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6022073ybn; Sun, 29 Sep 2019 10:37:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZdYPAnPYB0CcvmcXMTKsROPfxcmSeglo7WUZvQ2IkAO67TwRJf2i/0MLsCJT/slRWlT32 X-Received: by 2002:a17:906:f204:: with SMTP id gt4mr16014210ejb.299.1569778661662; Sun, 29 Sep 2019 10:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569778661; cv=none; d=google.com; s=arc-20160816; b=CRkRgiJrpMUOvnQm39ReQulDOYCQWnaaeoXJZGxGJaoI580FLB35ZoWWRXjXx2GOLR nlzAQnHsqd5Kzxt34LTWmtGprY4NWHfyHntNfoK3Nqw4WCR+r56p0QxTOHuDqYs99QyN 6tyk646XrxUHZoiuM9jddyBV8ISXvfvH0M7vUmPSCLPw6m/PkwSwQqDcE3GSj5/HiqCE 6GxuVlEZaFd+iIsFWgV1DxroMVjTJEdofkCS398cg3sNbVXnXSYEkCERoJDrxzXB5ego UHsB3ZtJU8KMmOKsElxM0m1cGQBjWxXT0APJOEwKYy5xCKbaqwoAfAHZ0Cn8uzYW0DRc f8PQ== 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 :dkim-signature; bh=rLuZYVJib/SY/SYkSi3JT6iN6K21w09ip/1LSdBs6ew=; b=Z7NxqJ3WenXEC6xGd9kAs1oXt0xLEyf515vGNqD1oenNmuE+SqvmeXixVs1Uaf/Dva OsjAarWsvzNUxm01G/lR2MSv47X+f+2ydfBTFfIL73Ojss0G03NrA0ytvr8xSS9GJEs2 QN7sg68i3GnKcjdbSIJ3aKnBH6M0pUFSf+nQ9NBs9xCo0IKrLgdkBelJVJY8UVhDcA07 GQ9mpwDHHD36ag58DSNae6aPjx6vW6k2zqtVrIUA7DUokdD/SYEtgNOeY2Nt18GV5koX dW8R29VbbCmbK9XKy0EV11VaRXtrmmOCBPgIJWiW1XLkwM/q/oI61R5zrsl+tCu3Dvux mUhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="SFg7/nZQ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si5479354eje.176.2019.09.29.10.37.16; Sun, 29 Sep 2019 10:37:41 -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="SFg7/nZQ"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730455AbfI2Rev (ORCPT + 99 others); Sun, 29 Sep 2019 13:34:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:46696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbfI2Rek (ORCPT ); Sun, 29 Sep 2019 13:34:40 -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 C19EE21D7A; Sun, 29 Sep 2019 17:34:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1569778479; bh=28EPEBeuVuP6Khqm6zlfvXCAwy4C7eBB7QJBK6lTiqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SFg7/nZQU19uettwodGd+pBvIjhjy0wvcoZaOQJBt9RSXMG8Wvtb2xq2WoibZhgs4 sIZwyX4qTEG2fq+Bu9HV/vubJWQFliCxNDTqN26/1Hr5c9SZtEy+2W+zRmprvevHlw miRaTz4CYDaK0XtKRRG+YBiNLae9Xsajy5OcdvpU= 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 4.19 08/33] livepatch: Nullify obj->mod in klp_module_coming()'s error path Date: Sun, 29 Sep 2019 13:33:56 -0400 Message-Id: <20190929173424.9361-8-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190929173424.9361-1-sashal@kernel.org> References: <20190929173424.9361-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 @@ 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