<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/inotify_user.c, branch linux-2.6.28.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.28.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-2.6.28.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2009-02-02T17:53:18Z</updated>
<entry>
<title>inotify: clean up inotify_read and fix locking problems</title>
<updated>2009-02-02T17:53:18Z</updated>
<author>
<name>Vegard Nossum</name>
</author>
<published>2009-01-22T14:29:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b9e1bfac4c90ee6c67b8375dc3606ae08a5ffb8'/>
<id>urn:sha1:4b9e1bfac4c90ee6c67b8375dc3606ae08a5ffb8</id>
<content type='text'>
commit 3632dee2f8b8a9720329f29eeaa4ec4669a3aff8 upstream.

If userspace supplies an invalid pointer to a read() of an inotify
instance, the inotify device's event list mutex is unlocked twice.
This causes an unbalance which effectively leaves the data structure
unprotected, and we can trigger oopses by accessing the inotify
instance from different tasks concurrently.

The best fix (contributed largely by Linus) is a total rewrite
of the function in question:

On Thu, Jan 22, 2009 at 7:05 AM, Linus Torvalds wrote:
&gt; The thing to notice is that:
&gt;
&gt;  - locking is done in just one place, and there is no question about it
&gt;   not having an unlock.
&gt;
&gt;  - that whole double-while(1)-loop thing is gone.
&gt;
&gt;  - use multiple functions to make nesting and error handling sane
&gt;
&gt;  - do error testing after doing the things you always need to do, ie do
&gt;   this:
&gt;
&gt;        mutex_lock(..)
&gt;        ret = function_call();
&gt;        mutex_unlock(..)
&gt;
&gt;        .. test ret here ..
&gt;
&gt;   instead of doing conditional exits with unlocking or freeing.
&gt;
&gt; So if the code is written in this way, it may still be buggy, but at least
&gt; it's not buggy because of subtle "forgot to unlock" or "forgot to free"
&gt; issues.
&gt;
&gt; This _always_ unlocks if it locked, and it always frees if it got a
&gt; non-error kevent.

Cc: John McCutchan &lt;ttb@tentacle.dhs.org&gt;
Cc: Robert Love &lt;rlove@google.com&gt;
Signed-off-by: Vegard Nossum &lt;vegard.nossum@gmail.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>System call wrappers part 29</title>
<updated>2009-01-18T18:44:01Z</updated>
<author>
<name>Heiko Carstens</name>
</author>
<published>2009-01-14T13:14:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a673b4d54bf1d8c61df163e28ca6178d569fc162'/>
<id>urn:sha1:a673b4d54bf1d8c61df163e28ca6178d569fc162</id>
<content type='text'>
commit 2e4d0924eb0c403ce4014fa139d1d61bf2c44fee upstream.

Signed-off-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>System call wrappers part 28</title>
<updated>2009-01-18T18:44:00Z</updated>
<author>
<name>Heiko Carstens</name>
</author>
<published>2009-01-14T13:14:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=47e059f33e324bef53aab02196595c0dd8b384fb'/>
<id>urn:sha1:47e059f33e324bef53aab02196595c0dd8b384fb</id>
<content type='text'>
commit 938bb9f5e840eddbf54e4f62f6c5ba9b3ae12c9d upstream.

Signed-off-by: Heiko Carstens &lt;heiko.carstens@de.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
</content>
</entry>
<entry>
<title>inotify: fix type errors in interfaces</title>
<updated>2009-01-18T18:43:49Z</updated>
<author>
<name>Michael Kerrisk</name>
</author>
<published>2009-01-05T12:19:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=05bfdda7824625c1d51cedcd79814706b42cc517'/>
<id>urn:sha1:05bfdda7824625c1d51cedcd79814706b42cc517</id>
<content type='text'>
commit 4ae8978cf92a96257cd8998a49e781be83571d64 upstream.

The problems lie in the types used for some inotify interfaces, both at the kernel level and at the glibc level. This mail addresses the kernel problem. I will follow up with some suggestions for glibc changes.

For the sys_inotify_rm_watch() interface, the type of the 'wd' argument is
currently 'u32', it should be '__s32' .  That is Robert's suggestion, and
is consistent with the other declarations of watch descriptors in the
kernel source, in particular, the inotify_event structure in
include/linux/inotify.h:

struct inotify_event {
        __s32           wd;             /* watch descriptor */
        __u32           mask;           /* watch mask */
        __u32           cookie;         /* cookie to synchronize two events */
        __u32           len;            /* length (including nulls) of name */
        char            name[0];        /* stub for possible name */
};

The patch makes the changes needed for inotify_rm_watch().

Signed-off-by: Michael Kerrisk &lt;mtk.manpages@googlemail.com&gt;
Cc: Robert Love &lt;rlove@google.com&gt;
Cc: Vegard Nossum &lt;vegard.nossum@gmail.com&gt;
Cc: Ulrich Drepper &lt;drepper@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>saner FASYNC handling on file close</title>
<updated>2008-11-01T16:49:46Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2008-10-31T23:28:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=233e70f4228e78eb2f80dc6650f65d3ae3dbf17c'/>
<id>urn:sha1:233e70f4228e78eb2f80dc6650f65d3ae3dbf17c</id>
<content type='text'>
As it is, all instances of -&gt;release() for files that have -&gt;fasync()
need to remember to evict file from fasync lists; forgetting that
creates a hole and we actually have a bunch that *does* forget.

