<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/verity/verify.c, branch linux-6.15.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-6.15.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2024-02-01T23:19:23Z</updated>
<entry>
<title>fsverity: remove hash page spin lock</title>
<updated>2024-02-01T23:19:23Z</updated>
<author>
<name>Andrey Albershteyn</name>
</author>
<published>2024-02-01T05:28:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8e43fb06e10d2c811797740dd578c5099a3e6378'/>
<id>urn:sha1:8e43fb06e10d2c811797740dd578c5099a3e6378</id>
<content type='text'>
The spin lock is not necessary here as it can be replaced with
memory barrier which should be better performance-wise.

When Merkle tree block size differs from page size, in
is_hash_block_verified() two things are modified during check - a
bitmap and PG_checked flag of the page.

Each bit in the bitmap represent verification status of the Merkle
tree blocks. PG_checked flag tells if page was just re-instantiated
or was in pagecache. Both of this states are shared between
verification threads. Page which was re-instantiated can not have
already verified blocks (bit set in bitmap).

The spin lock was used to allow only one thread to modify both of
these states and keep order of operations. The only requirement here
is that PG_Checked is set strictly after bitmap is updated.
This way other threads which see that PG_Checked=1 (page cached)
knows that bitmap is up-to-date. Otherwise, if PG_Checked is set
before bitmap is cleared, other threads can see bit=1 and therefore
will not perform verification of that Merkle tree block.

However, there's still the case when one thread is setting a bit in
verify_data_block() and other thread is clearing it in
is_hash_block_verified(). This can happen if two threads get to
!PageChecked branch and one of the threads is rescheduled before
resetting the bitmap. This is fine as at worst blocks are
re-verified in each thread.

Signed-off-by: Andrey Albershteyn &lt;aalbersh@redhat.com&gt;
[ebiggers: improved the comment and removed the 'verified' variable]
Link: https://lore.kernel.org/r/20240201052813.68380-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
</content>
</entry>
<entry>
<title>fsverity: simplify handling of errors during initcall</title>
<updated>2023-07-12T05:49:18Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2023-07-05T21:27:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e77000ccc531088c486fe5fbd13416fd5e3d2714'/>
<id>urn:sha1:e77000ccc531088c486fe5fbd13416fd5e3d2714</id>
<content type='text'>
Since CONFIG_FS_VERITY is a bool, not a tristate, fs/verity/ can only be
builtin or absent entirely; it can't be a loadable module.  Therefore,
the error code that gets returned from the fsverity_init() initcall is
never used.  If any part of the initcall does fail, which should never
happen, the kernel will be left in a bad state.

Following the usual convention for builtin code, just panic the kernel
if any of part of the initcall fails.

Link: https://lore.kernel.org/r/20230705212743.42180-2-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
</content>
</entry>
<entry>
<title>fsverity: simplify error handling in verify_data_block()</title>
<updated>2023-06-04T12:56:11Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2023-06-04T02:23:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=13e2408d02dd12a3b46bf8a29b3ae4f6119fc520'/>
<id>urn:sha1:13e2408d02dd12a3b46bf8a29b3ae4f6119fc520</id>
<content type='text'>
Clean up the error handling in verify_data_block() to (a) eliminate the
'err' variable which has caused some confusion because the function
actually returns a bool, (b) reduce the compiled code size slightly, and
(c) execute one fewer branch in the success case.

Link: https://lore.kernel.org/r/20230604022312.48532-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
</content>
</entry>
<entry>
<title>fsverity: don't use bio_first_page_all() in fsverity_verify_bio()</title>
<updated>2023-06-04T12:56:11Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2023-06-04T02:21:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d1f0c5ea04cd0a93309de0246278f0b22394692d'/>
<id>urn:sha1:d1f0c5ea04cd0a93309de0246278f0b22394692d</id>
<content type='text'>
bio_first_page_all(bio)-&gt;mapping-&gt;host is not compatible with large
folios, since the first page of the bio is not necessarily the head page
of the folio, and therefore it might not have the mapping pointer set.

