Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6272175iob; Tue, 10 May 2022 14:33:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh4ZZIc4OzkiQCdvSCRo3960bWF9uh2eDL+mtislbiOTBl4jOOFxnoL9l8juHLENBot5nF X-Received: by 2002:a63:41c1:0:b0:3c6:e382:c125 with SMTP id o184-20020a6341c1000000b003c6e382c125mr5587113pga.383.1652218404926; Tue, 10 May 2022 14:33:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652218404; cv=none; d=google.com; s=arc-20160816; b=tOPblsUXD4fQfXx+geocNPCU6DHoKXdbCZJgsvd49oK5zDjMEdY35COr5LWpMZoRXm KvkePPUX/tpgWHPg4glF9l0VNy9TYBGG0qPHQbo7Hey8K2GDayVMWPvraSQmCUa2XjgV ltDobtihKSHaxSrf/afVKA3mg1LyeIoxi8hxjAAgtvqMPZALGVvnsUmt5ASiY2xNOg9T CEjeTBwVuNFSDcjMqVL1JFyYw34UxQ50QE4q5mE6MM+ceTVuiH5hBTeyOiL+BAEfD527 9sGrEJzB+dWNT3EJAOi17cdwmQZilnOqjZcZATaN/+TUBXPmb5ae9uClWHq7v0xB3eVd LmMQ== 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=sb0q/IZz5+jDS2FwLWxsjBixHrar5oAQ8/SdcjxeBoU=; b=A3kK9ecv1mal0aIxknFPkuYVfqYpjkrBMWgzMLuShpCFaIcuOH4/P4v4friD7Y3KSa ifazDNX+/TQOdUdXEGlJn8kNDobGTPR6mcOU2LqiaOB214bgVx1+up059XtHGdm6sYog f+mUs/AeMU+1Bmtfn4ZJHI52KAPCb5NFPujjRE0uW5FUt1Qd3VATyQ7+PLj6EXoptTSY CLKaFDmTzprD/+IE+Qz15WFt1dWXDKDZq/bwemGmSWqdVO2N3fi/lkujllkD8rMQdXey 7NPZQbIiejHQ+TUQkcIlBRMnDjO9tDut3Lrzt8zZIj42ieCMK4Ak7PjLhfYBZiQC4rqd J7RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="McPIDPp/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a637909000000b003c60fd512fbsi518298pgc.870.2022.05.10.14.33.08; Tue, 10 May 2022 14:33:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="McPIDPp/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244473AbiEJNzF (ORCPT + 99 others); Tue, 10 May 2022 09:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244625AbiEJNhx (ORCPT ); Tue, 10 May 2022 09:37:53 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CFCA4706D; Tue, 10 May 2022 06:26:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id 2B117B81DA8; Tue, 10 May 2022 13:26:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E29AC385A6; Tue, 10 May 2022 13:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189159; bh=2mI/zjP+CAsjMl5kh45R2T1s5t3QVcMCqLJriNcVJ8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=McPIDPp/U00cl1YajAVmGx9exALUeV7hiEPRnfkJETwv6Q5WFdH51LkCbNJ0fBb+H 2lJrjzBKnBF8zz6+EDGllKtvFOU9TJIYcAzXT4PWiN5Wc2NBCx8Ce2s/WN5sgYXigj iNBVbT2SZsslDBAZWoIEZB0+FO4s8ETs/BuUp40w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Jan=20H=C3=B6ppner?= , Stefan Haberland , Jens Axboe Subject: [PATCH 5.10 24/70] s390/dasd: Fix read for ESE with blksize < 4k Date: Tue, 10 May 2022 15:07:43 +0200 Message-Id: <20220510130733.575368874@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130732.861729621@linuxfoundation.org> References: <20220510130732.861729621@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Höppner commit cd68c48ea15c85f1577a442dc4c285e112ff1b37 upstream. When reading unformatted tracks on ESE devices, the corresponding memory areas are simply set to zero for each segment. This is done incorrectly for blocksizes < 4096. There are two problems. First, the increment of dst is done using the counter of the loop (off), which is increased by blksize every iteration. This leads to a much bigger increment for dst as actually intended. Second, the increment of dst is done before the memory area is set to 0, skipping a significant amount of bytes of memory. This leads to illegal overwriting of memory and ultimately to a kernel panic. This is not a problem with 4k blocksize because blk_queue_max_segment_size is set to PAGE_SIZE, always resulting in a single iteration for the inner segment loop (bv.bv_len == blksize). The incorrectly used 'off' value to increment dst is 0 and the correct memory area is used. In order to fix this for blksize < 4k, increment dst correctly using the blksize and only do it at the end of the loop. Fixes: 5e2b17e712cf ("s390/dasd: Add dynamic formatting support for ESE volumes") Cc: stable@vger.kernel.org # v5.3+ Signed-off-by: Jan Höppner Reviewed-by: Stefan Haberland Link: https://lore.kernel.org/r/20220505141733.1989450-4-sth@linux.ibm.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/s390/block/dasd_eckd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -3228,12 +3228,11 @@ static int dasd_eckd_ese_read(struct das cqr->proc_bytes = blk_count * blksize; return 0; } - if (dst && !skip_block) { - dst += off; + if (dst && !skip_block) memset(dst, 0, blksize); - } else { + else skip_block--; - } + dst += blksize; blk_count++; } }