Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 232267 - kernel BUG at fs/locks.c:1799 - local DoS
Summary: kernel BUG at fs/locks.c:1799 - local DoS
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel
Version: 4.3
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Jeff Layton
QA Contact: Martin Jenner
Whiteboard: impact=moderate,source=bugzilla,repor...
Depends On:
TreeView+ depends on / blocked
Reported: 2007-03-14 16:39 UTC by Jussi-Pekka Hamalainen
Modified: 2007-11-17 01:14 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2007-06-08 12:45:44 UTC
Target Upstream Version:

Attachments (Terms of Use)

Description Jussi-Pekka Hamalainen 2007-03-14 16:39:57 UTC
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 14:01:03 UTC
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 12:45:44 UTC
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.