<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/quota, branch linux-5.19.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.19.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.19.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-10-24T07:56:44Z</updated>
<entry>
<title>quota: Check next/prev free block number after reading from quota file</title>
<updated>2022-10-24T07:56:44Z</updated>
<author>
<name>Zhihao Cheng</name>
</author>
<published>2022-09-23T13:45:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e4acbd10620ff524316c16cd322361250cb4abef'/>
<id>urn:sha1:e4acbd10620ff524316c16cd322361250cb4abef</id>
<content type='text'>
commit 6c8ea8b8cd4722efd419f91ca46a2dc81b7d89a3 upstream.

Following process:
 Init: v2_read_file_info: &lt;3&gt; dqi_free_blk 0 dqi_free_entry 5 dqi_blks 6

 Step 1. chown bin f_a -&gt; dquot_acquire -&gt; v2_write_dquot:
  qtree_write_dquot
   do_insert_tree
    find_free_dqentry
     get_free_dqblk
      write_blk(info-&gt;dqi_blocks) // info-&gt;dqi_blocks = 6, failure. The
	   content in physical block (corresponding to blk 6) is random.

 Step 2. chown root f_a -&gt; dquot_transfer -&gt; dqput_all -&gt; dqput -&gt;
         ext4_release_dquot -&gt; v2_release_dquot -&gt; qtree_delete_dquot:
  dquot_release
   remove_tree
    free_dqentry
     put_free_dqblk(6)
      info-&gt;dqi_free_blk = blk    // info-&gt;dqi_free_blk = 6

 Step 3. drop cache (buffer head for block 6 is released)

 Step 4. chown bin f_b -&gt; dquot_acquire -&gt; commit_dqblk -&gt; v2_write_dquot:
  qtree_write_dquot
   do_insert_tree
    find_free_dqentry
     get_free_dqblk
      dh = (struct qt_disk_dqdbheader *)buf
      blk = info-&gt;dqi_free_blk     // 6
      ret = read_blk(info, blk, buf)  // The content of buf is random
      info-&gt;dqi_free_blk = le32_to_cpu(dh-&gt;dqdh_next_free)  // random blk

 Step 5. chown bin f_c -&gt; notify_change -&gt; ext4_setattr -&gt; dquot_transfer:
  dquot = dqget -&gt; acquire_dquot -&gt; ext4_acquire_dquot -&gt; dquot_acquire -&gt;
          commit_dqblk -&gt; v2_write_dquot -&gt; dq_insert_tree:
   do_insert_tree
    find_free_dqentry
     get_free_dqblk
      blk = info-&gt;dqi_free_blk    // If blk &lt; 0 and blk is not an error
				     code, it will be returned as dquot

  transfer_to[USRQUOTA] = dquot  // A random negative value
  __dquot_transfer(transfer_to)
   dquot_add_inodes(transfer_to[cnt])
    spin_lock(&amp;dquot-&gt;dq_dqb_lock)  // page fault

, which will lead to kernel page fault:
 Quota error (device sda): qtree_write_dquot: Error -8000 occurred
 while creating quota
 BUG: unable to handle page fault for address: ffffffffffffe120
 #PF: supervisor write access in kernel mode
 #PF: error_code(0x0002) - not-present page
 Oops: 0002 [#1] PREEMPT SMP
 CPU: 0 PID: 5974 Comm: chown Not tainted 6.0.0-rc1-00004
 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996)
 RIP: 0010:_raw_spin_lock+0x3a/0x90
 Call Trace:
  dquot_add_inodes+0x28/0x270
  __dquot_transfer+0x377/0x840
  dquot_transfer+0xde/0x540
  ext4_setattr+0x405/0x14d0
  notify_change+0x68e/0x9f0
  chown_common+0x300/0x430
  __x64_sys_fchownat+0x29/0x40

In order to avoid accessing invalid quota memory address, this patch adds
block number checking of next/prev free block read from quota file.

