<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/fs/proc, branch v5.10</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.10</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.10'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2020-12-11T22:02:14Z</updated>
<entry>
<title>proc: use untagged_addr() for pagemap_read addresses</title>
<updated>2020-12-11T22:02:14Z</updated>
<author>
<name>Miles Chen</name>
<email>miles.chen@mediatek.com</email>
</author>
<published>2020-12-11T21:36:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=40d6366e9d86d9a67b5642040e76082fdb5bdcf9'/>
<id>urn:sha1:40d6366e9d86d9a67b5642040e76082fdb5bdcf9</id>
<content type='text'>
When we try to visit the pagemap of a tagged userspace pointer, we find
that the start_vaddr is not correct because of the tag.
To fix it, we should untag the userspace pointers in pagemap_read().

I tested with 5.10-rc4 and the issue remains.

Explanation from Catalin in [1]:

 "Arguably, that's a user-space bug since tagged file offsets were never
  supported. In this case it's not even a tag at bit 56 as per the arm64
  tagged address ABI but rather down to bit 47. You could say that the
  problem is caused by the C library (malloc()) or whoever created the
  tagged vaddr and passed it to this function. It's not a kernel
  regression as we've never supported it.

  Now, pagemap is a special case where the offset is usually not
  generated as a classic file offset but rather derived by shifting a
  user virtual address. I guess we can make a concession for pagemap
  (only) and allow such offset with the tag at bit (56 - PAGE_SHIFT + 3)"

My test code is based on [2]:

A userspace pointer which has been tagged by 0xb4: 0xb400007662f541c8

userspace program:

  uint64 OsLayer::VirtualToPhysical(void *vaddr) {
	uint64 frame, paddr, pfnmask, pagemask;
	int pagesize = sysconf(_SC_PAGESIZE);
	off64_t off = ((uintptr_t)vaddr) / pagesize * 8; // off = 0xb400007662f541c8 / pagesize * 8 = 0x5a00003b317aa0
	int fd = open(kPagemapPath, O_RDONLY);
	...

	if (lseek64(fd, off, SEEK_SET) != off || read(fd, &amp;frame, 8) != 8) {
		int err = errno;
		string errtxt = ErrorString(err);
		if (fd &gt;= 0)
			close(fd);
		return 0;
	}
  ...
  }

kernel fs/proc/task_mmu.c:

  static ssize_t pagemap_read(struct file *file, char __user *buf,
		size_t count, loff_t *ppos)
  {
	...
	src = *ppos;
	svpfn = src / PM_ENTRY_BYTES; // svpfn == 0xb400007662f54
	start_vaddr = svpfn &lt;&lt; PAGE_SHIFT; // start_vaddr == 0xb400007662f54000
	end_vaddr = mm-&gt;task_size;

	/* watch out for wraparound */
	// svpfn == 0xb400007662f54
	// (mm-&gt;task_size &gt;&gt; PAGE) == 0x8000000
	if (svpfn &gt; mm-&gt;task_size &gt;&gt; PAGE_SHIFT) // the condition is true because of the tag 0xb4
		start_vaddr = end_vaddr;

	ret = 0;
	while (count &amp;&amp; (start_vaddr &lt; end_vaddr)) { // we cannot visit correct entry because start_vaddr is set to end_vaddr
		int len;
		unsigned long end;
		...
	}
	...
  }

[1] https://lore.kernel.org/patchwork/patch/1343258/
[2] https://github.com/stressapptest/stressapptest/blob/master/src/os.cc#L158

Link: https://lkml.kernel.org/r/20201204024347.8295-1-miles.chen@mediatek.com
Signed-off-by: Miles Chen &lt;miles.chen@mediatek.com&gt;
Reviewed-by: Vincenzo Frascino &lt;vincenzo.frascino@arm.com&gt;
Reviewed-by: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Cc: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Cc: Alexander Potapenko &lt;glider@google.com&gt;
Cc: Vincenzo Frascino &lt;vincenzo.frascino@arm.com&gt;
Cc: Andrey Ryabinin &lt;aryabinin@virtuozzo.com&gt;
Cc: Catalin Marinas &lt;catalin.marinas@arm.com&gt;
Cc: Dmitry Vyukov &lt;dvyukov@google.com&gt;
Cc: Marco Elver &lt;elver@google.com&gt;
Cc: Will Deacon &lt;will@kernel.org&gt;
Cc: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Song Bao Hua (Barry Song) &lt;song.bao.hua@hisilicon.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;	[5.4-]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Merge tag 'io_uring-5.10-2020-11-20' of git://git.kernel.dk/linux-block</title>
<updated>2020-11-20T19:47:22Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2020-11-20T19:47:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fa5fca78bb2fe7a58ae7297407dcda1914ea8353'/>
<id>urn:sha1:fa5fca78bb2fe7a58ae7297407dcda1914ea8353</id>
<content type='text'>
Pull io_uring fixes from Jens Axboe:
 "Mostly regression or stable fodder:

   - Disallow async path resolution of /proc/self

   - Tighten constraints for segmented async buffered reads

   - Fix double completion for a retry error case

   - Fix for fixed file life times (Pavel)"

* tag 'io_uring-5.10-2020-11-20' of git://git.kernel.dk/linux-block:
  io_uring: order refnode recycling
  io_uring: get an active ref_node from files_data
  io_uring: don't double complete failed reissue request
  mm: never attempt async page lock if we've transferred data already
  io_uring: handle -EOPNOTSUPP on path resolution
  proc: don't allow async path resolution of /proc/self components
