<feed xmlns='http://www.w3.org/2005/Atom'>
<title>lwn.git/drivers/md/dm-verity-fec.c, branch v6.5</title>
<subtitle>Linux kernel documentation tree maintained by Jonathan Corbet</subtitle>
<id>http://mirrors.hust.edu.cn/git/lwn.git/atom?h=v6.5</id>
<link rel='self' href='http://mirrors.hust.edu.cn/git/lwn.git/atom?h=v6.5'/>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/'/>
<updated>2023-06-12T14:04:05+00:00</updated>
<entry>
<title>block: replace fmode_t with a block-specific type for block open flags</title>
<updated>2023-06-12T14:04:05+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2023-06-08T11:02:55+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=05bdb9965305bbfdae79b31d22df03d1e2cfcb22'/>
<id>urn:sha1:05bdb9965305bbfdae79b31d22df03d1e2cfcb22</id>
<content type='text'>
The only overlap between the block open flags mapped into the fmode_t and
other uses of fmode_t are FMODE_READ and FMODE_WRITE.  Define a new
blk_mode_t instead for use in blkdev_get_by_{dev,path}, -&gt;open and
-&gt;ioctl and stop abusing fmode_t.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Acked-by: Jack Wang &lt;jinpu.wang@ionos.com&gt;		[rnbd]
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Reviewed-by: Christian Brauner &lt;brauner@kernel.org&gt;
Link: https://lore.kernel.org/r/20230608110258.189493-28-hch@lst.de
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>dm: remove unnecessary (void*) conversions</title>
<updated>2023-04-11T16:01:01+00:00</updated>
<author>
<name>Yu Zhe</name>
<email>yuzhe@nfschina.com</email>
</author>
<published>2023-03-17T01:35:54+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=26cb62a285802ab6d26cdbf11305cd8516871d1a'/>
<id>urn:sha1:26cb62a285802ab6d26cdbf11305cd8516871d1a</id>
<content type='text'>
Pointer variables of void * type do not require type cast.

Signed-off-by: Yu Zhe &lt;yuzhe@nfschina.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@kernel.org&gt;
</content>
</entry>
<entry>
<title>dm: change "unsigned" to "unsigned int"</title>
<updated>2023-02-14T19:23:06+00:00</updated>
<author>
<name>Heinz Mauelshagen</name>
<email>heinzm@redhat.com</email>
</author>
<published>2023-01-25T20:14:58+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=86a3238c7b9b759cb864f4f768ab2e24687dc0e6'/>
<id>urn:sha1:86a3238c7b9b759cb864f4f768ab2e24687dc0e6</id>
<content type='text'>
Signed-off-by: Heinz Mauelshagen &lt;heinzm@redhat.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@kernel.org&gt;
</content>
</entry>
<entry>
<title>dm bufio: Add flags argument to dm_bufio_client_create</title>
<updated>2022-07-28T21:46:14+00:00</updated>
<author>
<name>Nathan Huckleberry</name>
<email>nhuck@google.com</email>
</author>
<published>2022-07-22T09:38:21+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=0fcb100d50835d6823723ef0898cd565b3796e0a'/>
<id>urn:sha1:0fcb100d50835d6823723ef0898cd565b3796e0a</id>
<content type='text'>
Add a flags argument to dm_bufio_client_create and update all the
callers. This is in preparation to add the DM_BUFIO_NO_SLEEP flag.