So let's keep our lives simple - let __fput() check FASYNC in
file-&gt;f_flags and call -&gt;fasync() there if it's been set.  And lose that
crap in -&gt;release() instances - leaving it there is still valid, but we
don't have to bother anymore.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>inotify: fix lock ordering wrt do_page_fault's mmap_sem</title>
<updated>2008-10-02T22:53:13Z</updated>
<author>
<name>Nick Piggin</name>
</author>
<published>2008-10-02T21:50:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=16dbc6c9616363fe53811abcbd935336dc0a0f01'/>
<id>urn:sha1:16dbc6c9616363fe53811abcbd935336dc0a0f01</id>
<content type='text'>
Fix inotify lock order reversal with mmap_sem due to holding locks over
copy_to_user.

Signed-off-by: Nick Piggin &lt;npiggin@suse.de&gt;
Reported-by: "Daniel J Blueman" &lt;daniel.blueman@gmail.com&gt;
Tested-by: "Daniel J Blueman" &lt;daniel.blueman@gmail.com&gt;
Cc: Ingo Molnar &lt;mingo@elte.hu&gt;
Cc: Peter Zijlstra &lt;a.p.zijlstra@chello.nl&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>[PATCH] sanitize __user_walk_fd() et.al.</title>
<updated>2008-07-27T00:53:34Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2008-07-22T13:59:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2d8f30380ab8c706f4e0a8f1aaa22b5886e9ac8a'/>
<id>urn:sha1:2d8f30380ab8c706f4e0a8f1aaa22b5886e9ac8a</id>
<content type='text'>
* do not pass nameidata; struct path is all the callers want.
* switch to new helpers:
	user_path_at(dfd, pathname, flags, &amp;path)
	user_path(pathname, &amp;path)
	user_lpath(pathname, &amp;path)
	user_path_dir(pathname, &amp;path)  (fail if not a directory)
  The last 3 are trivial macro wrappers for the first one.
* remove nameidata in callers.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>[PATCH] preparation to __user_walk_fd cleanup</title>
<updated>2008-07-27T00:53:32Z</updated>
<author>
<name>Al Viro</name>
</author>
<published>2008-07-22T12:09:30Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=256984a83880ff7ac78055cb87baea48137f0b77'/>
<id>urn:sha1:256984a83880ff7ac78055cb87baea48137f0b77</id>
<content type='text'>
Almost all users __user_walk_fd() and friends care only about struct path.
Get rid of the few that do not.

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>flag parameters: check magic constants</title>
<updated>2008-07-24T17:47:29Z</updated>
<author>
<name>Ulrich Drepper</name>
</author>
<published>2008-07-24T04:29:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e38b36f325153eaadd1c2a7abc5762079233e540'/>
<id>urn:sha1:e38b36f325153eaadd1c2a7abc5762079233e540</id>
<content type='text'>
This patch adds test that ensure the boundary conditions for the various
constants introduced in the previous patches is met.  No code is generated.

[akpm@linux-foundation.org: fix alpha]
Signed-off-by: Ulrich Drepper &lt;drepper@redhat.com&gt;
Acked-by: Davide Libenzi &lt;davidel@xmailserver.org&gt;
Cc: Michael Kerrisk &lt;mtk.manpages@googlemail.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>flag parameters: NONBLOCK in inotify_init</title>
<updated>2008-07-24T17:47:29Z</updated>
<author>
<name>Ulrich Drepper</name>
</author>
<published>2008-07-24T04:29:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=510df2dd482496083e1c3b1a8c9b6afd5fa4c7d7'/>
<id>urn:sha1:510df2dd482496083e1c3b1a8c9b6afd5fa4c7d7</id>
<content type='text'>
This patch adds non-blocking support for inotify_init1.  The
additional changes needed are minimal.

The following test must be adjusted for architectures other than x86 and
x86-64 and in case the syscall numbers changed.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include &lt;fcntl.h&gt;
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/syscall.h&gt;

#ifndef __NR_inotify_init1
# ifdef __x86_64__
#  define __NR_inotify_init1 294
# elif defined __i386__
#  define __NR_inotify_init1 332
# else
#  error "need __NR_inotify_init1"
# endif
#endif

#define IN_NONBLOCK O_NONBLOCK

int
main (void)
{
  int fd = syscall (__NR_inotify_init1, 0);
  if (fd == -1)
    {
      puts ("inotify_init1(0) failed");
      return 1;
    }
  int fl = fcntl (fd, F_GETFL);
  if (fl == -1)
    {
      puts ("fcntl failed");
      return 1;
    }
  if (fl &amp; O_NONBLOCK)
    {
      puts ("inotify_init1(0) set non-blocking mode");
      return 1;
    }
  close (fd);

  fd = syscall (__NR_inotify_init1, IN_NONBLOCK);
  if (fd == -1)
    {
      puts ("inotify_init1(IN_NONBLOCK) failed");
      return 1;
    }
  fl = fcntl (fd, F_GETFL);
  if (fl == -1)
    {
      puts ("fcntl failed");
      return 1;
    }
  if ((fl &amp; O_NONBLOCK) == 0)
    {
      puts ("inotify_init1(IN_NONBLOCK) set non-blocking mode");
      return 1;
    }
  close (fd);

  puts ("OK");

  return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ulrich Drepper &lt;drepper@redhat.com&gt;
Acked-by: Davide Libenzi &lt;davidel@xmailserver.org&gt;
Cc: Michael Kerrisk &lt;mtk.manpages@googlemail.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>
</feed>
