<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/sys/modules/cam, branch main</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>pass(4): Allowlist CCB func_codes to harden passthrough ioctls</title>
<updated>2026-04-24T18:31:55+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2026-04-24T18:29:53+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e1cff854997884ed9b7251d409d9c9c7a025606d'/>
<id>e1cff854997884ed9b7251d409d9c9c7a025606d</id>
<content type='text'>
The pass(4) driver's CAMIOCOMMAND and CAMIOQUEUE ioctls accept arbitrary
CCBs from userland.  This device requires root to open, and thus send
these commands. Previously, the only func_code filter was a blocklist
check against the XPT_FC_XPT_ONLY flag.  This missed several dangerous
func_codes that lack that flag:

 - XPT_ABORT: the abort_ccb field is a raw kernel pointer from the
   user CCB payload.  xpt_action_default() dereferences it without
   validation, leading to kernel crashes or worse.

 - XPT_SASYNC_CB: the callback and callback_arg fields come directly
   from the user CCB payload and get registered as a kernel async
   callback, allowing arbitrary kernel code execution.

 - Target mode CCBs (XPT_EN_LUN, XPT_TARGET_IO, etc.) fall through
   directly to the SIM with user-controlled payloads.

Replace the XPT_FC_XPT_ONLY blocklist with an explicit allowlist of CCB
function codes that are known to be safe for userland to submit: I/O
operations (SCSI, ATA, NVMe, SMP, MMC), device queries, transport
settings, and a handful of safe control operations (NOOP, REL_SIMQ,
RESET_DEV, DEBUG). Normally, the /dev/pass* permissions only allow root
to access them, so this is only a safety issue by default.

Also reject CAM_DATA_PADDR and CAM_DATA_SG_PADDR, since these pass
user-supplied physical addresses directly to DMA with no validation,
which on systems without an IOMMU allows arbitrary host memory access.
Add `options PASS_UNSAFE_PADDR` to allow the old behavior.

Verified that camdd, camcontrol, smartmontools, and cdrtools use only
func_codes on the allowlist (XPT_SCSI_IO, XPT_ATA_IO, XPT_NVME_IO,
XPT_NVME_ADMIN, XPT_PATH_INQ, XPT_GDEV_TYPE, XPT_GET_TRAN_SETTINGS,
XPT_SET_TRAN_SETTINGS, XPT_RESET_DEV, XPT_DEBUG) and none use
CAM_DATA_PADDR.

PR:			293888, 293890
Assisted-By:		Claude Opus 4.6 (1M context)
Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D56486
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The pass(4) driver's CAMIOCOMMAND and CAMIOQUEUE ioctls accept arbitrary
CCBs from userland.  This device requires root to open, and thus send
these commands. Previously, the only func_code filter was a blocklist
check against the XPT_FC_XPT_ONLY flag.  This missed several dangerous
func_codes that lack that flag:

 - XPT_ABORT: the abort_ccb field is a raw kernel pointer from the
   user CCB payload.  xpt_action_default() dereferences it without
   validation, leading to kernel crashes or worse.

 - XPT_SASYNC_CB: the callback and callback_arg fields come directly
   from the user CCB payload and get registered as a kernel async
   callback, allowing arbitrary kernel code execution.

 - Target mode CCBs (XPT_EN_LUN, XPT_TARGET_IO, etc.) fall through
   directly to the SIM with user-controlled payloads.

Replace the XPT_FC_XPT_ONLY blocklist with an explicit allowlist of CCB
function codes that are known to be safe for userland to submit: I/O
operations (SCSI, ATA, NVMe, SMP, MMC), device queries, transport
settings, and a handful of safe control operations (NOOP, REL_SIMQ,
RESET_DEV, DEBUG). Normally, the /dev/pass* permissions only allow root
to access them, so this is only a safety issue by default.

Also reject CAM_DATA_PADDR and CAM_DATA_SG_PADDR, since these pass
user-supplied physical addresses directly to DMA with no validation,
which on systems without an IOMMU allows arbitrary host memory access.
Add `options PASS_UNSAFE_PADDR` to allow the old behavior.

Verified that camdd, camcontrol, smartmontools, and cdrtools use only
func_codes on the allowlist (XPT_SCSI_IO, XPT_ATA_IO, XPT_NVME_IO,
XPT_NVME_ADMIN, XPT_PATH_INQ, XPT_GDEV_TYPE, XPT_GET_TRAN_SETTINGS,
XPT_SET_TRAN_SETTINGS, XPT_RESET_DEV, XPT_DEBUG) and none use
CAM_DATA_PADDR.

