lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160511150959.GA18352@qarx.de>
Date:	Wed, 11 May 2016 17:09:59 +0200
From:	Felix von Leitner <felix-linuxkernel@...e.de>
To:	Peter Meerwald-Stadler <pmeerw@...erw.net>
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: Re: getting mysterious (to me) EINVAL from inotify_rm_watch

Thus spake Peter Meerwald-Stadler (pmeerw@...erw.net):
> > I am trying to add inotify support to my tail implementation (for -F).
> > This is what happens:
> > 
> >   inotify_init()                          = 4
> >   inotify_add_watch(4, "/tmp/foo", IN_MODIFY) = 1
> >   inotify_rm_watch(4, 1)                  = -1 EINVAL (Invalid argument)
> >   inotify_add_watch(4, "/tmp/foo", IN_MODIFY) = 2
> > 
> > There is also some polling, some reading and some statting going on here, but
> > those are on other descriptors than 4 so they should not matter).
> > 
> > Can somebody explain the EINVAL I'm getting from inotify_rm_watch to me?
> > This is a stock kernel 4.5.0.

> #include <stdio.h>
> #include <sys/inotify.h>
> int main() {
> int fd, i, j;
> printf("init %d\n", fd=inotify_init()); // 3
> printf("add %d\n", i=inotify_add_watch(fd, "/tmp/foo", IN_MODIFY)); // 1
> printf("rm %d\n", inotify_rm_watch(fd, i)); // 0
> printf("add %d\n", j=inotify_add_watch(fd, "/tmp/foo", IN_MODIFY)); // 2
> return 0;
> }

> Ubuntu kernel x86_64 4.4.0-21, seems to work here
> so we have to guess what's going on between _add and _rm?

Oh, it turns out to be my fault.
I called close() on the file first, then did inotify_rm_watch.

It was not clear to me from the documentation that that automatically
removes the inotify watch.

Sorry for the noise,

Felix

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