Therefore, move the dereference of -&gt;mapping-&gt;host into
verify_data_blocks(), which works with a folio.

(Like the commit that this Fixes, this hasn't actually been tested with
large folios yet, since the filesystems that use fs/verity/ don't
support that yet.  But based on code review, I think this is needed.)

Fixes: 5d0f0e57ed90 ("fsverity: support verifying data from large folios")
Link: https://lore.kernel.org/r/20230604022101.48342-1-ebiggers@kernel.org
Reviewed-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
</content>
</entry>
<entry>
<title>fsverity: use shash API instead of ahash API</title>
<updated>2023-06-04T12:54:28Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2023-05-16T05:12:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8fcd94add6c5c93ed3b9314456e8420914401530'/>
<id>urn:sha1:8fcd94add6c5c93ed3b9314456e8420914401530</id>
<content type='text'>
The "ahash" API, like the other scatterlist-based crypto APIs such as
"skcipher", comes with some well-known limitations.  First, it can't
easily be used with vmalloc addresses.  Second, the request struct can't
be allocated on the stack.  This adds complexity and a possible failure
point that needs to be worked around, e.g. using a mempool.

The only benefit of ahash over "shash" is that ahash is needed to access
traditional memory-to-memory crypto accelerators, i.e. drivers/crypto/.
However, this style of crypto acceleration has largely fallen out of
favor and been superseded by CPU-based acceleration or inline crypto
engines.  Also, ahash needs to be used asynchronously to take full
advantage of such hardware, but fs/verity/ has never done this.

On all systems that aren't actually using one of these ahash-only crypto
accelerators, ahash just adds unnecessary overhead as it sits between
the user and the underlying shash algorithms.

