Yes, it's not really a kernel issue, but since we are talking about
locks I think I should mention it here. Updating wtmp doesn't need
any locking at all - open() with O_APPEND ensures writes at the end
of file. Some programs unfortunately do it (util-linux login for
example). This allows an easy denial of service - any user can open
wtmp and hold a lock on it (a shared lock is enough). Locks should
not be used on important system files which are world readable -
a separate file which is mode 0600 should be used for locking (see
lckpwdf() in libc >= 5.3.5 - can't just lock /etc/passwd, so it does
fcntl() locks on a zero length file /etc/.pwd.lock).
It's OK to use locks, say, on the user's mailbox - but one should be
careful when locking important system files...
Marek