Page MenuHomeFreeBSD

Fix "vrefact: wrong use count 0" with DRM
ClosedPublic

Authored by trasz on Fri, Nov 1, 3:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 13, 10:29 AM
Unknown Object (File)
Sat, Nov 9, 8:34 PM
Unknown Object (File)
Fri, Nov 8, 12:33 PM
Unknown Object (File)
Wed, Nov 6, 3:46 AM
Unknown Object (File)
Wed, Nov 6, 3:32 AM
Unknown Object (File)
Sun, Nov 3, 8:20 PM

Details

Summary

Bump the vnode use count, not just its hold count. This fixes a panic
triggered by fstatat(..., AT_EMPTY_PATH) on DRM device nodes, which happens
to be what glxinfo(1) from Ubuntu Jammy is doing.

PR: kern/274538

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

trasz requested review of this revision.Fri, Nov 1, 3:12 PM

This follows a somewhat similar fix in https://reviews.freebsd.org/D29323?id=86801. I can't say I have a proper understanding of what's going on here though.

Here's the test case from Alex S:

#define _GNU_SOURCE

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

int main() {
  int fd = open("/dev/dri/card0", O_RDWR);
  assert(fd != -1);

  struct stat st;
  fstatat(fd, "", &st, AT_EMPTY_PATH);

  return 0;
}

This cannot be right.

If the file references vnode, vnode must be active and have the use count at least 1, because file vref-ed the vnode on open.

In D47391#1080971, @kib wrote:

This cannot be right.

If the file references vnode, vnode must be active and have the use count at least 1, because file vref-ed the vnode on open.

Good point. Okay, so here's another attempt; this time in code specific to linuxkpi.

If going that way, then you can remove the adjacent vhold() and vdrop() as they are redundant.

It should be fine modulo the note about vhold() no longer needed.

This revision is now accepted and ready to land.Mon, Nov 4, 10:24 PM
trasz edited the summary of this revision. (Show Details)

Get rid of vhold/vdrop. I've been running it for a few days
and it appears to work fine.

This revision now requires review to proceed.Thu, Nov 7, 10:23 AM
This revision is now accepted and ready to land.Fri, Nov 8, 5:03 PM
This revision was automatically updated to reflect the committed changes.