1. Oct 26, 2009
  2. Oct 24, 2009
  3. Oct 22, 2009
  4. Oct 21, 2009
    • Andreas Gruenbacher's avatar
      dnotify: ignore FS_EVENT_ON_CHILD · 94552684
      Andreas Gruenbacher authored
      Mask off FS_EVENT_ON_CHILD in dnotify_handle_event().  Otherwise, when there
      is more than one watch on a directory and dnotify_should_send_event()
      succeeds, events with FS_EVENT_ON_CHILD set will trigger all watches and cause
      spurious events.
      
      This case was overlooked in commit e42e2773
      
      .
      
      	#define _GNU_SOURCE
      
      	#include <stdio.h>
      	#include <stdlib.h>
      	#include <unistd.h>
      	#include <signal.h>
      	#include <sys/types.h>
      	#include <sys/stat.h>
      	#include <fcntl.h>
      	#include <string.h>
      
      	static void create_event(int s, siginfo_t* si, void* p)
      	{
      		printf("create\n");
      	}
      
      	static void delete_event(int s, siginfo_t* si, void* p)
      	{
      		printf("delete\n");
      	}
      
      	int main (void) {
      		struct sigaction action;
      		char *tmpdir, *file;
      		int fd1, fd2;
      
      		sigemptyset (&action.sa_mask);
      		action.sa_flags = SA_SIGINFO;
      
      		action.sa_sigaction = create_event;
      		sigaction (SIGRTMIN + 0, &action, NULL);
      
      		action.sa_sigaction = delete_event;
      		sigaction (SIGRTMIN + 1, &action, NULL);
      
      	#	define TMPDIR "/tmp/test.XXXXXX"
      		tmpdir = malloc(strlen(TMPDIR) + 1);
      		strcpy(tmpdir, TMPDIR);
      		mkdtemp(tmpdir);
      
      	#	define TMPFILE "/file"
      		file = malloc(strlen(tmpdir) + strlen(TMPFILE) + 1);
      		sprintf(file, "%s/%s", tmpdir, TMPFILE);
      
      		fd1 = open (tmpdir, O_RDONLY);
      		fcntl(fd1, F_SETSIG, SIGRTMIN);
      		fcntl(fd1, F_NOTIFY, DN_MULTISHOT | DN_CREATE);
      
      		fd2 = open (tmpdir, O_RDONLY);
      		fcntl(fd2, F_SETSIG, SIGRTMIN + 1);
      		fcntl(fd2, F_NOTIFY, DN_MULTISHOT | DN_DELETE);
      
      		if (fork()) {
      			/* This triggers a create event */
      			creat(file, 0600);
      			/* This triggers a create and delete event (!) */
      			unlink(file);
      		} else {
      			sleep(1);
      			rmdir(tmpdir);
      		}
      
      		return 0;
      	}
      
      Signed-off-by: default avatarAndreas Gruenbacher <agruen@suse.de>
      Signed-off-by: default avatarEric Paris <eparis@redhat.com>
      94552684
  5. Oct 20, 2009
  6. Oct 19, 2009
    • Wei Yongjun's avatar
      inotify: fix coalesce duplicate events into a single event in special case · 3de0ef4f
      Wei Yongjun authored
      
      
      If we do rename a dir entry, like this:
      
        rename("/tmp/ino7UrgoJ.rename1", "/tmp/ino7UrgoJ.rename2")
        rename("/tmp/ino7UrgoJ.rename2", "/tmp/ino7UrgoJ")
      
      The duplicate events should be coalesced into a single event. But those two
      events do not be coalesced into a single event, due to some bad check in
      event_compare(). It can not match the two NULL inodes as the same event.
      
      Signed-off-by: default avatarWei Yongjun <yjwei@cn.fujitsu.com>
      Signed-off-by: default avatarEric Paris <eparis@redhat.com>
      3de0ef4f
    • Eric Paris's avatar
      inotify: deprecate the inotify kernel interface · cdc321ff
      Eric Paris authored
      
      
      In 2.6.33 there will be no users of the inotify interface.  Mark it for
      removal as fsnotify is more generic and is easier to use.
      
      Signed-off-by: default avatarEric Paris <eparis@redhat.com>
      cdc321ff
    • Eric Paris's avatar
      fsnotify: do not set group for a mark before it is on the i_list · 9f0d793b
      Eric Paris authored
      
      
      fsnotify_add_mark is supposed to add a mark to the g_list and i_list and to
      set the group and inode for the mark.  fsnotify_destroy_mark_by_entry uses
      the fact that ->group != NULL to know if this group should be destroyed or
      if it's already been done.
      
      But fsnotify_add_mark sets the group and inode before it actually adds the
      mark to the i_list and g_list.  This can result in a race in inotify, it
      requires 3 threads.
      
      sys_inotify_add_watch("file")	sys_inotify_add_watch("file")	sys_inotify_rm_watch([a])
      inotify_update_watch()
      inotify_new_watch()
      inotify_add_to_idr()
         ^--- returns wd = [a]
      				inotfiy_update_watch()
      				inotify_new_watch()
      				inotify_add_to_idr()
      				fsnotify_add_mark()
      				   ^--- returns wd = [b]
      				returns to userspace;
      								inotify_idr_find([a])
      								   ^--- gives us the pointer from task 1
      fsnotify_add_mark()
         ^--- this is going to set the mark->group and mark->inode fields, but will
      return -EEXIST because of the race with [b].
      								fsnotify_destroy_mark()
      								   ^--- since ->group != NULL we call back
      									into inotify_freeing_mark() which calls
      								inotify_remove_from_idr([a])
      
      since fsnotify_add_mark() failed we call:
      inotify_remove_from_idr([a])     <------WHOOPS it's not in the idr, this could
      					have been any entry added later!
      
      The fix is to make sure we don't set mark->group until we are sure the mark is
      on the inode and fsnotify_add_mark will return success.
      
      Signed-off-by: default avatarEric Paris <eparis@redhat.com>
      9f0d793b
  7. Oct 18, 2009
  8. Oct 17, 2009
  9. Oct 16, 2009
    • Darrick J. Wong's avatar
      KVM: Prevent kvm_init from corrupting debugfs structures · 0ea4ed8e
      Darrick J. Wong authored
      I'm seeing an oops condition when kvm-intel and kvm-amd are modprobe'd
      during boot (say on an Intel system) and then rmmod'd:
      
         # modprobe kvm-intel
           kvm_init()
           kvm_init_debug()
           kvm_arch_init()  <-- stores debugfs dentries internally
           (success, etc)
      
         # modprobe kvm-amd
           kvm_init()
           kvm_init_debug() <-- second initialization clobbers kvm's
                                internal pointers to dentries
           kvm_arch_init()
           kvm_exit_debug() <-- and frees them
      
         # rmmod kvm-intel
           kvm_exit()
           kvm_exit_debug() <-- double free of debugfs files!
      
           *BOOM*
      
      If execution gets to the end of kvm_init(), then the calling module has been
      established as the kvm provider.  Move the debugfs initialization to the end of
      the function, and remove the now-unnecessary call to kvm_exit_debug() from the
      error path.  That way we avoid trampling on the debugfs entries and freeing
      them twice.
      
      Cc: stable@kernel.org
      Signed-off-by: Dar...
      0ea4ed8e
    • Frederik Deweerdt's avatar
      KVM: MMU: fix pointer cast · 8a8365c5
      Frederik Deweerdt authored
      On a 32 bits compile, commit 3da0dd43
      
      
      introduced the following warnings:
      
      arch/x86/kvm/mmu.c: In function ‘kvm_set_pte_rmapp’:
      arch/x86/kvm/mmu.c:770: warning: cast to pointer from integer of different size
      arch/x86/kvm/mmu.c: In function ‘kvm_set_spte_hva’:
      arch/x86/kvm/mmu.c:849: warning: cast from pointer to integer of different size
      
      The following patch uses 'unsigned long' instead of u64 to match the
      pointer size on both arches.
      
      Signed-off-by: default avatarFrederik Deweerdt <frederik.deweerdt@xprog.eu>
      Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
      8a8365c5
    • Marcelo Tosatti's avatar
      KVM: use proper hrtimer function to retrieve expiration time · ace15464
      Marcelo Tosatti authored
      
      
      hrtimer->base can be temporarily NULL due to racing hrtimer_start.
      See switch_hrtimer_base/lock_hrtimer_base.
      
      Use hrtimer_get_remaining which is robust against it.
      
      CC: stable@kernel.org
      Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
      Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
      ace15464
    • Gwendal Grignou's avatar
      sata_mv: Prevent PIO commands to be defered too long if traffic in progress. · 159a7ff7
      Gwendal Grignou authored
      
      
      Use excl_link when non NCQ commands are defered, to be sure they are processed
      as soon as outstanding commands are completed. It prevents some commands to be
      defered indifinitely when using a port multiplier.
      
      Signed-off-by: default avatarGwendal Grignou <gwendal@google.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      159a7ff7
    • Alan Cox's avatar
      pata_sc1200: Fix crash on boot · 6d4f950e
      Alan Cox authored
      
      
      The SC1200 needs a NULL terminator or it may cause a crash on boot.
      
      Bug #14227
      
      Also correct a bogus comment as the driver had serializing added so can run
      dual port.
      
      Signed-off-by: default avatarAlan Cox <alan@linux.intel.com>
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      6d4f950e
    • Tejun Heo's avatar
      libata: fix internal command failure handling · f4b31db9
      Tejun Heo authored
      
      
      When an internal command fails, it should be failed directly without
      invoking EH.  In the original implemetation, this was accomplished by
      letting internal command bypass failure handling in ata_qc_complete().
      However, later changes added post-successful-completion handling to
      that code path and the success path is no longer adequate as internal
      command failure path.  One of the visible problems is that internal
      command failure due to timeout or other freeze conditions would
      spuriously trigger WARN_ON_ONCE() in the success path.
      
      This patch updates failure path such that internal command failure
      handling is contained there.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: stable@kernel.org
      Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
      f4b31db9