Bug 268832 - panics in check_uidgid() for outgoing packets
Summary: panics in check_uidgid() for outgoing packets
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.1-RELEASE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-net (Nobody)
URL:
Keywords: crash
Depends on:
Blocks:
 
Reported: 2023-01-08 22:47 UTC by Nikita Druba
Modified: 2023-01-12 10:02 UTC (History)
1 user (show)

See Also:


Attachments
kgdb -n last; bt (6.33 KB, text/plain)
2023-01-08 22:47 UTC, Nikita Druba
no flags Details
ipfw show (13.62 KB, text/plain)
2023-01-08 22:48 UTC, Nikita Druba
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Druba 2023-01-08 22:47:30 UTC
Created attachment 239348 [details]
kgdb -n last; bt

Hi!
Several days ago I was update of my FreeBSD from 12.3 to 13.1 and got the next trouble:
After boot fully updated OS(with packages), the OS freeze without any comments. I didn't have a chance to get some information about error or safely power off the system. It was fully freezed. 
OS was binary updated by freebsd-update. Freezing also repeated after switching to 13.1-RELENG kernel, builded from sources. 
After some time of troubleshooting and help from colleagues, got some idea about the reasons of this error.
Presumably, it was some component of ipfw. In attachments is ipfw show output, There a few lines at the beginning of rules is a counts, automatically added by cbsdd. In FreeBSD 12.3 they worked without errors, but after upgrade led to the described problem. When I disabling this cbsdd function, OS working well and dont try to freeze. 
To be more specific, I will describe the well-reproducing event, where I get an freezing. After compiling kernel with debug options I got a possibility to saw a reason of freeze. With debug kernel system stopped freezing, showed me kernel panic message and rebooted OS. In attachments I will rest backtrace of this event. 
Sequencing: 
Booting updated OS (without jails and any VMs, only primitive service apps), 
starting jail with a postgres (its can stable work a long time)
starting jail with a zabbix-server (that start to interact with a postgres jail)
after 10-60 seconds after launch of zabbix jail I get kernel panic.

I can easily repeat sequencing and get panic again to collect more information, if it needed.
Comment 1 Nikita Druba 2023-01-08 22:48:09 UTC
Created attachment 239349 [details]
ipfw show
Comment 2 Alexander V. Chernikov freebsd_committer freebsd_triage 2023-01-10 11:34:15 UTC
The following set of conditions leads to this:

* tcp_respond() does not propagate inpcb pointer if the connection is reset (TH_RST)
* On the output path, ipfw_chk is called
* ipfw may run check_uidgid() to verify jail/uid/gid ruleset opcodes
* check_uidgid() performs incpb lookup, requesting read lock
* As inpcb is already write-locked, the search results in the panic