Page MenuHomeFreeBSD

bhyve: don't try to capsicumise after failed open
ClosedPublic

Authored by kaktus on Nov 7 2017, 11:22 PM.
Tags
Referenced Files
Unknown Object (File)
Sun, Apr 21, 1:02 PM
Unknown Object (File)
Fri, Apr 19, 1:56 AM
Unknown Object (File)
Thu, Apr 18, 11:20 PM
Unknown Object (File)
Dec 20 2023, 8:39 AM
Unknown Object (File)
Oct 28 2023, 3:15 AM
Unknown Object (File)
Oct 13 2023, 5:10 PM
Unknown Object (File)
Oct 12 2023, 8:51 AM
Unknown Object (File)
Jul 10 2023, 4:22 PM
Subscribers

Details

Summary

When user specifies -l option and the target file can't be opened (ie. nmdm module isn't loaded and /dev/nmdm* is specified) bhyve tries to apply capabilities to not open file. Enclose that part in an if statement and only run it on correctly opened descriptor and in case of error provide meaningful message about the problem.

Test Plan

After applying this patch, specifying non existing file (or not loading nmdm) to -l option should effect in

Unable to initialize backend '/dev/asdf' for LPC device COM1

instead of

Unable to apply rights for sandbox

Diff Detail

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

Event Timeline

trasz added inline comments.
usr.sbin/bhyve/uart_emul.c
693 ↗(On Diff #34905)

Use err(), perhaps, to not hide the error string?

usr.sbin/bhyve/uart_emul.c
693 ↗(On Diff #34905)

Although I'm not saying no to this, it'll not help much in this case.
If @grehan will be interested I can prepare separate patch and replace all occurrences of errx with err in the capsicum cases.

Thanks for this patch.

The err vs errx can be a separate discussion.

This revision is now accepted and ready to land.Nov 9 2017, 2:40 PM
emaste added inline comments.
usr.sbin/bhyve/uart_emul.c
693 ↗(On Diff #34905)

I agree that such a change ought to be a separate patch, but also agree it is probably not valuable to have the error.

@grehan @emaste thanks for review guys, will commit it asap!