Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp638189pxv; Thu, 15 Jul 2021 12:09:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj/kQMgDl4bQFwyMczPA8rO1/jJ//rLOa4mKwQINRVj5QjJ5fQMs6KikRWF3ekGBeSdzSk X-Received: by 2002:a05:6402:2034:: with SMTP id ay20mr9486222edb.188.1626376165779; Thu, 15 Jul 2021 12:09:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376165; cv=none; d=google.com; s=arc-20160816; b=fB6tzVhPNMmbOY0TgxRO/WvyIY9flw6z/UaNCrJUsKA6vwYlQNV02QufGLLwhfJG/6 fGC3XtW0+6TgXI/2Cpz8XXgciChDpJMH2lJhs4HSk3rFLtabLLiOKWwqfaT2pJDK/4m2 +r2s7MLxhXlUG3pTvFB/ylgv99v81Q1F+/BhC47fl6SBwuaT2tvEm7oA5gWLtpM0ZYxM Icbi13DXNyONKOr/ttWeTUyb5Lolt8COzppXH0K7iMz8o7ZmnPiuRWEeQLjDolibYiyd +MLrOhIyRJi9oQkwNVGOJK+RlW+sGQEDTfom+umvMwvtr8i4Ve3CEF/WL7AXGhiduWHX W0vw== 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=80Tx9kGuaPrWNE3x8EASdQlJ6szMtCpIJUwOrryo4Jk=; b=0OtSMtHPupE+GhU93rlufWS6ED6fAeuAa0Re2/sQA6BaAjhccTnoKt2UcR0KYFbZWa LLjNS5VWErRdO6AyuZ7xL4GAxHUXZF8CNYpKNqS3xg7lZY/mCR27z3bvqU8uvgC8dVPo MA0xilDpd7stuvBBivYKmP1Jj3ARF+Sexrq0JsQx+FsK9PVGvgzp/of5Q6eN9K/9dLQp j09shuXcrFpAd8zpZ7+Ncoy/JzqXm3IU3FwPNZvTcoQnF7ABaH/+H3m/yRtbukq9AJNX +FN8INuxY+gmfuutXCvUn/PlLb6cYZDYCwFtYHV36zvx0bLZ1MptQBlsSiezVNWcajeh aRbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="az7i/yS+"; 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 l3si10023393ejd.407.2021.07.15.12.09.02; Thu, 15 Jul 2021 12:09:25 -0700 (PDT) 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="az7i/yS+"; 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 S243578AbhGOTJ4 (ORCPT + 99 others); Thu, 15 Jul 2021 15:09:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:35768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242219AbhGOS7d (ORCPT ); Thu, 15 Jul 2021 14:59:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A68B1613E3; Thu, 15 Jul 2021 18:56:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375373; bh=WHEJ/5JxED6vPS2TrQq+1VbRsCAJrlhyTw5epqGEJ6w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=az7i/yS+1+MNUvR+khbqafJ6xWeOrHoabi+eTM1iqKfyjBgwBsi7sy4akQr5LakML 3hpbAh7+/qDHfsk8/JkobMfB+Jgl1gZ3nd5YmL3oQt9iVOAEAxXsL6Wu3sG4D6gWGD HdJjUWMaSRXFuX8gqyhILI8G3FCz4Ke0JWh29/ZU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Damien Le Moal , Mike Snitzer , Sasha Levin Subject: [PATCH 5.12 058/242] dm: Fix dm_accept_partial_bio() relative to zone management commands Date: Thu, 15 Jul 2021 20:37:00 +0200 Message-Id: <20210715182602.649204741@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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: Damien Le Moal [ Upstream commit 6842d264aa5205da338b6dcc6acfa2a6732558f1 ] Fix dm_accept_partial_bio() to actually check that zone management commands are not passed as explained in the function documentation comment. Also, since a zone append operation cannot be split, add REQ_OP_ZONE_APPEND as a forbidden command. White lines are added around the group of BUG_ON() calls to make the code more legible. Signed-off-by: Damien Le Moal Signed-off-by: Mike Snitzer Signed-off-by: Sasha Levin --- drivers/md/dm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 3f3be9408afa..05747d2736a7 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1239,8 +1239,8 @@ static int dm_dax_zero_page_range(struct dax_device *dax_dev, pgoff_t pgoff, /* * A target may call dm_accept_partial_bio only from the map routine. It is - * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_RESET, - * REQ_OP_ZONE_OPEN, REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH. + * allowed for all bio types except REQ_PREFLUSH, REQ_OP_ZONE_* zone management + * operations and REQ_OP_ZONE_APPEND (zone append writes). * * dm_accept_partial_bio informs the dm that the target only wants to process * additional n_sectors sectors of the bio and the rest of the data should be @@ -1270,9 +1270,13 @@ void dm_accept_partial_bio(struct bio *bio, unsigned n_sectors) { struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); unsigned bi_size = bio->bi_iter.bi_size >> SECTOR_SHIFT; + BUG_ON(bio->bi_opf & REQ_PREFLUSH); + BUG_ON(op_is_zone_mgmt(bio_op(bio))); + BUG_ON(bio_op(bio) == REQ_OP_ZONE_APPEND); BUG_ON(bi_size > *tio->len_ptr); BUG_ON(n_sectors > bi_size); + *tio->len_ptr -= bi_size - n_sectors; bio->bi_iter.bi_size = n_sectors << SECTOR_SHIFT; } -- 2.30.2