From patchwork Fri Mar 27 14:01:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 11462423 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFAA26CA for ; Fri, 27 Mar 2020 14:08:49 +0000 (UTC) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 84518206F2 for ; Fri, 27 Mar 2020 14:08:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K9amgnnd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84518206F2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arrikto.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585318128; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ETNbbzbM82+LgfEXl+7sAYw7F4QBRB0+CFCiDQtgmrY=; b=K9amgnndweH/e+AUwS3wJ07JtOjBRUD18cFyE56oNj09RGhQdzGHCJ3Lz+Ewbe9PF/PQyX yDSz0zksdJ3E3s4LkUKI0+8igSDj/0tCtqVENMCTCdddaHxmof8qpRWkw0w/qMmF4wb+hI BrFvoriechvEeGrfm+SWDT0gw+f23eQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-FA5fAxyYM0aLqn-E7bul0g-1; Fri, 27 Mar 2020 10:08:46 -0400 X-MC-Unique: FA5fAxyYM0aLqn-E7bul0g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3368D107ACC4; Fri, 27 Mar 2020 14:08:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06B785C1BA; Fri, 27 Mar 2020 14:08:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8A5FC8A056; Fri, 27 Mar 2020 14:08:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RE8cVD007658 for ; Fri, 27 Mar 2020 10:08:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6DADC2166B2B; Fri, 27 Mar 2020 14:08:38 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6957B2166B2D for ; Fri, 27 Mar 2020 14:08:35 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A91BE8F784F for ; Fri, 27 Mar 2020 14:08:35 +0000 (UTC) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-256-ixfCwZhvPWarBiYpu8F0Gg-1; Fri, 27 Mar 2020 10:08:33 -0400 X-MC-Unique: ixfCwZhvPWarBiYpu8F0Gg-1 Received: by mail-pg1-f196.google.com with SMTP id b22so4619361pgb.6 for ; Fri, 27 Mar 2020 07:08:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ry/vDCGBU/wmPZGsuooji6NeOvuL2s5fj0a6lMjpAfs=; b=GtSu1nWzqsr1JnLngKmZfh4OujxiON9+W1pGkMw1SeG7XDkn4Y/2P6jgbg1pNdJ8wm YZSDXzY/tCCIR9wxj6kNLuzydqqUh0KG87RdsulXVzLX2k9FNFqcsh6HpNCXWzTCpNA6 coxoldduq5DA2igLm0nUcRH/ZTc1xysiff9LF5uducIABi42OcFhwLG8284gZ7Dc8N8S Kq2y1TlhlH9d1sIKm+5SlJ8ms6E7afoXv0ZcOtdEr/LFaAaBw6JPKimsMixLfGz7KOVz mjRGOEsuCPxPMw+qfieLj5GkHnZLlSGIa5VJpgC256nt0TDOVXGZNqmR0mJES5p4iMTt p+XA== X-Gm-Message-State: ANhLgQ1bAqhc6QDlMpOXGubZDr85+737rYurvXHPlGyb8RYhajdhs99d vSYrE8AicLK8qBrEz9ce4ziAbFgH7VQ= X-Google-Smtp-Source: ADFU+vuUfcaiTc+zdgbu2+m8dp3Tme9qGvg5ZhcUfnSRN0/+91ep3Qys7y91I7WrWNG66iuBrfva8g== X-Received: by 2002:a63:5d60:: with SMTP id o32mr13663279pgm.126.1585317755063; Fri, 27 Mar 2020 07:02:35 -0700 (PDT) Received: from snf-864.vm.snf.arr ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id l5sm3963399pgt.10.2020.03.27.07.02.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2020 07:02:33 -0700 (PDT) From: Nikos Tsironis To: agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com Date: Fri, 27 Mar 2020 16:01:08 +0200 Message-Id: <20200327140111.7798-2-ntsironis@arrikto.com> In-Reply-To: <20200327140111.7798-1-ntsironis@arrikto.com> References: <20200327140111.7798-1-ntsironis@arrikto.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02RE8cVD007658 X-loop: dm-devel@redhat.com Cc: ntsironis@arrikto.com Subject: [dm-devel] [PATCH 1/4] dm clone: Fix handling of partial region discards X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com There is a bug in the way dm-clone handles discards, which can lead to discarding the wrong blocks or trying to discard blocks beyond the end of the device. This could lead to data corruption, if the destination device indeed discards the underlying blocks, i.e., if the discard operation results in the original contents of a block to be lost. The root of the problem is the code that calculates the range of regions covered by a discard request and decides which regions to discard. Since dm-clone handles the device in units of regions, we don't discard parts of a region, only whole regions. The range is calculated as: rs = dm_sector_div_up(bio->bi_iter.bi_sector, clone->region_size); re = bio_end_sector(bio) >> clone->region_shift; , where 'rs' is the first region to discard and (re - rs) is the number of regions to discard. The bug manifests when we try to discard part of a single region, i.e., when we try to discard a block with size < region_size, and the discard request both starts at an offset with respect to the beginning of that region and ends before the end of the region. The root cause is the following comparison: if (rs == re) // skip discard and complete original bio immediately , which doesn't take into account that 'rs' might be greater than 're'. Thus, we then issue a discard request for the wrong blocks, instead of skipping the discard all together. Fix the check to also take into account the above case, so we don't end up discarding the wrong blocks. Also, add some range checks to dm_clone_set_region_hydrated() and dm_clone_cond_set_range(), which update dm-clone's region bitmap. Note that the aforementioned bug doesn't cause invalid memory accesses, because dm_clone_is_range_hydrated() returns True for this case, so the checks are just precautionary. Fixes: 7431b7835f55 ("dm: add clone target") Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Nikos Tsironis --- drivers/md/dm-clone-metadata.c | 13 +++++++++++++ drivers/md/dm-clone-target.c | 43 ++++++++++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/drivers/md/dm-clone-metadata.c b/drivers/md/dm-clone-metadata.c index c05b12110456..199e7af00858 100644 --- a/drivers/md/dm-clone-metadata.c +++ b/drivers/md/dm-clone-metadata.c @@ -850,6 +850,12 @@ int dm_clone_set_region_hydrated(struct dm_clone_metadata *cmd, unsigned long re struct dirty_map *dmap; unsigned long word, flags; + if (unlikely(region_nr >= cmd->nr_regions)) { + DMERR("Region %lu out of range (total number of regions %lu)", + region_nr, cmd->nr_regions); + return -ERANGE; + } + word = region_nr / BITS_PER_LONG; spin_lock_irqsave(&cmd->bitmap_lock, flags); @@ -879,6 +885,13 @@ int dm_clone_cond_set_range(struct dm_clone_metadata *cmd, unsigned long start, struct dirty_map *dmap; unsigned long word, region_nr; + if (unlikely(start >= cmd->nr_regions || (start + nr_regions) < start || + (start + nr_regions) > cmd->nr_regions)) { + DMERR("Invalid region range: start %lu, nr_regions %lu (total number of regions %lu)", + start, nr_regions, cmd->nr_regions); + return -ERANGE; + } + spin_lock_irq(&cmd->bitmap_lock); if (cmd->read_only) { diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c index d1e1b5b56b1b..022dddcad647 100644 --- a/drivers/md/dm-clone-target.c +++ b/drivers/md/dm-clone-target.c @@ -293,10 +293,17 @@ static inline unsigned long bio_to_region(struct clone *clone, struct bio *bio) /* Get the region range covered by the bio */ static void bio_region_range(struct clone *clone, struct bio *bio, - unsigned long *rs, unsigned long *re) + unsigned long *rs, unsigned long *nr_regions) { + unsigned long end; + *rs = dm_sector_div_up(bio->bi_iter.bi_sector, clone->region_size); - *re = bio_end_sector(bio) >> clone->region_shift; + end = bio_end_sector(bio) >> clone->region_shift; + + if (*rs >= end) + *nr_regions = 0; + else + *nr_regions = end - *rs; } /* Check whether a bio overwrites a region */ @@ -454,7 +461,7 @@ static void trim_bio(struct bio *bio, sector_t sector, unsigned int len) static void complete_discard_bio(struct clone *clone, struct bio *bio, bool success) { - unsigned long rs, re; + unsigned long rs, nr_regions; /* * If the destination device supports discards, remap and trim the @@ -463,9 +470,9 @@ static void complete_discard_bio(struct clone *clone, struct bio *bio, bool succ */ if (test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags) && success) { remap_to_dest(clone, bio); - bio_region_range(clone, bio, &rs, &re); + bio_region_range(clone, bio, &rs, &nr_regions); trim_bio(bio, rs << clone->region_shift, - (re - rs) << clone->region_shift); + nr_regions << clone->region_shift); generic_make_request(bio); } else bio_endio(bio); @@ -473,12 +480,21 @@ static void complete_discard_bio(struct clone *clone, struct bio *bio, bool succ static void process_discard_bio(struct clone *clone, struct bio *bio) { - unsigned long rs, re; + unsigned long rs, nr_regions; - bio_region_range(clone, bio, &rs, &re); - BUG_ON(re > clone->nr_regions); + bio_region_range(clone, bio, &rs, &nr_regions); + if (!nr_regions) { + bio_endio(bio); + return; + } - if (unlikely(rs == re)) { + if (WARN_ON(rs >= clone->nr_regions || (rs + nr_regions) < rs || + (rs + nr_regions) > clone->nr_regions)) { + DMERR("%s: Invalid range (%lu + %lu, total regions %lu) for discard (%llu + %u)", + clone_device_name(clone), rs, nr_regions, + clone->nr_regions, + (unsigned long long)bio->bi_iter.bi_sector, + bio_sectors(bio)); bio_endio(bio); return; } @@ -487,7 +503,7 @@ static void process_discard_bio(struct clone *clone, struct bio *bio) * The covered regions are already hydrated so we just need to pass * down the discard. */ - if (dm_clone_is_range_hydrated(clone->cmd, rs, re - rs)) { + if (dm_clone_is_range_hydrated(clone->cmd, rs, nr_regions)) { complete_discard_bio(clone, bio, true); return; } @@ -1169,7 +1185,7 @@ static void process_deferred_discards(struct clone *clone) int r = -EPERM; struct bio *bio; struct blk_plug plug; - unsigned long rs, re; + unsigned long rs, nr_regions; struct bio_list discards = BIO_EMPTY_LIST; spin_lock_irq(&clone->lock); @@ -1185,14 +1201,13 @@ static void process_deferred_discards(struct clone *clone) /* Update the metadata */ bio_list_for_each(bio, &discards) { - bio_region_range(clone, bio, &rs, &re); + bio_region_range(clone, bio, &rs, &nr_regions); /* * A discard request might cover regions that have been already * hydrated. There is no need to update the metadata for these * regions. */ - r = dm_clone_cond_set_range(clone->cmd, rs, re - rs); - + r = dm_clone_cond_set_range(clone->cmd, rs, nr_regions); if (unlikely(r)) break; } From patchwork Fri Mar 27 14:01:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 11462417 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 70E92159A for ; Fri, 27 Mar 2020 14:05:18 +0000 (UTC) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 354BE206F1 for ; Fri, 27 Mar 2020 14:05:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="G2Qr3uv7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 354BE206F1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arrikto.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585317917; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=r0Tq6EXS+ah/FVxdyzBgA27Xk4dBUaab0aiNZIo3dPg=; b=G2Qr3uv7kwcy4JZH0Itz954jYJyPU1GIw2NtnBR17vQN0p7EYjVe+xwOczhwokdOMnfwEB OiqxgnBltJt2P5xITd5Iv9eqLLfqAJZVgWaJAzx7ZLAm2qlflTTbP4qjnjxz3vSjVH9Ugc ifrz2wsbmiK+G/4J3kl4fqBZCAT44k8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-231-SPrDIelXPAuh8GDdp8dQmw-1; Fri, 27 Mar 2020 10:05:15 -0400 X-MC-Unique: SPrDIelXPAuh8GDdp8dQmw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17536801A01; Fri, 27 Mar 2020 14:05:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D7AD260C18; Fri, 27 Mar 2020 14:05:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7F89718089CD; Fri, 27 Mar 2020 14:05:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RE2mMZ007378 for ; Fri, 27 Mar 2020 10:02:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id E1BE21006B14; Fri, 27 Mar 2020 14:02:47 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE02610073A5 for ; Fri, 27 Mar 2020 14:02:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15E98101A55F for ; Fri, 27 Mar 2020 14:02:45 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-fRZ4F8gqNKuL10k6WioyDw-1; Fri, 27 Mar 2020 10:02:43 -0400 X-MC-Unique: fRZ4F8gqNKuL10k6WioyDw-1 Received: by mail-pg1-f194.google.com with SMTP id k5so2405446pga.2 for ; Fri, 27 Mar 2020 07:02:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=rW3ignUIeOl2OnTc6gMdisGesKp/nH9u+goPdHkYQgo=; b=RTxlFVDZPkCQ7XGX5FVXbX5+66HfLrpjpwHkBlwNOeMU8drfKeXJk7RorR5o7hnpXY fJ/5a0FT0ateClMmPtzeSsbH18PlWBZuM4Z2Ra0QYu6ztME9b/7SLxNoUJs+xPV7RCf9 dflTgJ1y8GrmVdIH1GzH151LU6jEWUQUYDUUIliN6etGplcxAfnFaJq6/mTsOiIy4480 pFvShrtV9mtIogdh2C1YAa5JZsP90bPQspzOZSqQYPZSym7mouDZ0YjrttUKnlaGFlW1 oQReO+oIg8HnneJAy+E9yBjz1jn6X+e0lg8N0Aa2QJauJjbkgylUr0dZXh91yGks45Sd pI6Q== X-Gm-Message-State: ANhLgQ21fFNaIAmJkvX6KuwBsk1Cw1ktlZZ22e6o8cB8FLiIFzkq9JAL t3UQypFPu5RCz28JKm5sFxqKaA== X-Google-Smtp-Source: ADFU+vvF46UoCT2g7L8jezEAr5ZP+s0gICkQMIVugwgY9CYj3yw+MC6WF65e3cJpbugLkAu0dgl0ng== X-Received: by 2002:a62:cdcc:: with SMTP id o195mr14883361pfg.323.1585317758488; Fri, 27 Mar 2020 07:02:38 -0700 (PDT) Received: from snf-864.vm.snf.arr ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id l5sm3963399pgt.10.2020.03.27.07.02.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2020 07:02:37 -0700 (PDT) From: Nikos Tsironis To: agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com Date: Fri, 27 Mar 2020 16:01:09 +0200 Message-Id: <20200327140111.7798-3-ntsironis@arrikto.com> In-Reply-To: <20200327140111.7798-1-ntsironis@arrikto.com> References: <20200327140111.7798-1-ntsironis@arrikto.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02RE2mMZ007378 X-loop: dm-devel@redhat.com Cc: ntsironis@arrikto.com Subject: [dm-devel] [PATCH 2/4] dm clone: Add overflow check for number of regions X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Add overflow check for clone->nr_regions variable, which holds the number of regions of the target. The overflow can occur with sufficiently large devices, if BITS_PER_LONG == 32. E.g., if the region size is 8 sectors (4K), the overflow would occur for device sizes > 34359738360 sectors (~16TB). This could result in multiple device sectors wrongly mapping to the same region number, due to the truncation from 64 bits to 32 bits, which would lead to data corruption. Fixes: 7431b7835f55 ("dm: add clone target") Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Nikos Tsironis --- drivers/md/dm-clone-target.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c index 022dddcad647..6ee85fb3388a 100644 --- a/drivers/md/dm-clone-target.c +++ b/drivers/md/dm-clone-target.c @@ -1790,6 +1790,7 @@ static int copy_ctr_args(struct clone *clone, int argc, const char **argv, char static int clone_ctr(struct dm_target *ti, unsigned int argc, char **argv) { int r; + sector_t nr_regions; struct clone *clone; struct dm_arg_set as; @@ -1831,7 +1832,16 @@ static int clone_ctr(struct dm_target *ti, unsigned int argc, char **argv) goto out_with_source_dev; clone->region_shift = __ffs(clone->region_size); - clone->nr_regions = dm_sector_div_up(ti->len, clone->region_size); + nr_regions = dm_sector_div_up(ti->len, clone->region_size); + + /* Check for overflow */ + if (nr_regions != (unsigned long)nr_regions) { + ti->error = "Too many regions. Consider increasing the region size"; + r = -EOVERFLOW; + goto out_with_source_dev; + } + + clone->nr_regions = nr_regions; r = validate_nr_regions(clone->nr_regions, &ti->error); if (r) From patchwork Fri Mar 27 14:01:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 11462415 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 332A9159A for ; Fri, 27 Mar 2020 14:05:14 +0000 (UTC) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2FF3206F1 for ; Fri, 27 Mar 2020 14:05:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bhCbB3Oz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E2FF3206F1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arrikto.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585317912; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PQc5bT2cIjGgR6ToXARNn1tu6cVxejUHmPdS4MHM/gA=; b=bhCbB3Ozak/k5vo1MTBvknHj7dPVg24XhDa9GTAzasm8pbW4U0Jc1ABGk6H235Xrwe9Q2w EZ5/d6rDBRZURzLfBl7tl4AXKmAakNrNQrK7vsuEVcBcH1hx0p9tO1beeKz+wFODomF9n5 BsjclQG17CloRaGoiaQsXoakvGwPJJU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-YfDKvqDYNsmT_YXOtHj2gQ-1; Fri, 27 Mar 2020 10:05:08 -0400 X-MC-Unique: YfDKvqDYNsmT_YXOtHj2gQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EC3E18A6EC4; Fri, 27 Mar 2020 14:05:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D043019925; Fri, 27 Mar 2020 14:05:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 25CF41809567; Fri, 27 Mar 2020 14:05:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RE2l24007373 for ; Fri, 27 Mar 2020 10:02:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27A1D2166B2C; Fri, 27 Mar 2020 14:02:47 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23E572166B2B for ; Fri, 27 Mar 2020 14:02:47 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A1438F7853 for ; Fri, 27 Mar 2020 14:02:47 +0000 (UTC) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-c3sclVv9OyOh1q00ynCKFQ-1; Fri, 27 Mar 2020 10:02:44 -0400 X-MC-Unique: c3sclVv9OyOh1q00ynCKFQ-1 Received: by mail-pl1-f195.google.com with SMTP id s23so3464906plq.13 for ; Fri, 27 Mar 2020 07:02:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xaosDm8ppIhl5+5QzS9SaIbdpa9cbjV5hMnDkIcgqb8=; b=lL8MxqZD2Tg18bGWCoTSE/vVfb5kEewt73+T9eSKsEuvDesWgPJv8JlU48NsmUj6ex Jur3cuJ2rsm+LJQPTVndDBbU4zJ8AUEoBSuNHb9tIhXCv8VkcTugL94IPD7OeNK3xFPR ZMQeI/XYVdDXzndcgRP/AFV7kkZdmaRXHMstD9d0/f3X0DKR58nxYDYewv5gHP0ttClv h/RypkMB0IwvfUd3CPnGiIM9dyp8kl0EhgnlUd1lEU391JNS0qzZm+Z/hvArmgbqBzUP wABXPUxn/92+iQeAG0LwHUF1BXItFaSlywRNEqu0lONcovTk63NBxddVw+EHmQIE0Teg lktg== X-Gm-Message-State: ANhLgQ1V43/cByjWYadu2Oh/CtSrvfJ9l98B/gefl/ajnTf8xV/MCxfl qPmkPnl2qss4iPW3NCsx8yDDIw== X-Google-Smtp-Source: ADFU+vvncOxNZ3U78mkhELkPUjrsFXEUD+KEx5k1rEla9DkyATWij4TrQ7z2ysDBCGwhtP/X/5l15Q== X-Received: by 2002:a17:902:6945:: with SMTP id k5mr13279901plt.61.1585317763507; Fri, 27 Mar 2020 07:02:43 -0700 (PDT) Received: from snf-864.vm.snf.arr ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id l5sm3963399pgt.10.2020.03.27.07.02.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2020 07:02:41 -0700 (PDT) From: Nikos Tsironis To: agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com Date: Fri, 27 Mar 2020 16:01:10 +0200 Message-Id: <20200327140111.7798-4-ntsironis@arrikto.com> In-Reply-To: <20200327140111.7798-1-ntsironis@arrikto.com> References: <20200327140111.7798-1-ntsironis@arrikto.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02RE2l24007373 X-loop: dm-devel@redhat.com Cc: ntsironis@arrikto.com Subject: [dm-devel] [PATCH 3/4] dm clone: Add missing casts to prevent overflows and data corruption X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Add missing casts when converting from regions to sectors. In case BITS_PER_LONG == 32, the lack of the appropriate casts can lead to overflows and miscalculation of the device sector. As a result, we could end up discarding and/or copying the wrong parts of the device, thus corrupting the device's data. Fixes: 7431b7835f55 ("dm: add clone target") Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Nikos Tsironis --- drivers/md/dm-clone-target.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c index 6ee85fb3388a..ca5020c58f7c 100644 --- a/drivers/md/dm-clone-target.c +++ b/drivers/md/dm-clone-target.c @@ -282,7 +282,7 @@ static bool bio_triggers_commit(struct clone *clone, struct bio *bio) /* Get the address of the region in sectors */ static inline sector_t region_to_sector(struct clone *clone, unsigned long region_nr) { - return (region_nr << clone->region_shift); + return ((sector_t)region_nr << clone->region_shift); } /* Get the region number of the bio */ @@ -471,7 +471,7 @@ static void complete_discard_bio(struct clone *clone, struct bio *bio, bool succ if (test_bit(DM_CLONE_DISCARD_PASSDOWN, &clone->flags) && success) { remap_to_dest(clone, bio); bio_region_range(clone, bio, &rs, &nr_regions); - trim_bio(bio, rs << clone->region_shift, + trim_bio(bio, region_to_sector(clone, rs), nr_regions << clone->region_shift); generic_make_request(bio); } else @@ -804,11 +804,14 @@ static void hydration_copy(struct dm_clone_region_hydration *hd, unsigned int nr struct dm_io_region from, to; struct clone *clone = hd->clone; + if (WARN_ON(!nr_regions)) + return; + region_size = clone->region_size; region_start = hd->region_nr; region_end = region_start + nr_regions - 1; - total_size = (nr_regions - 1) << clone->region_shift; + total_size = region_to_sector(clone, nr_regions - 1); if (region_end == clone->nr_regions - 1) { /* From patchwork Fri Mar 27 14:01:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 11462419 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B14B16CA for ; Fri, 27 Mar 2020 14:05:23 +0000 (UTC) Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 757F3206F1 for ; Fri, 27 Mar 2020 14:05:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="InfqP76S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 757F3206F1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arrikto.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585317922; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZJ3h39xT9xHRh7rK/GqVFKzJU1XV2gpRfiaAB8LBknc=; b=InfqP76S/78A8eDgoEBmJeauJyV/nLInFaGfv2tuvNrTIkC3dju0NFVe+hjHDB7ciz+LjE nsgPhdoNRnoj+xmchsQDA+ZHXCthWftVgirW2EP8if3/Ju1cJjKMbXou6f32Wvyd1VRbHr DLq/jw97ZVrafor9EdmmeokaKrtQ8O8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-8BnuxWObPLyZMQOC8IlwQw-1; Fri, 27 Mar 2020 10:05:18 -0400 X-MC-Unique: 8BnuxWObPLyZMQOC8IlwQw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD58B801A03; Fri, 27 Mar 2020 14:05:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A28FF1001DDE; Fri, 27 Mar 2020 14:05:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 562468A056; Fri, 27 Mar 2020 14:05:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02RE2qGv007394 for ; Fri, 27 Mar 2020 10:02:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id E457A2166B2D; Fri, 27 Mar 2020 14:02:51 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E07182166B2C for ; Fri, 27 Mar 2020 14:02:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5AE68F7850 for ; Fri, 27 Mar 2020 14:02:51 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-54-KOr7VC66MtmjuzfouVuRNQ-1; Fri, 27 Mar 2020 10:02:49 -0400 X-MC-Unique: KOr7VC66MtmjuzfouVuRNQ-1 Received: by mail-pf1-f195.google.com with SMTP id 23so4563643pfj.1 for ; Fri, 27 Mar 2020 07:02:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0m7ChndtR/eINjBLLkxaAY+V07LwwtZJQ4kPgtgER5o=; b=M0p6nphFKDROmHytWYKb6uKPs4oLrC5jilPh6amrVvCWHr1wPIavLI17e8+VnxNSlN DzyV6eR3tmU5af2APigR4xdgAfkAxzDy1uLrPOBgZahuY7Sx3j3bycIkb/Gx0CfZySxm 2ozVHrAtFEVZuDYOsGUFHiCmfVVGSt+QBReQWHu9SHTGg7Nk+Gy1rVddfjYdeLov7rx5 oZIwQJ1xcT15GR1Bg8GMnpXqFijVbnS+D+4tL/BqD4TDATSAduhh3UIr5TxUbNWRE7a3 wmxiGIaCiuwMcE7jch4xk03SEpe1FCmrG+AZv6MuO2to68ZkB1TefCacZxybCoVGdmsh vMrA== X-Gm-Message-State: ANhLgQ3fK/DDfrTp/WoGW/9LLMm8G68GI5UunrAcempQzFuGmM051Sk6 XWACyZpO5WgMNqSnEOL6gbKU+Q== X-Google-Smtp-Source: ADFU+vumPBnDmuhJ4RaYTscuoCw+QpxIgO8n9S3BBJjZNvahgAablPUwiOgh5MFib+vx1PKNQ+5x5g== X-Received: by 2002:a63:e141:: with SMTP id h1mr13615045pgk.129.1585317767022; Fri, 27 Mar 2020 07:02:47 -0700 (PDT) Received: from snf-864.vm.snf.arr ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id l5sm3963399pgt.10.2020.03.27.07.02.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Mar 2020 07:02:46 -0700 (PDT) From: Nikos Tsironis To: agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com Date: Fri, 27 Mar 2020 16:01:11 +0200 Message-Id: <20200327140111.7798-5-ntsironis@arrikto.com> In-Reply-To: <20200327140111.7798-1-ntsironis@arrikto.com> References: <20200327140111.7798-1-ntsironis@arrikto.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 02RE2qGv007394 X-loop: dm-devel@redhat.com Cc: ntsironis@arrikto.com Subject: [dm-devel] [PATCH 4/4] dm clone metadata: Fix return type of dm_clone_nr_of_hydrated_regions() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com dm_clone_nr_of_hydrated_regions() returns the number of regions that have been hydrated so far. In order to do so it employs bitmap_weight(). Until now, the return type of dm_clone_nr_of_hydrated_regions() was unsigned long. Because bitmap_weight() returns an int, in case BITS_PER_LONG == 64 and the return value of bitmap_weight() is 2^31 (the maximum allowed number of regions for a device), the result is sign extended from 32 bits to 64 bits and an incorrect value is displayed, in the status output of dm-clone, as the number of hydrated regions. Fix this by having dm_clone_nr_of_hydrated_regions() return an unsigned int. Fixes: 7431b7835f55 ("dm: add clone target") Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Nikos Tsironis --- drivers/md/dm-clone-metadata.c | 2 +- drivers/md/dm-clone-metadata.h | 2 +- drivers/md/dm-clone-target.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm-clone-metadata.c b/drivers/md/dm-clone-metadata.c index 199e7af00858..17712456fa63 100644 --- a/drivers/md/dm-clone-metadata.c +++ b/drivers/md/dm-clone-metadata.c @@ -656,7 +656,7 @@ bool dm_clone_is_range_hydrated(struct dm_clone_metadata *cmd, return (bit >= (start + nr_regions)); } -unsigned long dm_clone_nr_of_hydrated_regions(struct dm_clone_metadata *cmd) +unsigned int dm_clone_nr_of_hydrated_regions(struct dm_clone_metadata *cmd) { return bitmap_weight(cmd->region_map, cmd->nr_regions); } diff --git a/drivers/md/dm-clone-metadata.h b/drivers/md/dm-clone-metadata.h index 14af1ebd853f..d848b8799c07 100644 --- a/drivers/md/dm-clone-metadata.h +++ b/drivers/md/dm-clone-metadata.h @@ -156,7 +156,7 @@ bool dm_clone_is_range_hydrated(struct dm_clone_metadata *cmd, /* * Returns the number of hydrated regions. */ -unsigned long dm_clone_nr_of_hydrated_regions(struct dm_clone_metadata *cmd); +unsigned int dm_clone_nr_of_hydrated_regions(struct dm_clone_metadata *cmd); /* * Returns the first unhydrated region with region_nr >= @start diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c index ca5020c58f7c..5ce96ddf1ce1 100644 --- a/drivers/md/dm-clone-target.c +++ b/drivers/md/dm-clone-target.c @@ -1473,7 +1473,7 @@ static void clone_status(struct dm_target *ti, status_type_t type, goto error; } - DMEMIT("%u %llu/%llu %llu %lu/%lu %u ", + DMEMIT("%u %llu/%llu %llu %u/%lu %u ", DM_CLONE_METADATA_BLOCK_SIZE, (unsigned long long)(nr_metadata_blocks - nr_free_metadata_blocks), (unsigned long long)nr_metadata_blocks,