<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/squashfs/file.c, branch for-next</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>Squashfs: Ensure all readahead pages have been used</title>
<updated>2024-08-23T11:11:36+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2024-08-22T23:31:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=84e0e03b308816a48c67f6da2168fcea6d49eda8'/>
<id>84e0e03b308816a48c67f6da2168fcea6d49eda8</id>
<content type='text'>
In the recent work to remove page-&gt;index, a sanity check
that ensured all the readhead pages were covered by the
Squashfs data block was removed [1].

To avoid any regression, this commit adds the sanity check
back in an equivalent way.  Namely the page actor will now
return error if any pages are unused after completion.

[1] https://lore.kernel.org/all/20240818235847.170468-3-phillip@squashfs.org.uk/

--

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240822233106.121522-1-phillip@squashfs.org.uk
V3: last_page should be actor-&gt;last_page
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In the recent work to remove page-&gt;index, a sanity check
that ensured all the readhead pages were covered by the
Squashfs data block was removed [1].

To avoid any regression, this commit adds the sanity check
back in an equivalent way.  Namely the page actor will now
return error if any pages are unused after completion.

[1] https://lore.kernel.org/all/20240818235847.170468-3-phillip@squashfs.org.uk/

--

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240822233106.121522-1-phillip@squashfs.org.uk
V3: last_page should be actor-&gt;last_page
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Squashfs: Rewrite and update squashfs_readahead_fragment() to not use page-&gt;index</title>
<updated>2024-08-19T12:08:21+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2024-08-18T23:58:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=fd54fa6efe0dd3894d6fd703f8856675b4bf8315'/>
<id>fd54fa6efe0dd3894d6fd703f8856675b4bf8315</id>
<content type='text'>
The previous implementation lacked error checking (e.g. the bytes
returned by squashfs_fill_page() is not checked), and the use of
page-&gt;index could not be removed without substantially rewriting
the routine to use the page actor abstraction used elsewhere.

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240818235847.170468-5-phillip@squashfs.org.uk
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The previous implementation lacked error checking (e.g. the bytes
returned by squashfs_fill_page() is not checked), and the use of
page-&gt;index could not be removed without substantially rewriting
the routine to use the page actor abstraction used elsewhere.

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240818235847.170468-5-phillip@squashfs.org.uk
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Squashfs: Update squashfs_readahead() to not use page-&gt;index</title>
<updated>2024-08-19T12:08:20+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2024-08-18T23:58:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6f09ffb1f4fadf156d5d1032217b9d1fa4e07dbe'/>
<id>6f09ffb1f4fadf156d5d1032217b9d1fa4e07dbe</id>
<content type='text'>
This commit removes references to page-&gt;index in the pages returned
from __readahead_batch(), and instead uses the 'start' variable.

This does reveal a bug in the previous code in that 'start' was
not updated every time around the loop.  This is fixed in this
commit.

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240818235847.170468-3-phillip@squashfs.org.uk
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit removes references to page-&gt;index in the pages returned
from __readahead_batch(), and instead uses the 'start' variable.

This does reveal a bug in the previous code in that 'start' was
not updated every time around the loop.  This is fixed in this
commit.

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240818235847.170468-3-phillip@squashfs.org.uk
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Squashfs: Update page_actor to not use page-&gt;index</title>
<updated>2024-08-19T12:08:20+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2024-08-18T23:58:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=2258e22f05aff5865c93cbd4e9acba55b295d832'/>
<id>2258e22f05aff5865c93cbd4e9acba55b295d832</id>
<content type='text'>
This commit removes an unnecessary use of page-&gt;index,
and moves the other use over to folio-&gt;index.

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240818235847.170468-2-phillip@squashfs.org.uk
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit removes an unnecessary use of page-&gt;index,
and moves the other use over to folio-&gt;index.

Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Link: https://lore.kernel.org/r/20240818235847.170468-2-phillip@squashfs.org.uk
Signed-off-by: Christian Brauner &lt;brauner@kernel.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>squashfs: remove calls to set the folio error flag</title>
<updated>2024-05-08T15:41:28+00:00</updated>
<author>
<name>Matthew Wilcox (Oracle)</name>
<email>willy@infradead.org</email>
</author>
<published>2024-04-20T02:50:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=bbf45b7e68555569489ab2428dd9c23960cdc9bf'/>
<id>bbf45b7e68555569489ab2428dd9c23960cdc9bf</id>
<content type='text'>
Nobody checks the error flag on squashfs folios, so stop setting it.