Fetch a reproducer in [Link].

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216372
Fixes: 1da177e4c3f4152 ("Linux-2.6.12-rc2")
CC: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220923134555.2623931-2-chengzhihao1@huawei.com
Signed-off-by: Zhihao Cheng &lt;chengzhihao1@huawei.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>quota: Prevent memory allocation recursion while holding dq_lock</title>
<updated>2022-06-06T08:08:10Z</updated>
<author>
<name>Matthew Wilcox (Oracle)</name>
</author>
<published>2022-06-05T14:38:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=537e11cdc7a6b3ce94fa25ed41306193df9677b7'/>
<id>urn:sha1:537e11cdc7a6b3ce94fa25ed41306193df9677b7</id>
<content type='text'>
As described in commit 02117b8ae9c0 ("f2fs: Set GF_NOFS in
read_cache_page_gfp while doing f2fs_quota_read"), we must not enter
filesystem reclaim while holding the dq_lock.  Prevent this more generally
by using memalloc_nofs_save() while holding the lock.

Link: https://lore.kernel.org/r/20220605143815.2330891-2-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) &lt;willy@infradead.org&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: make dquot_quota_sync return errors from -&gt;sync_fs</title>
<updated>2022-01-30T16:59:47Z</updated>
<author>
<name>Darrick J. Wong</name>
</author>
<published>2022-01-30T16:53:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dd5532a4994bfda0386eb2286ec00758cee08444'/>
<id>urn:sha1:dd5532a4994bfda0386eb2286ec00758cee08444</id>
<content type='text'>
Strangely, dquot_quota_sync ignores the return code from the -&gt;sync_fs
call, which means that quotacalls like Q_SYNC never see the error.  This
doesn't seem right, so fix that.

Signed-off-by: Darrick J. Wong &lt;djwong@kernel.org&gt;
Reviewed-by: Jan Kara &lt;jack@suse.cz&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Acked-by: Christian Brauner &lt;brauner@kernel.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'fs_for_v5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs</title>
<updated>2021-11-06T23:40:48Z</updated>
<author>
<name>Linus Torvalds</name>
</author>
<published>2021-11-06T23:40:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d8b4e5bd4889e6568e8c3db983b4320f06091594'/>
<id>urn:sha1:d8b4e5bd4889e6568e8c3db983b4320f06091594</id>
<content type='text'>
Pull quota, isofs, and reiserfs updates from Jan Kara:
 "Fixes for handling of corrupted quota files, fix for handling of
  corrupted isofs filesystem, and a small cleanup for reiserfs"

* tag 'fs_for_v5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  fs: reiserfs: remove useless new_opts in reiserfs_remount
  isofs: Fix out of bound access for corrupted isofs image
  quota: correct error number in free_dqentry()
  quota: check block number when reading the block in quota file
</content>
</entry>
<entry>
<title>mm: don't include &lt;linux/blk-cgroup.h&gt; in &lt;linux/writeback.h&gt;</title>
<updated>2021-10-18T12:17:01Z</updated>
<author>
<name>Christoph Hellwig</name>
</author>
<published>2021-09-20T12:33:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=348332e000697b4ca82ef96719e02876434b8346'/>
<id>urn:sha1:348332e000697b4ca82ef96719e02876434b8346</id>
<content type='text'>
blk-cgroup.h pulls in blkdev.h and thus pretty much all the block
headers.  Break this dependency chain by turning wbc_blkcg_css into a
macro and dropping the blk-cgroup.h include.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: Johannes Thumshirn &lt;johannes.thumshirn@wdc.com&gt;
Link: https://lore.kernel.org/r/20210920123328.1399408-2-hch@lst.de
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>quota: correct error number in free_dqentry()</title>
<updated>2021-10-11T08:57:04Z</updated>
<author>
<name>Zhang Yi</name>
</author>
<published>2021-10-08T09:38:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d0e36a62bd4c60c09acc40e06ba4831a4d0bc75b'/>
<id>urn:sha1:d0e36a62bd4c60c09acc40e06ba4831a4d0bc75b</id>
<content type='text'>
Fix the error path in free_dqentry(), pass out the error number if the
block to free is not correct.

Fixes: 1ccd14b9c271 ("quota: Split off quota tree handling into a separate file")
Link: https://lore.kernel.org/r/20211008093821.1001186-3-yi.zhang@huawei.com
Signed-off-by: Zhang Yi &lt;yi.zhang@huawei.com&gt;
Cc: stable@kernel.org
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: check block number when reading the block in quota file</title>
<updated>2021-10-11T08:55:47Z</updated>
<author>
<name>Zhang Yi</name>
</author>
<published>2021-10-08T09:38:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9bf3d20331295b1ecb81f4ed9ef358c51699a050'/>
<id>urn:sha1:9bf3d20331295b1ecb81f4ed9ef358c51699a050</id>
<content type='text'>
The block number in the quota tree on disk should be smaller than the
v2_disk_dqinfo.dqi_blocks. If the quota file was corrupted, we may be
allocating an 'allocated' block and that would lead to a loop in a tree,
which will probably trigger oops later. This patch adds a check for the
block number in the quota tree to prevent such potential issue.

Link: https://lore.kernel.org/r/20211008093821.1001186-2-yi.zhang@huawei.com
Signed-off-by: Zhang Yi &lt;yi.zhang@huawei.com&gt;
Cc: stable@kernel.org
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: remove unnecessary oom message</title>
<updated>2021-06-22T08:40:52Z</updated>
<author>
<name>Zhen Lei</name>
</author>
<published>2021-06-18T01:47:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ce1b06c5f5e7fd2af8bc89323d9eb3102d8e3fe2'/>
<id>urn:sha1:ce1b06c5f5e7fd2af8bc89323d9eb3102d8e3fe2</id>
<content type='text'>
Fixes scripts/checkpatch.pl warning:
WARNING: Possible unnecessary 'out of memory' message

Remove it can help us save a bit of memory. After that, the static
function getdqbuf() becomes unnecessary, get rid of it and instead call
kmalloc() directly.

Link: https://lore.kernel.org/r/20210618014720.1977-2-thunder.leizhen@huawei.com
Signed-off-by: Zhen Lei &lt;thunder.leizhen@huawei.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: Change quotactl_path() systcall to an fd-based one</title>
<updated>2021-06-07T10:11:24Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2021-05-25T14:07:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=64c2c2c62f92339b176ea24403d8db16db36f9e6'/>
<id>urn:sha1:64c2c2c62f92339b176ea24403d8db16db36f9e6</id>
<content type='text'>
Some users have pointed out that path-based syscalls are problematic in
some environments and at least directory fd argument and possibly also
resolve flags are desirable for such syscalls. Rather than
reimplementing all details of pathname lookup and following where it may
eventually evolve, let's go for full file descriptor based syscall
similar to how ioctl(2) works since the beginning. Managing of quotas
isn't performance sensitive so the extra overhead of open does not
matter and we are able to consume O_PATH descriptors as well which makes
open cheap anyway. Also for frequent operations (such as retrieving
usage information for all users) we can reuse single fd and in fact get
even better performance as well as avoiding races with possible remounts
etc.

Tested-by: Sascha Hauer &lt;s.hauer@pengutronix.de&gt;
Acked-by: Christian Brauner &lt;christian.brauner@ubuntu.com&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: Use 'hlist_for_each_entry' to simplify code</title>
<updated>2021-05-10T14:27:49Z</updated>
<author>
<name>Christophe JAILLET</name>
</author>
<published>2021-04-28T08:44:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8c721cb0f742f9a01f2f1985b274b544f89904f4'/>
<id>urn:sha1:8c721cb0f742f9a01f2f1985b274b544f89904f4</id>
<content type='text'>
Use 'hlist_for_each_entry' instead of hand writing it.
This saves a few lines of code.

Link: https://lore.kernel.org/r/f82d3e33964dcbd2aac19866735e0a8381c8a735.1619599407.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
</feed>
