On Mon, Nov 12, 2012 at 11:57 AM, Pavel Roskin <proski@xxxxxxx> wrote: > Quoting Eric Paris <eparis@xxxxxxxxxxxxxx>: > >> OMG this +1 -1 stuff is nuts... Ping, Al. int iterate_fd(struct files_struct *files, unsigned n, [snip] while (!res && n < fdt->max_fds) { file = rcu_dereference_check_fdtable(files, fdt->fd[n++]); if (file) res = f(p, file, n); } spin_unlock(&files->file_lock); return res; So we increment n (the file descriptor number) in the dereference, then pass that (wrong) number to f(). Every single f() (including SELinux, the cause of this bug) returns fd+1 (so now we are up by 2). Then all of the users of iterate fd actually use fd-1 (which is wrong) Why not have iterate_fd return -ENOENT on no entries and stop all of the stupid games? We fix the real bug (the above function should do the n++ after the f() call, and the interface is sane to design against... -Eric -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to majordomo@xxxxxxxxxxxxx with the words "unsubscribe selinux" without quotes as the message.