Link: https://lkml.kernel.org/r/20240420025029.2166544-24-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
Tested-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Reviewed-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Nobody checks the error flag on squashfs folios, so stop setting it.

Link: https://lkml.kernel.org/r/20240420025029.2166544-24-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
Tested-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Reviewed-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Squashfs: fix variable overflow triggered by sysbot</title>
<updated>2023-12-11T01:21:26+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2023-11-13T16:09:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=12427de9439d68b8e96ba6f50b601ef15f437612'/>
<id>12427de9439d68b8e96ba6f50b601ef15f437612</id>
<content type='text'>
Sysbot reports a slab out of bounds write in squashfs_readahead().

This is ultimately caused by a file reporting an (infeasibly) large file
size (1407374883553280 bytes) with the minimum block size of 4K.

This causes variable overflow.

Link: https://lkml.kernel.org/r/20231113160901.6444-1-phillip@squashfs.org.uk
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Reported-by: syzbot+604424eb051c2f696163@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000b1fda20609ede0d1@google.com/
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Sysbot reports a slab out of bounds write in squashfs_readahead().

This is ultimately caused by a file reporting an (infeasibly) large file
size (1407374883553280 bytes) with the minimum block size of 4K.

This causes variable overflow.

Link: https://lkml.kernel.org/r/20231113160901.6444-1-phillip@squashfs.org.uk
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Reported-by: syzbot+604424eb051c2f696163@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000b1fda20609ede0d1@google.com/
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>squashfs: fix buffer release race condition in readahead code</title>
<updated>2022-10-28T20:37:21+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2022-10-20T22:36:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=e11c4e088be4c39d17f304fcf331670891905f42'/>
<id>e11c4e088be4c39d17f304fcf331670891905f42</id>
<content type='text'>
Fix a buffer release race condition, where the error value was used after
release.

Link: https://lkml.kernel.org/r/20221020223616.7571-4-phillip@squashfs.org.uk
Fixes: b09a7a036d20 ("squashfs: support reading fragments in readahead call")
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Tested-by: Bagas Sanjaya &lt;bagasdotme@gmail.com&gt;
Reported-by: Marc Miltenberger &lt;marcmiltenberger@gmail.com&gt;
Cc: Dimitri John Ledkov &lt;dimitri.ledkov@canonical.com&gt;
Cc: Hsin-Yi Wang &lt;hsinyi@chromium.org&gt;
Cc: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Cc: Slade Watkins &lt;srw@sladewatkins.net&gt;
Cc: Thorsten Leemhuis &lt;regressions@leemhuis.info&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix a buffer release race condition, where the error value was used after
release.

Link: https://lkml.kernel.org/r/20221020223616.7571-4-phillip@squashfs.org.uk
Fixes: b09a7a036d20 ("squashfs: support reading fragments in readahead call")
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Tested-by: Bagas Sanjaya &lt;bagasdotme@gmail.com&gt;
Reported-by: Marc Miltenberger &lt;marcmiltenberger@gmail.com&gt;
Cc: Dimitri John Ledkov &lt;dimitri.ledkov@canonical.com&gt;
Cc: Hsin-Yi Wang &lt;hsinyi@chromium.org&gt;
Cc: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Cc: Slade Watkins &lt;srw@sladewatkins.net&gt;
Cc: Thorsten Leemhuis &lt;regressions@leemhuis.info&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>squashfs: fix extending readahead beyond end of file</title>
<updated>2022-10-28T20:37:21+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2022-10-20T22:36:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c9199de82bad03bceb94ec3c5195c879d7e11911'/>
<id>c9199de82bad03bceb94ec3c5195c879d7e11911</id>
<content type='text'>
The readahead code will try to extend readahead to the entire size of the
Squashfs data block.

