Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9231620pxu; Mon, 28 Dec 2020 09:58:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzm2o2raWiTHO7qrAm66y4Ak0Ivg2Y/p/LUEWGjdVCO3/c07p5Gnbe2XoY6hLl3M0rQikw8 X-Received: by 2002:a17:906:2798:: with SMTP id j24mr42512701ejc.328.1609178309536; Mon, 28 Dec 2020 09:58:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609178309; cv=none; d=google.com; s=arc-20160816; b=v6rtsuurdU0q/OmGJSAvBPZJWmuVkDcgp1zZXdejCcYkaYjFJMxaAZysrTA8l/Hhgp MJ/TzW3bImlnJZ0Oh9l3Vly4PD9Y3XktIrIf1YEjy8EajWTgrYL5lJNcLmXv5HCC+EHv gSEj5nEi8VXiTHULUtzkH5/ACYhToKUlg5gcBSI6hhh2I+56ddfAK67gknLa+PLFMicL +DRLgu4q1GYTuNL2v76hg9HP1oNRpwzOYQFv3C4g6HrlSkcTWUgMU+EPzF7UKbRct2IE pCt52/qDQGhqJmkqlvcbBRp+EY4gU4AKRXZ8+qEHReJGS58gX5atTSdBBch8tJeaG0ov 23kg== 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=yNavYwFROLWlm6/k3JW7tExGqlpst4/Y/zbQ7HNArHE=; b=jRhG4aO3RpOvyn8oDD1Re9ZIJbDiyXRiIovJaKynZKow74vUocFh+XqV8N5kopH5d/ hEs9JE9O439oV4TsXMEwH+3pUcjwM2kZHQZXVnITE4Z+Vp9eY+kZZF1GP3nlkj/nBtSG PHzj8xYIo6lMlOX1gdJnrNWwmZRR9ZnRdhM9LhJVqftDE1096D7TQhfDdG0YiNS5X0Fo Vt23Q4Dkd2WZ21LNjwrvr0ofrN0yyybtoebpGRZ5yusWMSt+0U3CSJw5aTZKd3OgcoUY 0Tqy16FxregiguXoekbATLXbJkhW0LnBFM5j3+MPgePgzxfjXYepKoEk8HVCZ31/V6Iu hjEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UUWTksLX; 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 k25si18994430ejz.91.2020.12.28.09.58.07; Mon, 28 Dec 2020 09:58:29 -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=UUWTksLX; 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 S1732870AbgL1NT2 (ORCPT + 99 others); Mon, 28 Dec 2020 08:19:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:48000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732862AbgL1NT1 (ORCPT ); Mon, 28 Dec 2020 08:19:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CBC1C2076D; Mon, 28 Dec 2020 13:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161526; bh=qP5PmOfyTyIxZ6OcloGXOoA0/snFQLg5hJU14nFi1Pc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UUWTksLXgiwAVSuuWA93brTG6fuSbrDDLgmeCv6trfLpd37sPQIdYQ3edTMc+1hhU e7XlzQw3k1Jc5LmIhkbguna7/D6zJT8AQBB7x5AsSgVTEuwYJGRamfo6xU1oYC2FdY ol3P5wBvNuX9ue+iQAScUQlTRerjkWLETzpHRYFA= 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.14 235/242] xen-blkback: set ring->xenblkd to NULL after kthread_stop() Date: Mon, 28 Dec 2020 13:50:40 +0100 Message-Id: <20201228124916.258625227@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 @@ -263,6 +263,7 @@ static int xen_blkif_disconnect(struct x if (ring->xenblkd) { kthread_stop(ring->xenblkd); + ring->xenblkd = NULL; wake_up(&ring->shutdown_wq); }