Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp626802pxv; Thu, 15 Jul 2021 11:53:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKXRW9wuCBIRAL5WSBDJ4NezNMBrmrHf0fkdhJT1rjj3dHpSiGtOLl7dHV1Zi5Q2IT0GqD X-Received: by 2002:a92:cd8a:: with SMTP id r10mr3387752ilb.287.1626375238850; Thu, 15 Jul 2021 11:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375238; cv=none; d=google.com; s=arc-20160816; b=EDgATFdq8JKqXTe44nd0AJ2Lckgprao/L/z+e51oFvQfmvYB5uYV4k17JbPa1AjIQn 2Lq11IbpmnKhbR1kpTAHS3YZDw6Sboq1+tw8f8xxiHGK0sF7Ye5zUiAaDDcEHaoDLxf/ ulg7O/S7BdNetT71HzWMiBacuOshWy+CbxLW1Gj44lPQ+O3Bg5PwQOpy76cVYkxZb1Vi 2SxyTNdGEwc26dHUdXvrUWKbaOhB7EDJKviUsbeJCTdZVKGSjskQeG+b7JdXykosT6b6 GR51XvLJ7BihWYYTjxXyXMfV2YC8OQhOV3GrE3RsF2I5HI5s9mSwyWsMIlvyyZQAiB9b MqQA== 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=7ZqKhS158nbMk68b/Xhwgol4pzeGZBTg/b+sxvhCeFk=; b=hisDRifKhkJIEJ+/syDaGqTJRwN02gT7ElVVIjsPG6ALBIQ3wFmDo7wH6pU4h7hbBq dXIWjAQZTrn+TWwHsOw/0A4aTRcSeARPASqrdCYoY/AFDDhKG9zflLZgMNhNLeqGD0Cg XUGCdM5L+fzt9hE1/yAzV1BJ01L+CknCopWih62EvI42b3oaWnKqlf5n207FslCdmohr 6h+155R0iwr/buWys1qlQilz19giVPkiUwEGV5Cu6ev6sYb0sdR/b4EMiqyc58lz27u/ BQHjhyutj+OnynU2HAhGnpdz4L5JHNO8t0sZ2G6S/vuzaRhCbn7+J9C44F7QVId00P+2 kFEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gmYBUwMw; 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 k18si4847983ilq.10.2021.07.15.11.53.45; Thu, 15 Jul 2021 11:53:58 -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=gmYBUwMw; 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 S241625AbhGOSyf (ORCPT + 99 others); Thu, 15 Jul 2021 14:54:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:53266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231285AbhGOSu1 (ORCPT ); Thu, 15 Jul 2021 14:50:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD3D3613D8; Thu, 15 Jul 2021 18:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374854; bh=XTHGgfCtlB80EBeLshK0W/9LLK0O1nil14S3ALd6SGI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gmYBUwMwvX/TFxmUZKoM3UWQKKeD+Vk+tQjQo7ZBWwg9RY0D7QPnOHtZHvrvrYcu8 IaQAtk9DxSKtvtegxasX9hKRvE7LTXERE2JsBfXUrpbsg3i7tojTfJ4tts5Wg7qcyG A+RpdG9g0Sdsh4bhjlF44o+/daPJP++Yr1AZPp+4= 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.10 053/215] dm: Fix dm_accept_partial_bio() relative to zone management commands Date: Thu, 15 Jul 2021 20:37:05 +0200 Message-Id: <20210715182608.779324304@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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 638c04f9e832..19a70f434029 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1230,8 +1230,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 @@ -1261,9 +1261,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