</content>
</entry>
<entry>
<title>proc: don't allow async path resolution of /proc/self components</title>
<updated>2020-11-13T23:47:52Z</updated>
<author>
<name>Jens Axboe</name>
<email>axboe@kernel.dk</email>
</author>
<published>2020-11-13T23:47:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8d4c3e76e3be11a64df95ddee52e99092d42fc19'/>
<id>urn:sha1:8d4c3e76e3be11a64df95ddee52e99092d42fc19</id>
<content type='text'>
If this is attempted by a kthread, then return -EOPNOTSUPP as we don't
currently support that. Once we can get task_pid_ptr() doing the right
thing, then this can go away again.

Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>Merge branch 'hch' (patches from Christoph)</title>
<updated>2020-11-08T18:11:31Z</updated>
<author>
<name>Linus Torvalds</name>
<email>torvalds@linux-foundation.org</email>
</author>
<published>2020-11-08T18:11:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=6b2c4d52fd38e676fc9ab5d9241a056de565eb1a'/>
<id>urn:sha1:6b2c4d52fd38e676fc9ab5d9241a056de565eb1a</id>
<content type='text'>
Merge procfs splice read fixes from Christoph Hellwig:
 "Greg reported a problem due to the fact that Android tests use procfs
  files to test splice, which stopped working with the changes for
  set_fs() removal.

  This series adds read_iter support for seq_file, and uses those for
  various proc files using seq_file to restore splice read support"

[ Side note: Christoph initially had a scripted "move everything over"
  patch, which looks fine, but I personally would prefer us to actively
  discourage splice() on random files.  So this does just the minimal
  basic core set of proc file op conversions.

  For completeness, and in case people care, that script was

     sed -i -e 's/\.proc_read\(\s*=\s*\)seq_read/\.proc_read_iter\1seq_read_iter/g'

  but I'll wait and see if somebody has a strong argument for using
  splice on random small /proc files before I'd run it on the whole
  kernel.   - Linus ]

* emailed patches from Christoph Hellwig &lt;hch@lst.de&gt;:
  proc "seq files": switch to -&gt;read_iter
  proc "single files": switch to -&gt;read_iter
  proc/stat: switch to -&gt;read_iter
  proc/cpuinfo: switch to -&gt;read_iter
  proc: wire up generic_file_splice_read for iter ops
  seq_file: add seq_read_iter
</content>
</entry>
<entry>
<title>proc "seq files": switch to -&gt;read_iter</title>
<updated>2020-11-06T18:05:18Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2020-11-04T08:27:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b24c30c678630e48cf8e3caefe463e1c6144d029'/>
<id>urn:sha1:b24c30c678630e48cf8e3caefe463e1c6144d029</id>
<content type='text'>
Implement -&gt;read_iter for all proc "seq files" so that splice works on
them.

Suggested-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>proc "single files": switch to -&gt;read_iter</title>
<updated>2020-11-06T18:05:18Z</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@google.com</email>
</author>
<published>2020-11-04T08:27:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7cfc630e63b4f7b2ab5a1238c566a6b799ae1624'/>
<id>urn:sha1:7cfc630e63b4f7b2ab5a1238c566a6b799ae1624</id>
<content type='text'>
Implement -&gt;read_iter for all proc "single files" so that more bionic
tests cases can pass when they call splice() on other fun files like
/proc/version

Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>proc/stat: switch to -&gt;read_iter</title>
<updated>2020-11-06T18:05:18Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2020-11-04T08:27:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=28589f9e0f942377e9994711f5765b01d1b8eaa2'/>
<id>urn:sha1:28589f9e0f942377e9994711f5765b01d1b8eaa2</id>
<content type='text'>
Implement -&gt;read_iter so that splice can be used on this file.

Suggested-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>proc/cpuinfo: switch to -&gt;read_iter</title>
<updated>2020-11-06T18:05:18Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2020-11-04T08:27:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=70fce7d2253938191275ebcbd46efe45fceb05a1'/>
<id>urn:sha1:70fce7d2253938191275ebcbd46efe45fceb05a1</id>
<content type='text'>
Implement -&gt;read_iter so that the Android bionic test suite can use
this random proc file for its splice test case.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>proc: wire up generic_file_splice_read for iter ops</title>
<updated>2020-11-06T18:05:18Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2020-11-04T08:27:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=fe33850ff798eb8d57eea88cc14090770013bb73'/>
<id>urn:sha1:fe33850ff798eb8d57eea88cc14090770013bb73</id>
<content type='text'>
Wire up generic_file_splice_read for the iter based proxy ops, so
that splice reads from them work.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Tested-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>mm, oom: keep oom_adj under or at upper limit when printing</title>
<updated>2020-11-02T20:14:19Z</updated>
<author>
<name>Charles Haithcock</name>
<email>chaithco@redhat.com</email>
</author>
<published>2020-11-02T01:07:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=66606567dedf395e0857f531976efad4cbbd39ea'/>
<id>urn:sha1:66606567dedf395e0857f531976efad4cbbd39ea</id>
<content type='text'>
For oom_score_adj values in the range [942,999], the current
calculations will print 16 for oom_adj.  This patch simply limits the
output so output is inline with docs.

Signed-off-by: Charles Haithcock &lt;chaithco@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Acked-by: Michal Hocko &lt;mhocko@suse.com&gt;
Cc: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Link: https://lkml.kernel.org/r/20201020165130.33927-1-chaithco@redhat.com
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
