2.3.10: Bug with locks held in fs code

Michael Matz (matzmich@cs.tu-berlin.de)
Mon, 12 Jul 1999 03:41:04 +0200 (MET DST)


Hi,

By browsing in the latest (2.3.10) diff I observed the following strange
things:

In linux/fs/fcntl.c:
---- snip ----
+ write_lock(&files->file_lock);
arg = find_next_zero_bit(&files->open_fds, NR_OPEN, arg);
if (arg >= current->rlim[RLIMIT_NOFILE].rlim_cur)
goto out_putf;
FD_SET(arg, &files->open_fds);
FD_CLR(arg, &files->close_on_exec);
+ write_unlock(&files->file_lock);
fd_install(arg, file);
error = arg;
out:
---- snap ----

In the middle, the "goto out_putf" exits this function without unlocking
the &files->file_lock.

And similarly in linux/fs/file_table.c:
---- snip ----
+ /* Writable file? */
+ if (S_ISREG(inode->i_mode) && (file->f_mode & FMODE_WRITE))
+ return 0;
}
+ file_list_unlock();
+ return 1; /* Tis' cool bro. */
+too_bad:
+ file_list_unlock();
+ return 0;
}
---- snap ----

The first "return 0" should better read "goto too_bad", otherwise the
function exits without doing "file_list_unlock();"

Ciao,
Michael.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/