Page MenuHomeFreeBSD

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

Authored by trasz on Nov 1 2024, 3:12 PM.
Tags
None
Referenced Files
F106170114: D47391.diff
Thu, Dec 26, 1:15 PM
Unknown Object (File)
Thu, Dec 12, 9:10 PM
Unknown Object (File)
Fri, Nov 29, 6:11 PM
Unknown Object (File)
Nov 13 2024, 10:29 AM
Unknown Object (File)
Nov 9 2024, 8:34 PM
Unknown Object (File)
Nov 8 2024, 12:33 PM
Unknown Object (File)
Nov 6 2024, 3:46 AM
Unknown Object (File)
Nov 6 2024, 3:32 AM

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 Passed
Unit
No Test Coverage
Build Status
Buildable 60433
Build 57317: arc lint + arc unit

Event Timeline

trasz requested review of this revision.Nov 1 2024, 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.Nov 4 2024, 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.Nov 7 2024, 10:23 AM
This revision is now accepted and ready to land.Nov 8 2024, 5:03 PM
This revision was automatically updated to reflect the committed changes.