Coder Social home page Coder Social logo

this might be a good opportunity to replace calls to avc_has_perm() with calls to selinux_access_check() in selinux.c about dbus-broker HOT 8 CLOSED

bus1 avatar bus1 commented on May 16, 2024
this might be a good opportunity to replace calls to avc_has_perm() with calls to selinux_access_check() in selinux.c

from dbus-broker.

Comments (8)

dvdhrm avatar dvdhrm commented on May 16, 2024

Thanks for the hint!

selinux_access_check() resolves the contexts on every call. avc_has_perm() allows us to cache the lookups by storing the sid pointers rather than the context-strings. Is this intentional?

from dbus-broker.

 avatar commented on May 16, 2024

from dbus-broker.

bigon avatar bigon commented on May 16, 2024

If you are caching the security contexts I guess you should at least invalidate the cache if the policy is reloaded, see selinux_set_callback(3) manpage (and SELINUX_CB_POLICYLOAD)

from dbus-broker.

teg avatar teg commented on May 16, 2024

@bigon could you expand a bit on that? This is my understanding, please correct me if I'm wrong:

  1. The security context of a peer (which is the SO_SECLABEL of its socket) is pinned in the file description at open() and stays fixed regardless of any change to security policy.
  2. The SID returned by avc_context_to_sid() is valid for the lifetime of the daemon (we only call avc_destroy() when shutting down the daemon).
  3. We need to listen for SELINUX_CB_POLICYLOAD to reload the security contexts of names, and then obviously get a new SID if the context changes (we currently do not do this).

Are you saying that we also need to re-resolve all SIDs when the policy changes? Could we get a different SID back, even if the context is guaranteed to be the same?

from dbus-broker.

bigon avatar bigon commented on May 16, 2024

@teg I'm far from being an expert here, but I think that security context can be invalidated (the label become unlabeled_t) when a module is disabled or a policy is updated. But the sid itself might still be valid.

For the original question from @doverride (avc_has_perm vs selinux_check_access) I guess this could be discussed on the SELinux from the NSA

from dbus-broker.

dvdhrm avatar dvdhrm commented on May 16, 2024

Lets just switch to selinux_check_access(). Makes the code simpler, and we follow the upstream recommendation.

If this ends up slowing down the message bus considerably, we will need an upstream solution, anyway. Relying on deprecated interfaces sounds not right.

from dbus-broker.

teg avatar teg commented on May 16, 2024

Yeah, I'm fine with that.

from dbus-broker.

dvdhrm avatar dvdhrm commented on May 16, 2024

Fixed!

Thanks for the report!

from dbus-broker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.