GithubHelp home page GithubHelp logo

Comments (7)

snarkmaster avatar snarkmaster commented on June 8, 2024

Note that this is a bug that may not be obvious to users because both of the capng_apply calls return 0.

from libcap-ng.

snarkmaster avatar snarkmaster commented on June 8, 2024

Unrelatedly, this code here seems to skip the CapAmb: line that the sscanf would attempt to parse?

if (strncmp(buf, "CapA", 4))

I.e. I'm not sure whether this get_ambient_set works correctly either.

from libcap-ng.

stevegrubb avatar stevegrubb commented on June 8, 2024

Strange. In my testing I was using capng_print_caps_numeric() which hides what the system really thinks. Fixed now.
About the sscanf code, if strcmp() == 1, then we want to read the next line. Its only when its 0 that we want to read it.

from libcap-ng.

snarkmaster avatar snarkmaster commented on June 8, 2024

Thanks for putting up a fix! I'll test perhaps Monday.

testing using the internal state of capng

That's actually also the topic of my next bug report.

You'll notice that in my repro program I cross-check the result of capng_apply against procfs. I think it would be good if libcap-ng did that internally, feel free to use my proc-parsing code -- I can put up a cleaned-up version (it'll be on github soon, but you can have it even sooner :)

strncmp

So strncmp will return 0 if the two strings are equal, which means that you will continue; instead of going on to do sscanf. Am I reading this wrong?

This would also be improved if you adopt my procfs parser.

from libcap-ng.

stevegrubb avatar stevegrubb commented on June 8, 2024

So strncmp will return 0 if the two strings are equal, which means that you will continue; instead of going on to do sscanf.
If strncmp returns a 0, strings match and the "if" fails so we run sscanf. If they mismatch, the "if" is true and we take the continue.

from libcap-ng.

snarkmaster avatar snarkmaster commented on June 8, 2024

Sorry, you're right about the strncmp control flow, and I was having a brain glitch. My apologies for taking up your time with this.

from libcap-ng.

snarkmaster avatar snarkmaster commented on June 8, 2024

I can confirm that b6ff250 fixes the reported issue. However, as per my comment on the subsequent commit 6a24a9c, that one breaks the mitigation that one would need to use before the fix.

I.e. right now I just literally do capng_apply(CAPNG_SELECT_ALL); twice in a row.

After 6a24a9c, the second capng_apply fails, which to me seems weird.

I guess I could handle the new world by not checking errors on the second capng_apply, but that feels dirty, and besides, the semantics of "a no-op apply succeeds" seems more right than a "no-op apply fails". I thought the philosophy of libcap-ng was to free the end user from managing caps state. Avoiding the "no-op" error requires actively checking whether or not you're making a change before you call capng_apply, which IMO makes the API harder to use.

from libcap-ng.

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.