Page MenuHomeFreeBSD

Capsicumise dd
ClosedPublic

Authored by kaktus on Nov 16 2016, 9:37 PM.
Referenced Files
Unknown Object (File)
Fri, Dec 13, 4:58 PM
Unknown Object (File)
Sun, Dec 8, 10:32 PM
Unknown Object (File)
Thu, Dec 5, 5:06 PM
Unknown Object (File)
Wed, Dec 4, 6:43 PM
Unknown Object (File)
Mon, Dec 2, 11:14 PM
Unknown Object (File)
Wed, Nov 27, 12:57 AM
Unknown Object (File)
Sun, Nov 24, 8:12 AM
Unknown Object (File)
Sat, Nov 23, 1:01 PM
Subscribers

Details

Summary

This patch puts dd in capsicum based sandbox.

Sponsored by: Mysterious Code Ltd.

Test Plan

Tested with make test and by hand with various options like seek and skip.

Tape _untested_ but it should work as all ioctls related to tape are permitted.

Diff Detail

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

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
kaktus edited the test plan for this revision. (Show Details)
kaktus added reviewers: robak, capsicum.
kaktus set the repository for this revision to rS FreeBSD src repository - subversion.
kaktus added a project: capsicum.
freebsd/bin/dd/dd.c
179 ↗(On Diff #22267)

it might make more sense to do this on like 160, where we set CAP_WRITE etc

freebsd/bin/dd/dd.c
179 ↗(On Diff #22267)

But I want to _clear_ the flag if the file is open write only.

allanjude edited edge metadata.
allanjude added inline comments.
freebsd/bin/dd/dd.c
179 ↗(On Diff #22267)

I misunderstood what was happening, sorry.

This appears correct.

This revision is now accepted and ready to land.Nov 16 2016, 11:08 PM
kaktus edited edge metadata.

Regenerate patch.

This revision now requires review to proceed.Nov 17 2016, 11:10 AM
kaktus edited edge metadata.

Regenerate, this time with -U999999.

oshogbo requested changes to this revision.Nov 17 2016, 8:59 PM
oshogbo added a reviewer: oshogbo.
oshogbo added a subscriber: oshogbo.
oshogbo added inline comments.
bin/dd/dd.c
100 ↗(On Diff #22279)

We should check errno and cap_enter in one line.
Basically you should not warn if Capsicum is unavailable, user decided to compile kernel without CAPSICUM so we should not inform go about that on every step.
Some architectures even don't have Capsicum enable by default.

140 ↗(On Diff #22279)

Style.
{ MTIOCTOP, FIODTYPE }

192 ↗(On Diff #22279)

Style. To big indent, should be tab and 4 spaces.

196 ↗(On Diff #22279)

Here you don't need to check errno.

This revision now requires changes to proceed.Nov 17 2016, 8:59 PM
bin/dd/dd.c
183 ↗(On Diff #22279)

Here you also don't need to check errno.

bin/dd/dd.c
196 ↗(On Diff #22279)

To clarify, the caph_ helpers handle the errno checking internally.

bin/dd/dd.c
98 ↗(On Diff #22279)

Sorry for being PITA, but do we need that?
Which function requires time zones?

kaktus edited edge metadata.

Updated diff after requested changes.

kaktus added inline comments.
bin/dd/dd.c
140 ↗(On Diff #22279)

Maybe, as I don't see this rule defined _clearly_ in style(9).

robak edited edge metadata.

@oshogbo @allanjude It works for me, when I test it, so if I can get approval from someone with src commit bit, I am happy to commit it.

bin/dd/dd.c
140 ↗(On Diff #22279)

Some of style(9) is by example, not explicit - this is probably the closest even though it's for something else:

Enumeration values are all uppercase.

enum enumtype { ONE, TWO } et;
192 ↗(On Diff #22279)

Line 188 should be:
<tab><space><space><space><space>errno != ENOSYS
looking at the raw diff it has two tabs and four spaces in the most recent upload

kaktus edited edge metadata.

Fix indentation.

I think this looks good, and have asked @oshogbo if he can check again.

Also, let me say thank you for your interest and effort in applying Capsicum and submitting these patches.

oshogbo edited edge metadata.

Good work :)
Please just fix the error messages.

bin/dd/dd.c
146 ↗(On Diff #22334)

One more thing.
You are inconsistent in error messages.
Everywhere in file we have sentence start from small later ;(

This revision is now accepted and ready to land.Nov 18 2016, 6:46 PM
kaktus edited edge metadata.
kaktus marked an inline comment as done.
  • be more consistent with lowercase in err().
This revision now requires review to proceed.Nov 18 2016, 7:38 PM
This revision was automatically updated to reflect the committed changes.
kaktus edited edge metadata.

Make it compile on older releases as dd is part of bootstrap and pre 12-C don't have capsicum_helpers.h installed.

Tested on 10.3-RELEASE i386 building head r308913.

Reopening due to dd/build toolchain issues.

Hi,

Thanks for you work, but I like more your previus patch :)
So I would like to fix the problem with that patch in a little different meaner basically install libcapsicum.
I will do that today, and replay your patch.

Thank you one more time!

imp requested changes to this revision.Nov 21 2016, 7:36 PM
imp added a reviewer: imp.

I think we should have a fake libcapiscim that's all defeined as no-op success functions and add that to libegacy. We don't need to install the full libcapsicim and there's ordering issues trying to do so.

However, we don't need it for dd. I have patches in the works that remove the need to make it a bootstrap tool. I'll post a review shortly.

So the X is for 'install libcapsicim' not for this patch as it is once I get the Makefile stuff sorted.

This revision now requires changes to proceed.Nov 21 2016, 7:36 PM

As I see libcapsicum is header only https://svnweb.freebsd.org/base/head/lib/libcapsicum/Makefile?revision=306726&view=markup.
The breakage was obviously caused by lack of that header in installed system older than 12-C.

So either we 1) install that lib / header 2) remove dd from bootstrap 3) use the current patch (I agree that this is the less favourable option).

I'll leave it up to you guys to decide :-)

Since dd was removed from bootstrap in 309412, can this be recommitted?

In D8543#180755, @pawel.biernacki-gmail.com wrote:

Since dd was removed from bootstrap in 309412, can this be recommitted?

If you can bootstrap with an old dd binary, sure. Since we no longer build dd as a bootstrap tool, I anticipate that there will be smooth sailing. But test from 10.3R and 11.0R on amd64 just to make sure, along with at least one universe.

That's rather the whole reason I did this. :)

imp edited edge metadata.

Should have ticked 'accept'

This revision is now accepted and ready to land.Dec 6 2016, 10:24 PM
kaktus edited edge metadata.

Update diff with one that survived building head@r309672:

  1. buildword && buildkernel on FreeBSD 10.3-R i386
  2. universe on FreeBSD 11.0-R amd64
This revision now requires review to proceed.Dec 7 2016, 10:52 PM

Guys, are we happy with the state of things? I am keen to commit it, given relevant approval is provided.

oshogbo edited edge metadata.
This revision is now accepted and ready to land.Dec 9 2016, 2:24 PM
This revision was automatically updated to reflect the committed changes.
kaktus added a reviewer: ngie.

Fix regression when stdin/out/err fds are are overridden by shell.
Found by Kyua tests.

bin/dd/dd_test:io -> passed [0.038s]
bin/dd/dd_test:length -> passed [0.022s]
bin/dd/dd_test:seek -> passed [0.060s]

@ngie Thoughts? I'd like to commit this and move on to other things, so review/approval is highly appreciated.

ngie accepted this revision.
ngie edited edge metadata.

The changes proposed seem ok, in so long as it addresses the regression I reported on svn-src-all@.

This revision is now accepted and ready to land.Dec 12 2016, 9:18 AM
This revision was automatically updated to reflect the committed changes.