From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CDB1C7EE25 for ; Mon, 12 Jun 2023 10:53:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236167AbjFLKxe (ORCPT ); Mon, 12 Jun 2023 06:53:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236196AbjFLKxS (ORCPT ); Mon, 12 Jun 2023 06:53:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B54B5AD25 for ; Mon, 12 Jun 2023 03:37:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 95D0661BD9 for ; Mon, 12 Jun 2023 10:37:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5FECC433D2; Mon, 12 Jun 2023 10:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1686566278; bh=zxnzJWm+rYyHlrxH+v0LpgOSYpjVgNB8BHMwUciqIeM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NU+m6/GchBX3os1H2eQrtlZYrykqNl6Kk0/s7Z5APC1NEQZMsONkfX2stP160y/5m Yn+ByWszHsBmrzvGRb5hJY+DLUlweRzfrbUOyRvkB5Rn+Mu6J8A5he4YBOV/L2Fo2e VRVjqdME1B9x2N1D6t8u9Zhb/HsMXzUvPT6XkPxQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Jan=20H=C3=B6ppner?= , Stefan Haberland , Jens Axboe Subject: [PATCH 5.15 62/91] s390/dasd: Use correct lock while counting channel queue length Date: Mon, 12 Jun 2023 12:26:51 +0200 Message-ID: <20230612101704.648426803@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230612101702.085813286@linuxfoundation.org> References: <20230612101702.085813286@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jan Höppner commit ccc45cb4e7271c74dbb27776ae8f73d84557f5c6 upstream. The lock around counting the channel queue length in the BIODASDINFO ioctl was incorrectly changed to the dasd_block->queue_lock with commit 583d6535cb9d ("dasd: remove dead code"). This can lead to endless list iterations and a subsequent crash. The queue_lock is supposed to be used only for queue lists belonging to dasd_block. For dasd_device related queue lists the ccwdev lock must be used. Fix the mentioned issues by correctly using the ccwdev lock instead of the queue lock. Fixes: 583d6535cb9d ("dasd: remove dead code") Cc: stable@vger.kernel.org # v5.0+ Signed-off-by: Jan Höppner Reviewed-by: Stefan Haberland Signed-off-by: Stefan Haberland Link: https://lore.kernel.org/r/20230609153750.1258763-2-sth@linux.ibm.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/s390/block/dasd_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/s390/block/dasd_ioctl.c +++ b/drivers/s390/block/dasd_ioctl.c @@ -502,10 +502,10 @@ static int __dasd_ioctl_information(stru memcpy(dasd_info->type, base->discipline->name, 4); - spin_lock_irqsave(&block->queue_lock, flags); + spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags); list_for_each(l, &base->ccw_queue) dasd_info->chanq_len++; - spin_unlock_irqrestore(&block->queue_lock, flags); + spin_unlock_irqrestore(get_ccwdev_lock(base->cdev), flags); return 0; }