<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/mm/shmem.c, branch linux-2.6.34.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.34.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.34.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2014-02-10T21:11:25Z</updated>
<entry>
<title>tmpfs: fix use-after-free of mempolicy object</title>
<updated>2014-02-10T21:11:25Z</updated>
<author>
<name>Greg Thelen</name>
</author>
<published>2013-02-23T00:36:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6918382fea8962b86f724f035d14db541887fd48'/>
<id>urn:sha1:6918382fea8962b86f724f035d14db541887fd48</id>
<content type='text'>
commit 5f00110f7273f9ff04ac69a5f85bb535a4fd0987 upstream.

The tmpfs remount logic preserves filesystem mempolicy if the mpol=M
option is not specified in the remount request.  A new policy can be
specified if mpol=M is given.

Before this patch remounting an mpol bound tmpfs without specifying
mpol= mount option in the remount request would set the filesystem's
mempolicy object to a freed mempolicy object.

To reproduce the problem boot a DEBUG_PAGEALLOC kernel and run:
    # mkdir /tmp/x

    # mount -t tmpfs -o size=100M,mpol=interleave nodev /tmp/x

    # grep /tmp/x /proc/mounts
    nodev /tmp/x tmpfs rw,relatime,size=102400k,mpol=interleave:0-3 0 0

    # mount -o remount,size=200M nodev /tmp/x

    # grep /tmp/x /proc/mounts
    nodev /tmp/x tmpfs rw,relatime,size=204800k,mpol=??? 0 0
        # note ? garbage in mpol=... output above

    # dd if=/dev/zero of=/tmp/x/f count=1
        # panic here

Panic:
    BUG: unable to handle kernel NULL pointer dereference at           (null)
    IP: [&lt;          (null)&gt;]           (null)
    [...]
    Oops: 0010 [#1] SMP DEBUG_PAGEALLOC
    Call Trace:
      mpol_shared_policy_init+0xa5/0x160
      shmem_get_inode+0x209/0x270
      shmem_mknod+0x3e/0xf0
      shmem_create+0x18/0x20
      vfs_create+0xb5/0x130
      do_last+0x9a1/0xea0
      path_openat+0xb3/0x4d0
      do_filp_open+0x42/0xa0
      do_sys_open+0xfe/0x1e0
      compat_sys_open+0x1b/0x20
      cstar_dispatch+0x7/0x1f

Non-debug kernels will not crash immediately because referencing the
dangling mpol will not cause a fault.  Instead the filesystem will
reference a freed mempolicy object, which will cause unpredictable
behavior.

The problem boils down to a dropped mpol reference below if
shmem_parse_options() does not allocate a new mpol:

    config = *sbinfo
    shmem_parse_options(data, &amp;config, true)
    mpol_put(sbinfo-&gt;mpol)
    sbinfo-&gt;mpol = config.mpol  /* BUG: saves unreferenced mpol */

This patch avoids the crash by not releasing the mempolicy if
shmem_parse_options() doesn't create a new mpol.

How far back does this issue go? I see it in both 2.6.36 and 3.3.  I did
not look back further.

Signed-off-by: Greg Thelen &lt;gthelen@google.com&gt;
Acked-by: Hugh Dickins &lt;hughd@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
</content>
</entry>
<entry>
<title>shmem: let shared anonymous be nonlinear again</title>
<updated>2012-03-14T14:56:48Z</updated>
<author>
<name>Hugh Dickins</name>
</author>
<published>2011-03-22T23:33:43Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9195c4ca3ee1ae26d23b4a61b789ef95c563c1de'/>
<id>urn:sha1:9195c4ca3ee1ae26d23b4a61b789ef95c563c1de</id>
<content type='text'>
commit bee4c36a5cf5c9f63ce1d7372aa62045fbd16d47 upstream.

Up to 2.6.22, you could use remap_file_pages(2) on a tmpfs file or a
shared mapping of /dev/zero or a shared anonymous mapping.  In 2.6.23 we
disabled it by default, but set VM_CAN_NONLINEAR to enable it on safe
mappings.  We made sure to set it in shmem_mmap() for tmpfs files, but
missed it in shmem_zero_setup() for the others.  Fix that at last.

Reported-by: Kenny Simpson &lt;theonetruekenny@yahoo.com&gt;
Signed-off-by: Hugh Dickins &lt;hughd@google.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Paul Gortmaker &lt;paul.gortmaker@windriver.com&gt;
</content>
</entry>
<entry>
<title>Fix breakage in shmem.c</title>
<updated>2009-12-17T00:48:48Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2009-12-17T00:35:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=718deb6b61e34c200c1f2b706176d9aac334cb2d'/>
<id>urn:sha1:718deb6b61e34c200c1f2b706176d9aac334cb2d</id>
<content type='text'>
Replacing
	error = 0;
	if (error)
		op
with nothing is not quite an equivalent transformation ;-)

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>make generic_acl slightly more generic</title>
<updated>2009-12-16T17:16:49Z</updated>
<author>
<name>Christoph Hellwig</name>
</author>
<published>2009-11-03T15:44:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1c7c474c31aea6d5cb2fb35f31d9e9e91ae466b1'/>
<id>urn:sha1:1c7c474c31aea6d5cb2fb35f31d9e9e91ae466b1</id>
<content type='text'>
Now that we cache the ACL pointers in the generic inode all the generic_acl
cruft can go away and generic_acl.c can directly implement xattr handlers
dealing with the full Posix ACL semantics for in-memory filesystems.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>sanitize xattr handler prototypes</title>
<updated>2009-12-16T17:16:49Z</updated>
<author>
<name>Christoph Hellwig</name>
</author>
<published>2009-11-13T09:52:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=431547b3c4533b8c7fd150ab36980b9a3147797b'/>
<id>urn:sha1:431547b3c4533b8c7fd150ab36980b9a3147797b</id>
<content type='text'>
Add a flags argument to struct xattr_handler and pass it to all xattr
handler methods.  This allows using the same methods for multiple
handlers, e.g. for the ACL methods which perform exactly the same action
for the access and default ACLs, just using a different underlying
attribute.  With a little more groundwork it'll also allow sharing the
methods for the regular user/trusted/secure handlers in extN, ocfs2 and
jffs2 like it's already done for xfs in this patch.

