Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9177775pxu; Mon, 28 Dec 2020 08:30:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm38I8vIgzYwBap1ggzJMgEbzA0oh8yMtkgvW57g44uHZP0gYuJ+PyOtP0Faw3DTY4Qo5o X-Received: by 2002:a17:907:3f0d:: with SMTP id hq13mr40793000ejc.142.1609173049555; Mon, 28 Dec 2020 08:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173049; cv=none; d=google.com; s=arc-20160816; b=KrF9Zl93Q28ujPtqIcQQax1Vlhb8G7g8g5nhSPrnPOCliHE9I63STGKhe+aChH419v g5DefU705x47qMYOYl6V/SESj1e0l05UxnzFk4TqIPil9OHY/2lu9yP0lJNZCNweN9zd 827vS5LZBvKEUDMFg14OOYcpyerKfC/9+7OGh9QdOH3Em1myawD2V+UKO3MkSUBogb9U 5lGnqz9sdwyN/p5qriCne5hxaADD4ahc4SVCjoOd6TyytwHEc7KG4ipqTZxi8X/Fs7gl qa04Ywbm4B2fFzS5C8U5+pHOKIqMfml2XZm31bxs0K892vY41Qz3WehmEaC8kldIFI88 z9XA== 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=8fL04BrzA0se11kyw+PWJ4KfRrOGAiFqb3PmJoid8Xs=; b=wtXh9nWlFQBgnpXLCvAGiZroSA9nLmCJO94grNu3oZkXKMdJI4dprf2tzRK1vXzCCs pPUUR0KVVQEghKpr9DbsCR7zvpN/0jx2zlbm8JKRLX8yLsS1TfyTwqCPj+J2GeN0CiLb uSebpQPexUJ49uPsT8NCiVHyQo5gpgxYGW4MWeso95J6cxGQDdOQVcx6VsWeqNTYvHK/ LR99R5TctSbgkmurbOW7EtAh/3mUtr1g5VfK391G9kBcJ79SCV3o/LLPH3kSw5A1Umek BhiopMY8tRWzi2mGLCmeAygCeW+uDFCJmNaViGQ/b8SDax5sVWCAzanrTdFpf9B5oAxS T5xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZE1OFzTm; 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 dd3si20167706edb.558.2020.12.28.08.30.25; Mon, 28 Dec 2020 08:30:49 -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=ZE1OFzTm; 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 S1730714AbgL1NHy (ORCPT + 99 others); Mon, 28 Dec 2020 08:07:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:35000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730747AbgL1NHS (ORCPT ); Mon, 28 Dec 2020 08:07:18 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E72A522573; Mon, 28 Dec 2020 13:06:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160797; bh=inxXpKCh5ibIdqztv/yjJY/mv0C1JWi5hUuwN4VtN8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZE1OFzTmprxspzPr1rw6jPW2Ka0V/PGe5Hj7vBqps7BvseywhU/NMNeYLAEK1Xd+y N+y09XP7zzfHMv+iLcA88PnnFF6vnKNJCAQvIINhg1S/nfxydkeXKd+cf45xaLrm34 qv+x1pcU6u+DElltEc3RXUIPNBnm/CMlC/ZvDo3E= 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 4.9 174/175] xen-blkback: set ring->xenblkd to NULL after kthread_stop() Date: Mon, 28 Dec 2020 13:50:27 +0100 Message-Id: <20201228124901.664693510@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 @@ -262,6 +262,7 @@ static int xen_blkif_disconnect(struct x if (ring->xenblkd) { kthread_stop(ring->xenblkd); + ring->xenblkd = NULL; wake_up(&ring->shutdown_wq); }