Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1682949ybi; Wed, 17 Jul 2019 20:04:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuLVv3IQXtIIdR0cNK5AbeMSPt4FG+Pd5fhMdiEVx3wgGDQCKhki6WtfbOVWl8LQ7dWjdY X-Received: by 2002:a63:c442:: with SMTP id m2mr45680217pgg.286.1563419043996; Wed, 17 Jul 2019 20:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563419043; cv=none; d=google.com; s=arc-20160816; b=APxiuQnjc97iYdxoeGuuQl06GgKZ+d8cQFMfnUfnY6zR/hLtzzci+GBnUvvJaqjhxa geUIcVSvqyjxZc0QbsJvRJZdABv7e60/DfhHdwzkc1FkQ60uheo09YcIW4KpdCCkincv t6x+GtIcWy3Bz9w4lZWokzDb8MkA6zC791p6uHA+njrkzNlas4dwveIeWcLLlYvlco77 mQnbFFOE1jPWeQKbBZmKkgN2mDZUxCPLkvWwSwMvza9NDRZ8DrX4S50FBJ+/HeSplXTp /7V0ezNBzJKDDEQ5vlOdJfnRp6z4dz40t5gqD93qERFzVCmwi3heIPUHIkbZE8Vy42wC D5Gw== 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=KhcwzlAxCWFIHKYdT6lhkUAgE65kVDo9tqe+WZvjiAk=; b=MdVLdu8mzprlo4pMaF5gcD44jX/XiuOCnEdDxgRTBxCcV817nPJBP5PfUXBXoWlN0c o5xtdGzJPv3j47wtuhxs8loBG7pfAMv3Nvk/pIASpSqBVqqZgYpMCVntn9WBahsZn4Ul a7wfFF+BF2arIUy45M5I7wkQMSFkiA0g9ft7tvRL+QnFjaPesgpJd6F3gA3VkkD6aA+/ qRFZFLMlfawzRE6crNys8In/QL0A5Uz9ykuqef8TaPAwvS9MbzZh+VNoqDoGqf1KtpTF /Odb/v+IlchcWO68FgJRgbfatag2QxR5VrbN2iBms9ORl8my7faDovzW4uipkiMNCgue smpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vovVF8gR; 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 v23si24966574pgn.557.2019.07.17.20.03.47; Wed, 17 Jul 2019 20:04:03 -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=vovVF8gR; 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 S2389209AbfGRDDK (ORCPT + 99 others); Wed, 17 Jul 2019 23:03:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:33806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389185AbfGRDDI (ORCPT ); Wed, 17 Jul 2019 23:03:08 -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 625CA204EC; Thu, 18 Jul 2019 03:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563418987; bh=YfICFsESOvdQZDGiHscJVaj94R0uz2pITiwXWI9h5k4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vovVF8gRZxIwnBrvGb05EGNmVF39Xmc50j/mMEUw/y0oHk+/yHnrSA+sq2rD9rHOC X2/gbHTniT4U10jkOacj6i9BwEh+nvUeN/TxadBRSa8H9KBUIVOk4UeJ6Kmi9oX+8V y2An+6Sm2j2i8wcIHQNH8GZQa7H/UQF0sOxLnGyU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julian Wiedmann , Vasily Gorbik Subject: [PATCH 5.2 16/21] s390/qdio: (re-)initialize tiqdio list entries Date: Thu, 18 Jul 2019 12:01:34 +0900 Message-Id: <20190718030034.929584571@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190718030030.456918453@linuxfoundation.org> References: <20190718030030.456918453@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 @@ -150,6 +150,7 @@ static int __qdio_allocate_qs(struct qdi return -ENOMEM; } irq_ptr_qs[i] = q; + INIT_LIST_HEAD(&q->entry); } return 0; } @@ -178,6 +179,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)