But, it didn't take into account that the last block at the end of the
file may not be a whole block.  In this case, the code would extend
readahead to beyond the end of the file, leaving trailing pages.

Fix this by only requesting the expected number of pages.

Link: https://lkml.kernel.org/r/20221020223616.7571-3-phillip@squashfs.org.uk
Fixes: 8fc78b6fe24c ("squashfs: implement readahead")
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Tested-by: Bagas Sanjaya &lt;bagasdotme@gmail.com&gt;
Reported-by: Marc Miltenberger &lt;marcmiltenberger@gmail.com&gt;
Cc: Dimitri John Ledkov &lt;dimitri.ledkov@canonical.com&gt;
Cc: Hsin-Yi Wang &lt;hsinyi@chromium.org&gt;
Cc: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Cc: Slade Watkins &lt;srw@sladewatkins.net&gt;
Cc: Thorsten Leemhuis &lt;regressions@leemhuis.info&gt;
Cc: &lt;stable@vger.kernel.org&gt;

Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The readahead code will try to extend readahead to the entire size of the
Squashfs data block.

But, it didn't take into account that the last block at the end of the
file may not be a whole block.  In this case, the code would extend
readahead to beyond the end of the file, leaving trailing pages.

Fix this by only requesting the expected number of pages.

Link: https://lkml.kernel.org/r/20221020223616.7571-3-phillip@squashfs.org.uk
Fixes: 8fc78b6fe24c ("squashfs: implement readahead")
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Tested-by: Bagas Sanjaya &lt;bagasdotme@gmail.com&gt;
Reported-by: Marc Miltenberger &lt;marcmiltenberger@gmail.com&gt;
Cc: Dimitri John Ledkov &lt;dimitri.ledkov@canonical.com&gt;
Cc: Hsin-Yi Wang &lt;hsinyi@chromium.org&gt;
Cc: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Cc: Slade Watkins &lt;srw@sladewatkins.net&gt;
Cc: Thorsten Leemhuis &lt;regressions@leemhuis.info&gt;
Cc: &lt;stable@vger.kernel.org&gt;

Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>squashfs: fix read regression introduced in readahead code</title>
<updated>2022-10-28T20:37:21+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2022-10-20T22:36:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9ef8eb6104527bfe9ed31f7a4ffa721390adf9a8'/>
<id>9ef8eb6104527bfe9ed31f7a4ffa721390adf9a8</id>
<content type='text'>
Patch series "squashfs: fix some regressions introduced in the readahead
code".

This patchset fixes 3 regressions introduced by the recent readahead code
changes.  The first regression is causing "snaps" to randomly fail after a
couple of hours or days, which how the regression came to light.


This patch (of 3):

If a file isn't a whole multiple of the page size, the last page will have
trailing bytes unfilled.

There was a mistake in the readahead code which did this.  In particular
it incorrectly assumed that the last page in the readahead page array
(page[nr_pages - 1]) will always contain the last page in the block, which
if we're at file end, will be the page that needs to be zero filled.

But the readahead code may not return the last page in the block, which
means it is unmapped and will be skipped by the decompressors (a temporary
buffer used).

In this case the zero filling code will zero out the wrong page, leading
to data corruption.

Fix this by by extending the "page actor" to return the last page if
present, or NULL if a temporary buffer was used.

