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
Unknown Object (File)
Thu, Jan 30, 3:03 AM
Unknown Object (File)
Sat, Jan 25, 12:36 PM
Unknown Object (File)
Sat, Jan 25, 10:02 AM
Unknown Object (File)
Thu, Jan 23, 5:47 PM
Unknown Object (File)
Dec 12 2024, 9:47 AM
Unknown Object (File)
Dec 10 2024, 8:03 PM
Unknown Object (File)
Dec 4 2024, 4:16 AM
Unknown Object (File)
Nov 30 2024, 11:11 PM
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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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 ↗(On Diff #70744)

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.