[Bug 220037] [vfs] sys/kern/vfs_bio.c: a sleep-under-rwlock bug in getblk

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Jun 16 08:34:21 UTC 2017


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220037

            Bug ID: 220037
           Summary: [vfs] sys/kern/vfs_bio.c: a sleep-under-rwlock bug in
                    getblk
           Product: Base System
           Version: 11.0-RELEASE
          Hardware: i386
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: baijiaju1990 at 163.com

The kernel may sleep under a rwlock, and the function call path in file
"sys/kern/vfs_bio.c" in FreeBSD 11.0 is:
getblk [line 3498: acquire the rwlock by BO_RLOCK]
  bp_unmapped_get_kva [line 3582]
    bufspace_wait [line 3430]
      buf_flush [line 637] (rw_wunlock(&nblock) is called, but not BO_RUNLOCK)
        flushbufqueues [line 2977]
          malloc(M_WAITOK) [line 3093] --> may sleep

The possible fix of this bug is to set the last parameter "M_WAITOK" in malloc
to "M_NOWAIT".

This bug is found by a static analysis tool written by myself, and it is
checked by my review of the FreeBSD code.

By the way, I am a freshman in developing FreeBSD drivers, and I am willing to
submit a patch. But I do not know how to write and submit a patch, and where to
submit, so I am looking forward to useful advice :)

Jia-Ju Bai

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list