You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by Jojy Varghese <jo...@mesosphere.io> on 2016/04/19 19:02:40 UTC

Review Request 46370: Introduced linux capabilities API.

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/
-----------------------------------------------------------

Review request for mesos, Jie Yu and Kevin Klues.


Bugs: MESOS-5051
    https://issues.apache.org/jira/browse/MESOS-5051


Repository: mesos


Description
-------

This change introduces basic API for linux capabilities. This is not a
comprehensive API but is strictly limited to the need for securing Mesos
containers using linux capabilities.


Diffs
-----

  src/CMakeLists.txt ca59a1824352423f4db6ef8bb41acc6fe602c041 
  src/Makefile.am a8f68316c5d4d4c82d99363535a97fa5b1caafc5 
  src/linux/capabilities.hpp PRE-CREATION 
  src/linux/capabilities.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/46370/diff/


Testing
-------

make check.


Thanks,

Jojy Varghese


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/
-----------------------------------------------------------

(Updated April 28, 2016, 9:44 p.m.)


Review request for mesos, Jie Yu and Kevin Klues.


Bugs: MESOS-5051
    https://issues.apache.org/jira/browse/MESOS-5051


Repository: mesos


Description
-------

This change introduces basic API for linux capabilities. This is not a
comprehensive API but is strictly limited to the need for securing Mesos
containers using linux capabilities.


Diffs (updated)
-----

  src/CMakeLists.txt f991743f1a467f24a786e925983390a411792327 
  src/Makefile.am 53de98f43629dc94f7619324369caf88407b2f41 
  src/linux/capabilities.hpp PRE-CREATION 
  src/linux/capabilities.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/46370/diff/


Testing
-------

make check.


Thanks,

Jojy Varghese


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/
-----------------------------------------------------------

(Updated April 26, 2016, 1:23 a.m.)


Review request for mesos, Jie Yu and Kevin Klues.


Bugs: MESOS-5051
    https://issues.apache.org/jira/browse/MESOS-5051


Repository: mesos


Description
-------

This change introduces basic API for linux capabilities. This is not a
comprehensive API but is strictly limited to the need for securing Mesos
containers using linux capabilities.


Diffs (updated)
-----

  src/CMakeLists.txt 8e3eecb172e6c6b5256313f0937dc19999156e91 
  src/Makefile.am 08d5279bbc0c763255fda3c3360d8f24f41bccda 
  src/linux/capabilities.hpp PRE-CREATION 
  src/linux/capabilities.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/46370/diff/


Testing
-------

make check.


Thanks,

Jojy Varghese


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/
-----------------------------------------------------------

(Updated April 20, 2016, 8:19 p.m.)


Review request for mesos, Jie Yu and Kevin Klues.


Bugs: MESOS-5051
    https://issues.apache.org/jira/browse/MESOS-5051


Repository: mesos


Description
-------

This change introduces basic API for linux capabilities. This is not a
comprehensive API but is strictly limited to the need for securing Mesos
containers using linux capabilities.


Diffs (updated)
-----

  src/CMakeLists.txt 8e3eecb172e6c6b5256313f0937dc19999156e91 
  src/Makefile.am 08d5279bbc0c763255fda3c3360d8f24f41bccda 
  src/linux/capabilities.hpp PRE-CREATION 
  src/linux/capabilities.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/46370/diff/


Testing
-------

make check.


Thanks,

Jojy Varghese


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/
-----------------------------------------------------------

(Updated April 20, 2016, 7:05 p.m.)


Review request for mesos, Jie Yu and Kevin Klues.


Bugs: MESOS-5051
    https://issues.apache.org/jira/browse/MESOS-5051


Repository: mesos


Description
-------

This change introduces basic API for linux capabilities. This is not a
comprehensive API but is strictly limited to the need for securing Mesos
containers using linux capabilities.


Diffs (updated)
-----

  src/CMakeLists.txt 8e3eecb172e6c6b5256313f0937dc19999156e91 
  src/Makefile.am 08d5279bbc0c763255fda3c3360d8f24f41bccda 
  src/linux/capabilities.hpp PRE-CREATION 
  src/linux/capabilities.cpp PRE-CREATION 