Also change the inode argument to the handlers to a dentry to allow
using the handlers mechnism for filesystems that require it later,
e.g. cifs.

[with GFS2 bits updated by Steven Whitehouse &lt;swhiteho@redhat.com&gt;]

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Reviewed-by: James Morris &lt;jmorris@namei.org&gt;
Acked-by: Joel Becker &lt;joel.becker@oracle.com&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>Untangling ima mess, part 1: alloc_file()</title>
<updated>2009-12-16T17:16:47Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2009-12-16T09:53:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0552f879d45cecc35d8e372a591fc5ed863bca58'/>
<id>urn:sha1:0552f879d45cecc35d8e372a591fc5ed863bca58</id>
<content type='text'>
There are 2 groups of alloc_file() callers:
	* ones that are followed by ima_counts_get
	* ones giving non-regular files
So let's pull that ima_counts_get() into alloc_file();
it's a no-op in case of non-regular files.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>switch alloc_file() to passing struct path</title>
<updated>2009-12-16T17:16:42Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2009-08-08T20:52:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2c48b9c45579a9b5e3e74694eebf3d2451f3dbd3'/>
<id>urn:sha1:2c48b9c45579a9b5e3e74694eebf3d2451f3dbd3</id>
<content type='text'>
... and have the caller grab both mnt and dentry; kill
leak in infiniband, while we are at it.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>switch shmem_file_setup() to alloc_file()</title>
<updated>2009-12-16T17:16:40Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2009-08-05T14:25:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b42af81f0d7f95dff320f47d99c201925f406f5'/>
<id>urn:sha1:4b42af81f0d7f95dff320f47d99c201925f406f5</id>
<content type='text'>
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>swap_info: note SWAP_MAP_SHMEM</title>
<updated>2009-12-15T16:53:16Z</updated>
<author>
<name>Hugh Dickins</name>
</author>
<published>2009-12-15T01:58:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=aaa468653b4a0d11c603c48d716f765177a5a9e4'/>
<id>urn:sha1:aaa468653b4a0d11c603c48d716f765177a5a9e4</id>
<content type='text'>
While we're fiddling with the swap_map values, let's assign a particular
value to shmem/tmpfs swap pages: their swap counts are never incremented,
and it helps swapoff's try_to_unuse() a little if it can immediately
distinguish those pages from process pages.

Since we've no use for SWAP_MAP_BAD | COUNT_CONTINUED,
we might as well use that 0xbf value for SWAP_MAP_SHMEM.

Signed-off-by: Hugh Dickins &lt;hugh.dickins@tiscali.co.uk&gt;
Reviewed-by: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.com&gt;
Cc: Rik van Riel &lt;riel@redhat.com&gt;
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>const: mark struct vm_struct_operations</title>
<updated>2009-09-27T18:39:25Z</updated>
<author>
<name>Alexey Dobriyan</name>
</author>
<published>2009-09-27T18:29:37Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f0f37e2f77731b3473fa6bd5ee53255d9a9cdb40'/>
<id>urn:sha1:f0f37e2f77731b3473fa6bd5ee53255d9a9cdb40</id>
<content type='text'>
* mark struct vm_area_struct::vm_ops as const
* mark vm_ops in AGP code

But leave TTM code alone, something is fishy there with global vm_ops
being used.

Signed-off-by: Alexey Dobriyan &lt;adobriyan@gmail.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