Link: https://lkml.kernel.org/r/20221020223616.7571-1-phillip@squashfs.org.uk
Link: https://lkml.kernel.org/r/20221020223616.7571-2-phillip@squashfs.org.uk
Fixes: 8fc78b6fe24c ("squashfs: implement readahead")
Link: https://lore.kernel.org/lkml/b0c258c3-6dcf-aade-efc4-d62a8b3a1ce2@alu.unizg.hr/
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Reported-by: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Tested-by: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Tested-by: Slade Watkins &lt;srw@sladewatkins.net&gt;
Tested-by: Bagas Sanjaya &lt;bagasdotme@gmail.com&gt;
Reported-by: Marc Miltenberger &lt;marcmiltenberger@gmail.com&gt;
Cc: Dimitri John Ledkov &lt;dimitri.ledkov@canonical.com&gt;
Cc: Hsin-Yi Wang &lt;hsinyi@chromium.org&gt;
Cc: Thorsten Leemhuis &lt;regressions@leemhuis.info&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Patch series "squashfs: fix some regressions introduced in the readahead
code".

This patchset fixes 3 regressions introduced by the recent readahead code
changes.  The first regression is causing "snaps" to randomly fail after a
couple of hours or days, which how the regression came to light.


This patch (of 3):

If a file isn't a whole multiple of the page size, the last page will have
trailing bytes unfilled.

There was a mistake in the readahead code which did this.  In particular
it incorrectly assumed that the last page in the readahead page array
(page[nr_pages - 1]) will always contain the last page in the block, which
if we're at file end, will be the page that needs to be zero filled.

But the readahead code may not return the last page in the block, which
means it is unmapped and will be skipped by the decompressors (a temporary
buffer used).

In this case the zero filling code will zero out the wrong page, leading
to data corruption.

Fix this by by extending the "page actor" to return the last page if
present, or NULL if a temporary buffer was used.

Link: https://lkml.kernel.org/r/20221020223616.7571-1-phillip@squashfs.org.uk
Link: https://lkml.kernel.org/r/20221020223616.7571-2-phillip@squashfs.org.uk
Fixes: 8fc78b6fe24c ("squashfs: implement readahead")
Link: https://lore.kernel.org/lkml/b0c258c3-6dcf-aade-efc4-d62a8b3a1ce2@alu.unizg.hr/
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Reported-by: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Tested-by: Mirsad Goran Todorovac &lt;mirsad.todorovac@alu.unizg.hr&gt;
Tested-by: Slade Watkins &lt;srw@sladewatkins.net&gt;
Tested-by: Bagas Sanjaya &lt;bagasdotme@gmail.com&gt;
Reported-by: Marc Miltenberger &lt;marcmiltenberger@gmail.com&gt;
Cc: Dimitri John Ledkov &lt;dimitri.ledkov@canonical.com&gt;
Cc: Hsin-Yi Wang &lt;hsinyi@chromium.org&gt;
Cc: Thorsten Leemhuis &lt;regressions@leemhuis.info&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>squashfs: don't call kmalloc in decompressors</title>
<updated>2022-08-28T21:02:45+00:00</updated>
<author>
<name>Phillip Lougher</name>
<email>phillip@squashfs.org.uk</email>
</author>
<published>2022-08-22T21:54:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=1f13dff09ffc8bcf6aa20639b638d813379c7f6b'/>
<id>1f13dff09ffc8bcf6aa20639b638d813379c7f6b</id>
<content type='text'>
The decompressors may be called while in an atomic section.  So move the
kmalloc() out of this path, and into the "page actor" init function.

This fixes a regression introduced by commit
f268eedddf35 ("squashfs: extend "page actor" to handle missing pages")

Link: https://lkml.kernel.org/r/20220822215430.15933-1-phillip@squashfs.org.uk
Fixes: f268eedddf35 ("squashfs: extend "page actor" to handle missing pages")
Reported-by: Chris Murphy &lt;lists@colorremedies.com&gt;
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The decompressors may be called while in an atomic section.  So move the
kmalloc() out of this path, and into the "page actor" init function.

This fixes a regression introduced by commit
f268eedddf35 ("squashfs: extend "page actor" to handle missing pages")

Link: https://lkml.kernel.org/r/20220822215430.15933-1-phillip@squashfs.org.uk
Fixes: f268eedddf35 ("squashfs: extend "page actor" to handle missing pages")
Reported-by: Chris Murphy &lt;lists@colorremedies.com&gt;
Signed-off-by: Phillip Lougher &lt;phillip@squashfs.org.uk&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
