Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp655051pxv; Thu, 15 Jul 2021 12:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxyAWhC2SY4XHFOBevC7UYysH/+KsCsV9GLTo+dbHiWF10fbn38SpomTbJDITmuAjuxEbb X-Received: by 2002:aa7:c550:: with SMTP id s16mr9259054edr.130.1626377775707; Thu, 15 Jul 2021 12:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377775; cv=none; d=google.com; s=arc-20160816; b=jAtY4aKhTuxPs8vodsBDGhQC0NTL2q16iuc5DArQMp9ihjI+eqp61UvD3T8ziQR1CD PrTwBhyg/KtyHVcotcJhfD5VMGWM/j6rzpwrbUUt3pkarJTdh31PvOK5g/SQ6VvIKgyk HAlAtRd+10H2x9GMZ57Y7ZfML75Cry3NZpZVjM19rQQzMHj6BpQqR80S9O2jycMY6pWt KuKbR5PhWfJzL2ZVOnuLVUBbxWGkRCyKqPU5ZNaqoNa2qcHt+Gl6BZEGr15MdvCl5EqQ XgrNcmfvJCc90Wb0HbALHY3p6qeUO4IZZTPlNKobr8OXDJC0zxMqkiblFJupIAxd4/pt 22Fw== 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=uPW4I0Ya/XyB8wHruGXZjRJR7MHiLn7QXw9c5O83adI=; b=TT1sfnRNANpkGNEgRwORyvjewwUKk/eoIMw6Pb93q57m/mAw5qbthPbQMwdP5h70f3 UsJtdchtemn0MAleJug5glFMym1OyYwIU76Nii8RRZ0ARBwJOm4Hc3NCHYVi2YivwF/X LK1V1pY3g6RUybKNTLhK1icPWIP+R6U9MEpbkwthJA5EqEsF0HW16vSFLms1EDbxH9qM yJgUIZs39HfaC8NXLgiQiengFEFNuhDcTms0zVDLrlu/krX0ul+jnLcg2ASoFzMdNerE 8zSmTS+zzY+XJaeuPLVJQVtVjl0sWpcHr4s+GXLktTfEgcPZKYZ2upDoccPRmi+IrTzR SHuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XlXgtBJT; 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 8si10165633ejx.637.2021.07.15.12.35.52; Thu, 15 Jul 2021 12:36:15 -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=XlXgtBJT; 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 S245706AbhGOTbx (ORCPT + 99 others); Thu, 15 Jul 2021 15:31:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:46538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243727AbhGOTKC (ORCPT ); Thu, 15 Jul 2021 15:10:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C1FB61403; Thu, 15 Jul 2021 19:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375984; bh=KNHNOZZ+57xbiph6fwgBKaFe7XtVUF36GtCnIH/qkvo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XlXgtBJTzatVOWecwtZ3P8XlVjzn/mDwU44Fu6CKjap3N+E3k7j7DC0E+T96fM1uN Sx8lZZvkrHSAV3EttpAy3Vvy5CZ+eyiQxHNZODiv25yEnDlXA0lO9De+WjO6IPa+dy M0o4yV4eP5joKBH2kd1vAqQvIKvsleJgWt1d6s3k= 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.13 070/266] dm: Fix dm_accept_partial_bio() relative to zone management commands Date: Thu, 15 Jul 2021 20:37:05 +0200 Message-Id: <20210715182626.549566706@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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 ca2aedd8ee7d..11af20080639 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1237,8 +1237,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 @@ -1268,9 +1268,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