Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1702669ybi; Wed, 17 Jul 2019 20:25:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxadXMuovJ15UjMnkj1mKV58fX+6BBiPkXgooAi5nMBGcZB4ORzIztED4K7ISbNn1Nx+3x X-Received: by 2002:a17:902:2d01:: with SMTP id o1mr48415784plb.105.1563420301928; Wed, 17 Jul 2019 20:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563420301; cv=none; d=google.com; s=arc-20160816; b=h/H12iE82xOhw1J3JwULOid9IYZJxxS9e/f/BtaFi597jsjPyLkTfm5r1+U8dpt9cy 8E605qXoGl0f0LqciZIoSntyqISOeb41eeRyMjhWzYzVWkHkzLmS++mhADHHwnZ2QbNI FXqIRWo96Pq/cltu7R0PgjpvYfeGlGrBLb67e1CvMXABN/eqkT9rQHWAd3FIwQXIyXzG eum76ylxu41Wx0Ltn1T8tW1DxdAIFU6cmgHgqCD5GqvPONX7ySHjQGyt2mwde2ijbNgn r++Ybmjv+yWMhMkey6ztpsnLfTYZWB9jmxVxED7M2KozY6eiHlFNXGmRnhUsFDgpk6ks 2LZA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ml9iPg42CaumGDwdS0MvEI5ydNU98CVYxmSKoIVWsj8=; b=UF5AHU141B34mE+JNC9sGQ+xkd+SKwoOCZRXux1AoomXHGT7RzD0P58YOK8RqWV+tq f8veXxon+DgdDqiVLc1kou5m39LyOTqkwus7FG5OL3kp6968mBs0Rm28J5424cH9Y/Kp 3nYBXQ/l6NOOIhL1CN7+ZJOCN6P8Liyt1Kn2aSASBgIx87i6GnGYd3CAUeZG5k1bD3YP jENBfiV33NuGtNf6fqYRI+X1S8lp5vDue0Cf5YKJlS9qZ80xLzZWmsG3KzNVZa3VVjwH sm31DIs9Qn9w+L200F3KudqUv6pyEkdXQ5882v7xkDuHe7Yr80rcDuNFWA5OWLlUpqtk cEWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NRuTkeP5; 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 o2si10519875pfp.113.2019.07.17.20.24.45; Wed, 17 Jul 2019 20:25:01 -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=NRuTkeP5; 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 S2391393AbfGRDXq (ORCPT + 99 others); Wed, 17 Jul 2019 23:23:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:39582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727851AbfGRDHv (ORCPT ); Wed, 17 Jul 2019 23:07:51 -0400 Received: from localhost (115.42.148.210.bf.2iij.net [210.148.42.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 628B62053B; Thu, 18 Jul 2019 03:07:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563419270; bh=wMdPNoj9T1GtWUxEQzxuJ8p/8iOFmwa+5cQ4Ej+wvbs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NRuTkeP5LdLAgZMu7rDZuAkhAVADVFJJR7U5xfg1afeE0z4AgRLh6Jp7Y4k3lcRc1 Hn9ZRAhC402HujhjQ7pDXKlAATnfMM6KT1IO2wSoDzl3JV7shq9Wrd2w9MY8XEOfGO djS6aIkZ/eHin7jhZfdaKz0h+qZbKLOfE8+3IVD8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Wiedmann , Vasily Gorbik Subject: [PATCH 4.19 38/47] s390/qdio: (re-)initialize tiqdio list entries Date: Thu, 18 Jul 2019 12:01:52 +0900 Message-Id: <20190718030051.979282235@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030045.780672747@linuxfoundation.org> References: <20190718030045.780672747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julian Wiedmann commit e54e4785cb5cb4896cf4285964aeef2125612fb2 upstream. When tiqdio_remove_input_queues() removes a queue from the tiq_list as part of qdio_shutdown(), it doesn't re-initialize the queue's list entry and the prev/next pointers go stale. If a subsequent qdio_establish() fails while sending the ESTABLISH cmd, it calls qdio_shutdown() again in QDIO_IRQ_STATE_ERR state and tiqdio_remove_input_queues() will attempt to remove the queue entry a second time. This dereferences the stale pointers, and bad things ensue. Fix this by re-initializing the list entry after removing it from the list. For good practice also initialize the list entry when the queue is first allocated, and remove the quirky checks that papered over this omission. Note that prior to commit e521813468f7 ("s390/qdio: fix access to uninitialized qdio_q fields"), these checks were bogus anyway. setup_queues_misc() clears the whole queue struct, and thus needs to re-init the prev/next pointers as well. Fixes: 779e6e1c724d ("[S390] qdio: new qdio driver.") Cc: Signed-off-by: Julian Wiedmann Signed-off-by: Vasily Gorbik Signed-off-by: Greg Kroah-Hartman --- drivers/s390/cio/qdio_setup.c | 2 ++ drivers/s390/cio/qdio_thinint.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/drivers/s390/cio/qdio_setup.c +++ b/drivers/s390/cio/qdio_setup.c @@ -151,6 +151,7 @@ static int __qdio_allocate_qs(struct qdi return -ENOMEM; } irq_ptr_qs[i] = q; + INIT_LIST_HEAD(&q->entry); } return 0; } @@ -179,6 +180,7 @@ static void setup_queues_misc(struct qdi q->mask = 1 << (31 - i); q->nr = i; q->handler = handler; + INIT_LIST_HEAD(&q->entry); } static void setup_storage_lists(struct qdio_q *q, struct qdio_irq *irq_ptr, --- a/drivers/s390/cio/qdio_thinint.c +++ b/drivers/s390/cio/qdio_thinint.c @@ -87,14 +87,14 @@ void tiqdio_remove_input_queues(struct q struct qdio_q *q; q = irq_ptr->input_qs[0]; - /* if establish triggered an error */ - if (!q || !q->entry.prev || !q->entry.next) + if (!q) return; mutex_lock(&tiq_list_lock); list_del_rcu(&q->entry); mutex_unlock(&tiq_list_lock); synchronize_rcu(); + INIT_LIST_HEAD(&q->entry); } static inline int has_multiple_inq_on_dsci(struct qdio_irq *irq_ptr)