Repository navigation
Working with upstreams
Part VII of the system development guide.
NetBSD and Linux do not accept AI-generated code, so aiBSD does not send them patches. It does send bug reports for problems it finds in their code.
- Verify against current upstream. Several candidates found by diffing NetBSD's 5.6-era DRM turned out fixed, unreachable or trivial in Linux 7.3.7; only one held up, and it was NetBSD's. Read the current code and every call site before writing anything.
-
Check reachability. An affected helper is only a real bug if a
built caller reaches it; say which callers are affected and which are
not (e.g. the interval-tree report notes that
drm_mmand i915 userptr use other code paths on NetBSD). - Say how it was found: by code reading, or reproduced, and on what.
- Describe the fix in words rather than sending a patch; a one-line configuration flag is fine to quote.
- Disclose that the problem was found with AI assistance.
- Keep drafts outside the tree (they are not committed); a maintainer submits them.
Security problems go privately to the security officer (security-officer@NetBSD.org), never to the public bug database, and are not described in public (commits, this wiki) until NetBSD has fixed them or agreed to disclosure.
- NetBSD:
send-pr(1)or the web form at gnats.netbsd.org (categories such askern,toolchain). - Linux DRM: the freedesktop.org GitLab issue tracker of the relevant driver, or the dri-devel mailing list.
aiBSD's trunk is a mirror of NetBSD's (the official git mirror on
GitHub), and aiBSD work lives on branches merged from it. Sync
regularly:
- Fast-forward the fork's
trunkto NetBSD's — on GitHub with its "Sync fork" button orgh repo sync, or locally from anupstreamremote. Never with--forceor "Discard commits", which would throw away anything committed totrunk. - Fetch, and list the new upstream commits touching what aiBSD has
rewritten (
sys/external/bsd/drm2,common, the drmkms modules,tests/dev/drm, set lists): each needs a decision — port, adapt or drop (changes to NetBSD's old 5.6dist/are dropped). - Merge
trunkinto the working branches.
Once aiBSD commits land on trunk itself, fast-forwarding stops being
possible for good; from then on NetBSD's trunk is merged into ours.
| Draft | Upstream | Summary |
|---|---|---|
netbsd-pr-drm2-str_has_prefix.txt |
NetBSD | compat str_has_prefix returns the inverted result; named TV modes never match |
netbsd-pr-tools-mpfr-clang.txt |
NetBSD |
build.sh tools fails in MPFR configure with clang on glibc hosts |
netbsd-pr-drm2-interval_tree.txt |
NetBSD | compat interval-tree queries miss overlapping intervals; affects radeon/amdgpu GPU VA overlap checks |
netbsd-pr-drm2-linux_xa.txt |
NetBSD | compat xa_store on an existing key corrupts the tree; xa_find_after, xa_alloc edge cases |
netbsd-pr-drm2-linux_dma_fence.txt |
NetBSD |
dma_fence_wait_any_timeout checks past the end of the array; a KASSERT tests a bit number as a mask |
netbsd-pr-drm2-dma_fence_array.txt |
NetBSD | fence-array member callback asserts the wrong lock (DIAGNOSTIC panic); racy pending count; truncated context |
netbsd-pr-rumpuser_dl-strtab-overflow.txt |
NetBSD | heap overflow in every rump_init() copying symbol names; unneeded <sys/evcnt.h> breaks non-NetBSD hosts |
netbsd-pr-drm2-dma_buf-release.txt |
NetBSD | dma-buf exporters' release never called: every PRIME export leaks its GEM object |
netbsd-pr-rump-kthread_join-uaf.txt |
NetBSD | rump's kthread_join() reads the lwp after kthread_exit() freed it; rare hangs |
netbsd-security-drm2-sync_file_get_fence.txt |
NetBSD (security officer) |
sync_file_get_fence() took any descriptor's data as a sync file; fixed upstream (PR kern/61098) |
netbsd-pr-drm2-kfifo-ratelimit.txt |
NetBSD | compat kfifo_in cannot fill an empty FIFO; ratelimit_state_init divides by zero below one second (latent) |
netbsd-pr-uao_dropswap_range.txt |
NetBSD |
uao_dropswap_range leaves freed swap slots in the array of small anonymous objects (not reachable from tmpfs or memfd) |
netbsd-pr-uvm_obj_wirepages-dropswap.txt |
NetBSD |
uvm_obj_wirepages frees the swap slots of the wrong pages (data loss) |
netbsd-pr-virtio-queue-enable-zero.txt |
NetBSD | virtio_pci writes 0 to queue_enable when freeing a queue, which virtio 1.0 forbids |
netbsd-pr-tests-net-httpd-reverse-dns.txt |
NetBSD | the network tests' httpd does reverse DNS; on machines with name servers the fetch times out (mtudisc6_basic, ipforwarding_fastforward_v6) |
netbsd-pr-librumpclient-longjmp-stale-respwait.txt |
NetBSD | a signal handler that longjmps out of a rumphijack'd syscall leaves a stale wait record; the next syscall crashes |
linux-drm-drm_memcpy_from_wc-tail.txt |
Linux DRM |
memcpy_fallback() (drm_cache) copies a full bounce buffer for the tail |
netbsd-pr-drm2-pci_iomap-bars.txt |
NetBSD |
pci_iounmap unmaps the whole BAR (i915 maps 2 MiB of 16) and teardown unmaps it again; the upper half of a 64-bit BAR is probed as a BAR |
netbsd-pr-drm2-idr-null-entries.txt |
NetBSD |
idr_for_each/idr_get_next do not skip NULL entries as Linux does (latent upstream; panicked vgem) |
netbsd-pr-libm-acos-near-one.txt |
NetBSD | x87 acos (i386/amd64) loses up to ~2^18 ulp near 1: 1 - x*x cancels; (1 - x)(1 + x) fixes it (as glibc did in 2012) |
linux-drm-ast-dp-relicense.txt |
Linux DRM | request (as a patch for acks) to dual-license ast's two GPL-only DisplayPort files GPL-2.0 OR MIT, like the rest of ast |
A GPL-only file in an otherwise permissive driver blocks a GPL-free
build. Asking costs little: the change is one SPDX line per file, sent
as a patch on which every copyright holder of non-trivial changes
replies with Acked-by (find them with git log on the file; tree-wide
mechanical changes are usually not counted). Point out history that
helps: code ported from permissively licensed sources, or a GPL tag
added only by the 2017 SPDX cleanup to a file that had no notice. Have
a fallback ready (a clean-room replacement from a permissive source, or
a stub) in case anyone declines. Linux's rules for tool-assisted
contributions apply (Documentation/process/coding-assistants.rst): no
Signed-off-by from the tool, and say what the tool did.
Imported code (dist/ directories) is kept pristine where possible.
Where it must change, the change is made in place and written as the
code it would be upstream, so NetBSD or the original project could take
it unchanged:
-
No labels. Comments say what the code does and why, never who
changed it: no
aiBSD:tags (NetBSD does not label its own code "NetBSD:"). Copyright lines naming the aiBSD contributors are attribution and stay. -
No aiBSD macro. Nothing defines
__aiBSD__; a local change is unconditional, not hidden behind an#ifdef. - One commit per change, its message saying what and why.
Which changes are local is recorded outside the code:
git log -- <dir>/dist lists them, and the import's README.aibsd
names the import's version and summarizes what differs and why. To
see the whole difference, diff dist/ against the imported commit the
README names.
aiBSD changes NetBSD's core when a gap would cripple what users get
(see the plan's core changes).
Such changes are kept small and in separate commits — new files and
hooks rather than rewrites — so that merging NetBSD's trunk stays easy
and each change can be offered to NetBSD on its own. Upstream churn in
the files concerned is worth checking first (git log --since on
trunk): sys/arch/x86/x86/pmap.c, for instance, changed three times in
three years.
aiBSD system development guide
Tutorial
II — Building
III — The kernel
- Kernel basics
- Booting and kernel modules
- The boot loader
- Threads, processes, tasks
- Devices and drivers
- Files, descriptors, device nodes
- PCI
- Virtual memory
- Memory and DMA
- Page tables, TLBs, memory types
- Firmware
- State and events
- The console
- Power management
IV — Linux compat layer
V — DRM
VI — Testing
VII — Upstreams
Appendices