Diff: https://reviews.apache.org/r/46370/diff/


Testing
-------

make check.


Thanks,

Jojy Varghese


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.

> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.hpp, lines 94-99
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350684#file1350684line94>
> >
> >     From my reading of: http://man7.org/linux/man-pages/man7/capabilities.7.html
> >     
> >     this enum should probably be called `Set`.
> >     
> >     Note, the name `Capability` at the front is unnecessary if we embed this in the `capabilities` namespace.
> >     
> >     Also, it's pretty standard practice in C++ to define an `enum` as a `enum class` for better type checking.  As such, you can define the final element with a common name of `COUNT` to get at the size of the enum.
> >     
> >     For example, you can get at the size of the enum as: `capabilities::Set::COUNT` instead of relying on the `const` for `NUMBER_OF_CAP_SETS` defined above.
> 
> Jojy Varghese wrote:
>     Although i agree that C++11 supports enum classes, couple of reasons for using plain enum here:
>     1. Other places in the code mostly use plain old enums.
>     2. Its hard(not impossible) to get the value of the enum class's element (say for printing).

regarding naming, If you look at the code of libcap (a standard portable capability interface) (https://github.com/abstrakraft/lxc-android-libcap/blob/master/libcap/libcap.h), the name `set` is referenced for the value and not the type. In fact the `SystemCallPayload` structure in my code is same from libcap.


- Jojy


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/#review129674
-----------------------------------------------------------


On April 19, 2016, 5:02 p.m., Jojy Varghese wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46370/
> -----------------------------------------------------------
> 
> (Updated April 19, 2016, 5:02 p.m.)
> 
> 
> Review request for mesos, Jie Yu and Kevin Klues.
> 
> 
> Bugs: MESOS-5051
>     https://issues.apache.org/jira/browse/MESOS-5051
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This change introduces basic API for linux capabilities. This is not a
> comprehensive API but is strictly limited to the need for securing Mesos
> containers using linux capabilities.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt ca59a1824352423f4db6ef8bb41acc6fe602c041 
>   src/Makefile.am a8f68316c5d4d4c82d99363535a97fa5b1caafc5 
>   src/linux/capabilities.hpp PRE-CREATION 
>   src/linux/capabilities.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46370/diff/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jojy Varghese
> 
>


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.

> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.cpp, lines 124-125
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350685#file1350685line124>
> >
> >     This should be unnecessary. See: https://github.com/klueska-mesosphere/mesos/blob/master/src/linux/cgroups.cpp#L2435

Not sure about this as  I like to lean towards good programming practice than depending on compiler flags.


- Jojy


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/#review129674
-----------------------------------------------------------


On April 20, 2016, 8:19 p.m., Jojy Varghese wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46370/
> -----------------------------------------------------------
> 
> (Updated April 20, 2016, 8:19 p.m.)
> 
> 
> Review request for mesos, Jie Yu and Kevin Klues.
> 
> 
> Bugs: MESOS-5051
>     https://issues.apache.org/jira/browse/MESOS-5051
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This change introduces basic API for linux capabilities. This is not a
> comprehensive API but is strictly limited to the need for securing Mesos
> containers using linux capabilities.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 8e3eecb172e6c6b5256313f0937dc19999156e91 
>   src/Makefile.am 08d5279bbc0c763255fda3c3360d8f24f41bccda 
>   src/linux/capabilities.hpp PRE-CREATION 
>   src/linux/capabilities.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46370/diff/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jojy Varghese
> 
>


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.

> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.hpp, lines 32-33
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350684#file1350684line32>
> >
> >     This should all probably live in the mesos::internal::capabilities namespace.

The reasons why I chose to have it in mesos::internal is that we have Capabilities class (explained in the class's documentation why we need a class).


> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.hpp, lines 94-99
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350684#file1350684line94>
> >
> >     From my reading of: http://man7.org/linux/man-pages/man7/capabilities.7.html
> >     
> >     this enum should probably be called `Set`.
> >     
> >     Note, the name `Capability` at the front is unnecessary if we embed this in the `capabilities` namespace.
> >     
> >     Also, it's pretty standard practice in C++ to define an `enum` as a `enum class` for better type checking.  As such, you can define the final element with a common name of `COUNT` to get at the size of the enum.
> >     
> >     For example, you can get at the size of the enum as: `capabilities::Set::COUNT` instead of relying on the `const` for `NUMBER_OF_CAP_SETS` defined above.

Although i agree that C++11 supports enum classes, couple of reasons for using plain enum here:
1. Other places in the code mostly use plain old enums.
2. Its hard(not impossible) to get the value of the enum class's element (say for printing).


> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.hpp, line 178
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350684#file1350684line178>
> >
> >     Didn't we discuss not making this a class, and only having get()/set() calls as part of the namespace?

Explained in the class's documentation.


> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.hpp, line 209
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350684#file1350684line209>
> >
> >     What did we decide about the `add()` pairing to this `drop()` call?

As mentioned in the documentation of `drop`, the `drop` API is for dropping `bounding` capabilities.


> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.cpp, lines 36-38
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350685#file1350685line36>
> >
> >     Is there not a header file you can just include here?

No the standard header files dont provide the syscall declaration.


> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > src/linux/capabilities.hpp, lines 50-90
> > <https://reviews.apache.org/r/46370/diff/1/?file=1350684#file1350684line50>
> >
> >     Since we should probably be embedding this in a `capabilities` namespace, it is redundant to call this enum `Capability`. I'd sugggest `Privilege`.  That way one of these can be accessed as e.g. `capabiliites::Privilege::SETGID`.
> >     
> >     Also, as mentioned in a comment below, this should probably be declared as an `enum class` for better type checking.
> >     
> >     The `COUNT` trick mentioned below should probably be applied here as well.

I like Capability because that is what its referenced as in every documentation and literature.


- Jojy


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/#review129674
-----------------------------------------------------------


On April 19, 2016, 5:02 p.m., Jojy Varghese wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46370/
> -----------------------------------------------------------
> 
> (Updated April 19, 2016, 5:02 p.m.)
> 
> 
> Review request for mesos, Jie Yu and Kevin Klues.
> 
> 
> Bugs: MESOS-5051
>     https://issues.apache.org/jira/browse/MESOS-5051
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This change introduces basic API for linux capabilities. This is not a
> comprehensive API but is strictly limited to the need for securing Mesos
> containers using linux capabilities.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt ca59a1824352423f4db6ef8bb41acc6fe602c041 
>   src/Makefile.am a8f68316c5d4d4c82d99363535a97fa5b1caafc5 
>   src/linux/capabilities.hpp PRE-CREATION 
>   src/linux/capabilities.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46370/diff/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jojy Varghese
> 
>


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Jojy Varghese <jo...@mesosphere.io>.

> On April 20, 2016, 3:15 a.m., Kevin Klues wrote:
> > I added a few comments below, but in general, I feel like there are places this code could be greatly simplified.  Specifically, it's not obvious to me why we need all of the different classes you define (or maybe more about why they need to be part of the public interface).  Could you clarify the rational here a bit?

Classes like `CapabilityFlags` allows good encapsulation of the bitmap and makes the API more fiendly to deal with. Leaving them as bitmap would leave the complexity to the caller.

Same idea with other classes.


- Jojy


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/#review129674
-----------------------------------------------------------


On April 20, 2016, 8:19 p.m., Jojy Varghese wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46370/
> -----------------------------------------------------------
> 
> (Updated April 20, 2016, 8:19 p.m.)
> 
> 
> Review request for mesos, Jie Yu and Kevin Klues.
> 
> 
> Bugs: MESOS-5051
>     https://issues.apache.org/jira/browse/MESOS-5051
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This change introduces basic API for linux capabilities. This is not a
> comprehensive API but is strictly limited to the need for securing Mesos
> containers using linux capabilities.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt 8e3eecb172e6c6b5256313f0937dc19999156e91 
>   src/Makefile.am 08d5279bbc0c763255fda3c3360d8f24f41bccda 
>   src/linux/capabilities.hpp PRE-CREATION 
>   src/linux/capabilities.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46370/diff/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jojy Varghese
> 
>


Re: Review Request 46370: Introduced linux capabilities API.

Posted by Kevin Klues <kl...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/46370/#review129674
-----------------------------------------------------------



I added a few comments below, but in general, I feel like there are places this code could be greatly simplified.  Specifically, it's not obvious to me why we need all of the different classes you define (or maybe more about why they need to be part of the public interface).  Could you clarify the rational here a bit?


src/linux/capabilities.hpp (line 30)
<https://reviews.apache.org/r/46370/#comment193174>

    Is this file #including itself? Does this compile?



src/linux/capabilities.hpp (lines 32 - 33)
<https://reviews.apache.org/r/46370/#comment193176>

    This should all probably live in the mesos::internal::capabilities namespace.



src/linux/capabilities.hpp (lines 39 - 45)
<https://reviews.apache.org/r/46370/#comment193178>

    These are both probably unnecessary (see comments below).



src/linux/capabilities.hpp (lines 50 - 90)
<https://reviews.apache.org/r/46370/#comment193180>

    Since we should probably be embedding this in a `capabilities` namespace, it is redundant to call this enum `Capability`. I'd sugggest `Privilege`.  That way one of these can be accessed as e.g. `capabiliites::Privilege::SETGID`.
    
    Also, as mentioned in a comment below, this should probably be declared as an `enum class` for better type checking.
    
    The `COUNT` trick mentioned below should probably be applied here as well.



src/linux/capabilities.hpp (lines 94 - 99)
<https://reviews.apache.org/r/46370/#comment193179>

    From my reading of: http://man7.org/linux/man-pages/man7/capabilities.7.html
    
    this enum should probably be called `Set`.
    
    Note, the name `Capability` at the front is unnecessary if we embed this in the `capabilities` namespace.
    
    Also, it's pretty standard practice in C++ to define an `enum` as a `enum class` for better type checking.  As such, you can define the final element with a common name of `COUNT` to get at the size of the enum.
    
    For example, you can get at the size of the enum as: `capabilities::Set::COUNT` instead of relying on the `const` for `NUMBER_OF_CAP_SETS` defined above.



src/linux/capabilities.hpp (line 178)
<https://reviews.apache.org/r/46370/#comment193181>

    Didn't we discuss not making this a class, and only having get()/set() calls as part of the namespace?



src/linux/capabilities.hpp (line 209)
<https://reviews.apache.org/r/46370/#comment193182>

    What did we decide about the `add()` pairing to this `drop()` call?



src/linux/capabilities.cpp (lines 36 - 38)
<https://reviews.apache.org/r/46370/#comment193171>

    Is there not a header file you can just include here?



src/linux/capabilities.cpp (lines 124 - 125)
<https://reviews.apache.org/r/46370/#comment193183>

    This should be unnecessary. See: https://github.com/klueska-mesosphere/mesos/blob/master/src/linux/cgroups.cpp#L2435


- Kevin Klues


On April 19, 2016, 5:02 p.m., Jojy Varghese wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/46370/
> -----------------------------------------------------------
> 
> (Updated April 19, 2016, 5:02 p.m.)
> 
> 
> Review request for mesos, Jie Yu and Kevin Klues.
> 
> 
> Bugs: MESOS-5051
>     https://issues.apache.org/jira/browse/MESOS-5051
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> This change introduces basic API for linux capabilities. This is not a
> comprehensive API but is strictly limited to the need for securing Mesos
> containers using linux capabilities.
> 
> 
> Diffs
> -----
> 
>   src/CMakeLists.txt ca59a1824352423f4db6ef8bb41acc6fe602c041 
>   src/Makefile.am a8f68316c5d4d4c82d99363535a97fa5b1caafc5 
>   src/linux/capabilities.hpp PRE-CREATION 
>   src/linux/capabilities.cpp PRE-CREATION 
> 
> Diff: https://reviews.apache.org/r/46370/diff/
> 
> 
> Testing
> -------
> 
> make check.
> 
> 
> Thanks,
> 
> Jojy Varghese
> 
>