PR:			293888, 293890
Assisted-By:		Claude Opus 4.6 (1M context)
Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D56486
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove residual blank line at start of Makefile</title>
<updated>2024-07-15T22:43:39+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2024-07-15T04:46:32+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e9ac41698b2f322d55ccf9da50a3596edb2c1800'/>
<id>e9ac41698b2f322d55ccf9da50a3596edb2c1800</id>
<content type='text'>
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
</pre>
</div>
</content>
</entry>
<entry>
<title>cam: Minor tidying up the cam module Makefile</title>
<updated>2023-11-03T16:15:39+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-11-02T20:41:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=03e2fc4c44465d29a8208eaa0bd65198efbd572b'/>
<id>03e2fc4c44465d29a8208eaa0bd65198efbd572b</id>
<content type='text'>
One src per line + sorting.

Sponsored by:		Netflix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
One src per line + sorting.

Sponsored by:		Netflix
</pre>
</div>
</content>
</entry>
<entry>
<title>sys: Remove $FreeBSD$: one-line sh pattern</title>
<updated>2023-08-16T17:54:58+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-16T17:54:58+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=031beb4e239bfce798af17f5fe8dba8bcaf13d99'/>
<id>031beb4e239bfce798af17f5fe8dba8bcaf13d99</id>
<content type='text'>
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
</pre>
</div>
</content>
</entry>
<entry>
<title>We don't need $M/$M in the path anymore.</title>
<updated>2020-03-15T17:40:14+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2020-03-15T17:40:14+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=ddeb85e13151e2704347c43ca97e561c5c539b25'/>
<id>ddeb85e13151e2704347c43ca97e561c5c539b25</id>
<content type='text'>
Now that machdep files are gone, we don't need $S/$M/$M in the path to find
them.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that machdep files are gone, we don't need $S/$M/$M in the path to find
them.
</pre>
</div>
</content>
</entry>
<entry>
<title>Sparc64 and pc98 needed cam_machdep and/or ata_machdep for various</title>
<updated>2020-03-14T18:35:44+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2020-03-14T18:35:44+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=30b5d9be24ec13157d18ae9bf01ef964f8187998'/>
<id>30b5d9be24ec13157d18ae9bf01ef964f8187998</id>
<content type='text'>
reasons. Those have now left the tree, and with them the need to have machdep
files. Places that called the routines in quesiton have been removed
previously. Remove these files from the Makefile to tidy up.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
reasons. Those have now left the tree, and with them the need to have machdep
files. Places that called the routines in quesiton have been removed
previously. Remove these files from the Makefile to tidy up.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add nvme_util.c to cam.ko.</title>
<updated>2018-04-07T19:29:19+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2018-04-07T19:29:19+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=14ce4632d401be3b1429c3e91be00010bc5b6569'/>
<id>14ce4632d401be3b1429c3e91be00010bc5b6569</id>
<content type='text'>
cam.ko can't load onto the kernel w/o nvme in the kernel. Add
nvme_util.c to cam.ko.

Noticed by: kib@
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
cam.ko can't load onto the kernel w/o nvme in the kernel. Add
nvme_util.c to cam.ko.

Noticed by: kib@
</pre>
</div>
</content>
</entry>
<entry>
<title>Move most of the contents of opt_compat.h to opt_global.h.</title>
<updated>2018-04-06T17:35:35+00:00</updated>
<author>
<name>Brooks Davis</name>
<email>brooks@FreeBSD.org</email>
</author>
<published>2018-04-06T17:35:35+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=6469bdcdb6a5968dc7edfcfb495d427b4bfdb3dd'/>
<id>6469bdcdb6a5968dc7edfcfb495d427b4bfdb3dd</id>
<content type='text'>
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
</pre>
</div>
</content>
</entry>
<entry>
<title>Add nvme_da back.</title>
<updated>2018-04-04T02:37:05+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2018-04-04T02:37:05+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=4887cfe7894618b3879e1eea20f7ff07164521ea'/>
<id>4887cfe7894618b3879e1eea20f7ff07164521ea</id>
<content type='text'>
Now that it can co-exist in the kernel with nvd, add it back to the
cam module.

Sponsored by: Netflix
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that it can co-exist in the kernel with nvd, add it back to the
cam module.

Sponsored by: Netflix
</pre>
</div>
</content>
</entry>
<entry>
<title>This should have been += so clean builds work.</title>
<updated>2018-03-14T16:45:04+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2018-03-14T16:45:04+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=2a559cb8c8177e89e7bf74a54c8a34fbcf7b7139'/>
<id>2a559cb8c8177e89e7bf74a54c8a34fbcf7b7139</id>
<content type='text'>
Noticed by: hps@
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Noticed by: hps@
</pre>
</div>
</content>
</entry>
</feed>
