Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1974998imm; Thu, 7 Jun 2018 03:27:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIBGvyyrfxjgamoRYF3xdmiyEl1OfA8iXk+ObaeNMtUMrKe9g3hgl4sjxXnY5y1sKVnrkO9 X-Received: by 2002:a63:b008:: with SMTP id h8-v6mr1096916pgf.137.1528367275116; Thu, 07 Jun 2018 03:27:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528367275; cv=none; d=google.com; s=arc-20160816; b=dqCp6YxgaEXeo0g9m9pQFPbIoI8e6WjffufD/PJjRYUwaEOIVCZ+0vMxYKYBmSkldq GhBLGgBo5mlI/FS57mFyuN0hIYZm5uKLpvLtCJZ6VsfuNBN+VYAI7xuJomWv+WeNYdc4 YRHd7/pU/kVoP3esuqP53QypRNpjwuGQriUUWuU3UMCxwtwvlW9PVZ116/2V0p2uM484 lbrnCjMW0xFslODZ94Cb7dVE6zpmjPs6ML1ReXvhcu2yJUg6wztrYbHPMJ3unltjFXCM UiGxw3IKU2c5tmSKwiKa4VRox3p1yvrvfaMeZhT+//bjFIQOc9MkGi3gm9q0ozJ7JOOz ltbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uiIs55EmFKixZzJ99rNdfoHRJ6aWycwdTZxsdgz4qik=; b=D1b/iNmIMKF8lrhzqEp4KmwcHwa+NQMaB2abZWZ4ADMQR3JDwwEkEcVQbsQz0zv0WH PqfZGCh6+AwAqNzkafzbBeMSsYrR/b+qDMxIT8dGJgmOoIh+gl03YMi0x7TdumVKSCN0 dkyxC7w25b5e5/2Tq/NidZBYb7OU1evabl1qmmAkMv/9/uwfW/U01g/QQA4wYU9g1bs9 37AWdLLLngzRmlrzQu45Ebia5G4CbuRpYQnQ9ZoOxGEa2pCXEqCg3W+n3zGEu0nQVA+j pUvWBIT7RhpeN8lwPxRN/UzXDpHVZrKqkd8vHkoWRUQeHTgKUU4xzjXnVUYde8KAt2Na LSfQ== 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 w22-v6si52574496pll.599.2018.06.07.03.27.40; Thu, 07 Jun 2018 03:27:55 -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 S1753289AbeFGJ3z (ORCPT + 99 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