Page MenuHomeFreeBSD

Don't access a user buffer directly from the kernel.
ClosedPublic

Authored by jhb on Apr 18 2020, 7:41 PM.
Tags
None
Referenced Files
F161698595: D24487.diff
Mon, Jul 6, 1:31 AM
Unknown Object (File)
Apr 28 2026, 9:35 AM
Unknown Object (File)
Apr 27 2026, 7:04 AM
Unknown Object (File)
Apr 19 2026, 7:11 AM
Unknown Object (File)
Apr 18 2026, 11:10 PM
Unknown Object (File)
Apr 17 2026, 3:14 AM
Unknown Object (File)
Apr 5 2026, 11:41 AM
Unknown Object (File)
Mar 20 2026, 4:38 AM
Subscribers

Details

Summary

The handle_string callback for the ENCIOC_SETSTRING ioctl was passing a
user pointer to memcpy(). Fix by using copyin() instead.

For ENCIOC_GETSTRING ioctls, the handler was storing the user pointer
in a CCB's data_ptr field where it was indirected by other code. Fix
this by allocating a temporary buffer (which ENCIOC_SETSTRING already
did) and copying the result out to the user buffer after the CCB has
been processed.

Test Plan
  • compile tested only

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 30590
Build 28331: arc lint + arc unit

Event Timeline

This was found by CheriBSD where user and kernel pointers are different types so generate compile errors, but SMAP should have caught this one at runtime I think.

jrtc27 added inline comments.
sys/cam/scsi/scsi_enc_ses.c
2909

You need to free buf on this error path.

Modulo the free() note.

This revision is now accepted and ready to land.Apr 18 2020, 10:42 PM
jhb marked an inline comment as done.Apr 21 2020, 5:46 PM
This revision was automatically updated to reflect the committed changes.