Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9100299pxu; Mon, 28 Dec 2020 06:38:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOne/mY1kvyIx2siBRNfuP8BtSrgXMr98Xk3FKbWccO+hQw2FzfBCpjBmblwSZInf5OP1t X-Received: by 2002:a17:906:74e:: with SMTP id z14mr40823634ejb.362.1609166334016; Mon, 28 Dec 2020 06:38:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166334; cv=none; d=google.com; s=arc-20160816; b=ku3sJCaPCtJy8Qhv9gdWJACNfjQo6GM/dn2Prx6fWvbpeyGNI4zFoQMiwoHnYUV+R7 xWwS7WRGgGWc6ctDWsP9OQXcNjPm2s6Pu/v9JkifiyVnFffN4KF9V7N5w9wZijLb25mq EX6TnXskOMDJm0Dct8efY01jKFIbehyIikf9dXuwX2xf2bT0b7tr6LO0wceEGceV4wEB TyPYnaYV9XmYIfx29eEVtuWTcTKvmcbq26nNTrd4TSBaZb7XG7vTUrqVkr1+RxuUM6vZ fqH4ADVKQ4Rf779hkU8uHK+dN2NZz8OJ6wwMSzZlawXPkLpSU+BkseSS41dVC7Ana3z7 t7YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8hKV/jSD+DRM/r2uNKgmr4NjZyCwkRx7xASYJSj1FRo=; b=FuHm/iZWNu6FY/EKTthlRbdUSnO+AMdXKrOxHWjVyZC51753thI1WbZoBbpI8uBe9S cI3lCr2RhILDXu+/RUbm/oorDeT/RMxKLjLt8rM3NReWcVSgA3cT8qDqZ7/MPppRO1kt UG+M0f1npztNlivI8tpzuBz3osJXy3bIWU9JBxMdfsvCT/xDAzBuQkd6X1qOZ3fRz+lJ SOgEhc6QYJfRLSxOOGXF1SzLsY/cajXNkAbsGymZ9od5nMvbLvcGGudjjMMOahLdwhDm V76HF+DuvrGk8J9/4f6jwEzlQoKBiJ5d42OZnO0J01DiHwneWKQ2a7sNHRmhGgv4ibp0 Nnaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FobRrUww; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si19559140ejc.684.2020.12.28.06.38.31; Mon, 28 Dec 2020 06:38:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FobRrUww; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504794AbgL1Ocp (ORCPT + 99 others); Mon, 28 Dec 2020 09:32:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:38964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504167AbgL1Ob5 (ORCPT ); Mon, 28 Dec 2020 09:31:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 02CF420731; Mon, 28 Dec 2020 14:31:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165902; bh=FByFilfvTSCB8jVvVtOFWdve0P2M38QBoOeXyFRguSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FobRrUwwP+lZjAMkHxdaan/hrt06gzm5T2FoHN36MQE8cEQHWEPJVBDAYTGpGKFJO aFDqq9n9VVlf3ndwGNfkm2ql+EsXmqDssn81AwcwgyU8PeM6mXssj0TYTezf0BG5fW PX5dJH9pw+iL73RjYXcXHA7ilQN8blvCkwEVVdiA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Olivier Benjamin , Pawel Wieczorkiewicz , Julien Grall , Juergen Gross Subject: [PATCH 5.10 695/717] xen-blkback: set ring->xenblkd to NULL after kthread_stop() Date: Mon, 28 Dec 2020 13:51:33 +0100 Message-Id: <20201228125054.281133955@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pawel Wieczorkiewicz commit 1c728719a4da6e654afb9cc047164755072ed7c9 upstream. When xen_blkif_disconnect() is called, the kernel thread behind the block interface is stopped by calling kthread_stop(ring->xenblkd). The ring->xenblkd thread pointer being non-NULL determines if the thread has been already stopped. Normally, the thread's function xen_blkif_schedule() sets the ring->xenblkd to NULL, when the thread's main loop ends. However, when the thread has not been started yet (i.e. wake_up_process() has not been called on it), the xen_blkif_schedule() function would not be called yet. In such case the kthread_stop() call returns -EINTR and the ring->xenblkd remains dangling. When this happens, any consecutive call to xen_blkif_disconnect (for example in frontend_changed() callback) leads to a kernel crash in kthread_stop() (e.g. NULL pointer dereference in exit_creds()). This is XSA-350. Cc: # 4.12 Fixes: a24fa22ce22a ("xen/blkback: don't use xen_blkif_get() in xen-blkback kthread") Reported-by: Olivier Benjamin Reported-by: Pawel Wieczorkiewicz Signed-off-by: Pawel Wieczorkiewicz Reviewed-by: Julien Grall Reviewed-by: Juergen Gross Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/block/xen-blkback/xenbus.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c @@ -274,6 +274,7 @@ static int xen_blkif_disconnect(struct x if (ring->xenblkd) { kthread_stop(ring->xenblkd); + ring->xenblkd = NULL; wake_up(&ring->shutdown_wq); }