Signed-off-by: Nathan Huckleberry &lt;nhuck@google.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@kernel.org&gt;
</content>
</entry>
<entry>
<title>dm verity fec: fix misaligned RS roots IO</title>
<updated>2021-04-14T18:28:29+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk@google.com</email>
</author>
<published>2021-04-14T15:28:28+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=8ca7cab82bda4eb0b8064befeeeaa38106cac637'/>
<id>urn:sha1:8ca7cab82bda4eb0b8064befeeeaa38106cac637</id>
<content type='text'>
commit df7b59ba9245 ("dm verity: fix FEC for RS roots unaligned to
block size") introduced the possibility for misaligned roots IO
relative to the underlying device's logical block size. E.g. Android's
default RS roots=2 results in dm_bufio-&gt;block_size=1024, which causes
the following EIO if the logical block size of the device is 4096,
given v-&gt;data_dev_block_bits=12:

E sd 0    : 0:0:0: [sda] tag#30 request not aligned to the logical block size
E blk_update_request: I/O error, dev sda, sector 10368424 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0
E device-mapper: verity-fec: 254:8: FEC 9244672: parity read failed (block 18056): -5

Fix this by onlu using f-&gt;roots for dm_bufio blocksize IFF it is
aligned to v-&gt;data_dev_block_bits.

Fixes: df7b59ba9245 ("dm verity: fix FEC for RS roots unaligned to block size")
Cc: stable@vger.kernel.org
Signed-off-by: Jaegeuk Kim &lt;jaegeuk@google.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm verity: fix FEC for RS roots unaligned to block size</title>
<updated>2021-03-04T20:08:18+00:00</updated>
<author>
<name>Milan Broz</name>
<email>gmazyland@gmail.com</email>
</author>
<published>2021-02-23T20:21:21+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=df7b59ba9245c4a3115ebaa905e3e5719a3810da'/>
<id>urn:sha1:df7b59ba9245c4a3115ebaa905e3e5719a3810da</id>
<content type='text'>
Optional Forward Error Correction (FEC) code in dm-verity uses
Reed-Solomon code and should support roots from 2 to 24.

The error correction parity bytes (of roots lengths per RS block) are
stored on a separate device in sequence without any padding.

Currently, to access FEC device, the dm-verity-fec code uses dm-bufio
client with block size set to verity data block (usually 4096 or 512
bytes).

Because this block size is not divisible by some (most!) of the roots
supported lengths, data repair cannot work for partially stored parity
bytes.

This fix changes FEC device dm-bufio block size to "roots &lt;&lt; SECTOR_SHIFT"
where we can be sure that the full parity data is always available.
(There cannot be partial FEC blocks because parity must cover whole
sectors.)

Because the optional FEC starting offset could be unaligned to this
new block size, we have to use dm_bufio_set_sector_offset() to
configure it.

The problem is easily reproduced using veritysetup, e.g. for roots=13:

  # create verity device with RS FEC
  dd if=/dev/urandom of=data.img bs=4096 count=8 status=none
  veritysetup format data.img hash.img --fec-device=fec.img --fec-roots=13 | awk '/^Root hash/{ print $3 }' &gt;roothash

  # create an erasure that should be always repairable with this roots setting
  dd if=/dev/zero of=data.img conv=notrunc bs=1 count=8 seek=4088 status=none

  # try to read it through dm-verity
  veritysetup open data.img test hash.img --fec-device=fec.img --fec-roots=13 $(cat roothash)
  dd if=/dev/mapper/test of=/dev/null bs=4096 status=noxfer
  # wait for possible recursive recovery in kernel
  udevadm settle
  veritysetup close test

With this fix, errors are properly repaired.
  device-mapper: verity-fec: 7:1: FEC 0: corrected 8 errors
  ...

Without it, FEC code usually ends on unrecoverable failure in RS decoder:
  device-mapper: verity-fec: 7:1: FEC 0: failed to correct: -74
  ...

This problem is present in all kernels since the FEC code's
introduction (kernel 4.5).

It is thought that this problem is not visible in Android ecosystem
because it always uses a default RS roots=2.

Depends-on: a14e5ec66a7a ("dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size")
Signed-off-by: Milan Broz &lt;gmazyland@gmail.com&gt;
Tested-by: Jérôme Carretero &lt;cJ-ko@zougloub.eu&gt;
Reviewed-by: Sami Tolvanen &lt;samitolvanen@google.com&gt;
Cc: stable@vger.kernel.org # 4.5+
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm verity fec: fix hash block number in verity_fec_decode</title>
<updated>2020-04-16T20:16:38+00:00</updated>
<author>
<name>Sunwook Eom</name>
<email>speed.eom@samsung.com</email>
</author>
<published>2020-04-10T03:54:19+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=ad4e80a639fc61d5ecebb03caa5cdbfb91fcebfc'/>
<id>urn:sha1:ad4e80a639fc61d5ecebb03caa5cdbfb91fcebfc</id>
<content type='text'>
The error correction data is computed as if data and hash blocks
were concatenated. But hash block number starts from v-&gt;hash_start.
So, we have to calculate hash block number based on that.

Fixes: a739ff3f543af ("dm verity: add support for forward error correction")
Cc: stable@vger.kernel.org
Signed-off-by: Sunwook Eom &lt;speed.eom@samsung.com&gt;
Reviewed-by: Sami Tolvanen &lt;samitolvanen@google.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>dm verity fec: fix memory leak in verity_fec_dtr</title>
<updated>2020-03-24T16:00:29+00:00</updated>
<author>
<name>Shetty, Harshini X (EXT-Sony Mobile)</name>
<email>Harshini.X.Shetty@sony.com</email>
</author>
<published>2020-03-17T09:15:45+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=75fa601934fda23d2f15bf44b09c2401942d8e15'/>
<id>urn:sha1:75fa601934fda23d2f15bf44b09c2401942d8e15</id>
<content type='text'>
Fix below kmemleak detected in verity_fec_ctr. output_pool is
allocated for each dm-verity-fec device. But it is not freed when
dm-table for the verity target is removed. Hence free the output
mempool in destructor function verity_fec_dtr.

unreferenced object 0xffffffffa574d000 (size 4096):
  comm "init", pid 1667, jiffies 4294894890 (age 307.168s)
  hex dump (first 32 bytes):
    8e 36 00 98 66 a8 0b 9b 00 00 00 00 00 00 00 00  .6..f...........
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [&lt;0000000060e82407&gt;] __kmalloc+0x2b4/0x340
    [&lt;00000000dd99488f&gt;] mempool_kmalloc+0x18/0x20
    [&lt;000000002560172b&gt;] mempool_init_node+0x98/0x118
    [&lt;000000006c3574d2&gt;] mempool_init+0x14/0x20
    [&lt;0000000008cb266e&gt;] verity_fec_ctr+0x388/0x3b0
    [&lt;000000000887261b&gt;] verity_ctr+0x87c/0x8d0
    [&lt;000000002b1e1c62&gt;] dm_table_add_target+0x174/0x348
    [&lt;000000002ad89eda&gt;] table_load+0xe4/0x328
    [&lt;000000001f06f5e9&gt;] dm_ctl_ioctl+0x3b4/0x5a0
    [&lt;00000000bee5fbb7&gt;] do_vfs_ioctl+0x5dc/0x928
    [&lt;00000000b475b8f5&gt;] __arm64_sys_ioctl+0x70/0x98
    [&lt;000000005361e2e8&gt;] el0_svc_common+0xa0/0x158
    [&lt;000000001374818f&gt;] el0_svc_handler+0x6c/0x88
    [&lt;000000003364e9f4&gt;] el0_svc+0x8/0xc
    [&lt;000000009d84cec9&gt;] 0xffffffffffffffff

Fixes: a739ff3f543af ("dm verity: add support for forward error correction")
Depends-on: 6f1c819c219f7 ("dm: convert to bioset_init()/mempool_init()")
Cc: stable@vger.kernel.org
Signed-off-by: Harshini Shetty &lt;harshini.x.shetty@sony.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
<entry>
<title>treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152</title>
<updated>2019-05-30T18:26:32+00:00</updated>
<author>
<name>Thomas Gleixner</name>
<email>tglx@linutronix.de</email>
</author>
<published>2019-05-27T06:55:01+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=2874c5fd284268364ece81a7bd936f3c8168e567'/>
<id>urn:sha1:2874c5fd284268364ece81a7bd936f3c8168e567</id>
<content type='text'>
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 of the license or at
  your option any later version

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 3029 file(s).

Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Reviewed-by: Allison Randal &lt;allison@lohutok.net&gt;
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>dm verity fec: remove redundant unlikely annotation</title>
<updated>2019-03-05T19:53:48+00:00</updated>
<author>
<name>Chengguang Xu</name>
<email>cgxu519@gmx.com</email>
</author>
<published>2019-02-13T05:46:57+00:00</published>
<link rel='alternate' type='text/html' href='http://mirrors.hust.edu.cn/git/lwn.git/commit/?id=821b40da4d91839005166b808abdc6ca4f5235aa'/>
<id>urn:sha1:821b40da4d91839005166b808abdc6ca4f5235aa</id>
<content type='text'>
unlikely has already included in IS_ERR(),
so just remove redundant unlikely annotation.

Signed-off-by: Chengguang Xu &lt;cgxu519@gmx.com&gt;
Signed-off-by: Mike Snitzer &lt;snitzer@redhat.com&gt;
</content>
</entry>
</feed>