Also, XFS is planned to cache fsverity Merkle tree blocks in the
existing XFS buffer cache.  As a result, it will be possible for a
single Merkle tree block to be split across discontiguous pages
(https://lore.kernel.org/r/20230405233753.GU3223426@dread.disaster.area).
This data will need to be hashed.  It is easiest to work with a vmapped
address in this case.  However, ahash is incompatible with this.

Therefore, let's convert fs/verity/ from ahash to shash.  This
simplifies the code, and it should also slightly improve performance for
everyone who wasn't actually using one of these ahash-only crypto
accelerators, i.e. almost everyone (or maybe even everyone)!

Link: https://lore.kernel.org/r/20230516052306.99600-1-ebiggers@kernel.org
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Acked-by: Ard Biesheuvel &lt;ardb@kernel.org&gt;
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
</content>
</entry>
<entry>
<title>fsverity: Remove WQ_UNBOUND from fsverity read workqueue</title>
<updated>2023-03-14T23:16:36Z</updated>
<author>
<name>Nathan Huckleberry</name>
</author>
<published>2023-03-10T19:33:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f959325e6ac3f499450088b8d9c626d1177be160'/>
<id>urn:sha1:f959325e6ac3f499450088b8d9c626d1177be160</id>
<content type='text'>
WQ_UNBOUND causes significant scheduler latency on ARM64/Android.  This
is problematic for latency sensitive workloads, like I/O
post-processing.

Removing WQ_UNBOUND gives a 96% reduction in fsverity workqueue related
scheduler latency and improves app cold startup times by ~30ms.
WQ_UNBOUND was also removed from the dm-verity workqueue for the same
reason [1].

This code was tested by running Android app startup benchmarks and
measuring how long the fsverity workqueue spent in the runnable state.

Before
Total workqueue scheduler latency: 553800us
After
Total workqueue scheduler latency: 18962us

[1]: https://lore.kernel.org/all/20230202012348.885402-1-nhuck@google.com/

Signed-off-by: Nathan Huckleberry &lt;nhuck@google.com&gt;
Fixes: 8a1d0f9cacc9 ("fs-verity: add data verification hooks for -&gt;readpages()")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230310193325.620493-1-nhuck@google.com
Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
</content>
</entry>
<entry>
<title>fsverity: support verifying data from large folios</title>
<updated>2023-01-27T22:46:31Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2023-01-27T22:15:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5d0f0e57ed900917836385527ce5b122fa1425a3'/>
<id>urn:sha1:5d0f0e57ed900917836385527ce5b122fa1425a3</id>
<content type='text'>
Try to make fs/verity/verify.c aware of large folios.  This includes
making fsverity_verify_bio() support the case where the bio contains
large folios, and adding a function fsverity_verify_folio() which is the
equivalent of fsverity_verify_page().

There's no way to actually test this with large folios yet, but I've
tested that this doesn't cause any regressions.

Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Link: https://lore.kernel.org/r/20230127221529.299560-1-ebiggers@kernel.org
</content>
</entry>
<entry>
<title>fsverity: support verification with tree block size &lt; PAGE_SIZE</title>
<updated>2023-01-10T03:06:03Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2022-12-23T20:36:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5306892a50bf4cd4cc945bad286c7c950078d65e'/>
<id>urn:sha1:5306892a50bf4cd4cc945bad286c7c950078d65e</id>
<content type='text'>
Add support for verifying data from verity files whose Merkle tree block
size is less than the page size.  The main use case for this is to allow
a single Merkle tree block size to be used across all systems, so that
only one set of fsverity file digests and signatures is needed.

To do this, eliminate various assumptions that the Merkle tree block
size and the page size are the same:

- Make fsverity_verify_page() a wrapper around a new function
  fsverity_verify_blocks() which verifies one or more blocks in a page.

- When a Merkle tree block is needed, get the corresponding page and
  only verify and use the needed portion.  (The Merkle tree continues to
  be read and cached in page-sized chunks; that doesn't need to change.)

- When the Merkle tree block size and page size differ, use a bitmap
  fsverity_info::hash_block_verified to keep track of which Merkle tree
  blocks have been verified, as PageChecked cannot be used directly.

Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Reviewed-by: Andrey Albershteyn &lt;aalbersh@redhat.com&gt;
Tested-by: Ojaswin Mujoo &lt;ojaswin@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20221223203638.41293-7-ebiggers@kernel.org
</content>
</entry>
<entry>
<title>fsverity: replace fsverity_hash_page() with fsverity_hash_block()</title>
<updated>2023-01-10T03:06:01Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2022-12-23T20:36:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f45555bf23cfc6bf0f0239de321221b1b81817ab'/>
<id>urn:sha1:f45555bf23cfc6bf0f0239de321221b1b81817ab</id>
<content type='text'>
In preparation for allowing the Merkle tree block size to differ from
PAGE_SIZE, replace fsverity_hash_page() with fsverity_hash_block().  The
new function is similar to the old one, but it operates on the block at
the given offset in the page instead of on the full page.

(For now, all callers still pass a full page.)

Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Reviewed-by: Andrey Albershteyn &lt;aalbersh@redhat.com&gt;
Tested-by: Ojaswin Mujoo &lt;ojaswin@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20221223203638.41293-6-ebiggers@kernel.org
</content>
</entry>
<entry>
<title>fsverity: store log2(digest_size) precomputed</title>
<updated>2023-01-10T03:05:56Z</updated>
<author>
<name>Eric Biggers</name>
</author>
<published>2022-12-23T20:36:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=579a12f78d889339488175cd9f353dba2bb8d047'/>
<id>urn:sha1:579a12f78d889339488175cd9f353dba2bb8d047</id>
<content type='text'>
Add log_digestsize to struct merkle_tree_params so that it can be used
in verify.c.  Also save memory by using u8 for all the log_* fields.

Signed-off-by: Eric Biggers &lt;ebiggers@google.com&gt;
Reviewed-by: Andrey Albershteyn &lt;aalbersh@redhat.com&gt;
Tested-by: Ojaswin Mujoo &lt;ojaswin@linux.ibm.com&gt;
Link: https://lore.kernel.org/r/20221223203638.41293-4-ebiggers@kernel.org
</content>
</entry>
</feed>
