Coder Social home page Coder Social logo

Comments (5)

markus-metzger avatar markus-metzger commented on June 11, 2024

The uint8_t value is implicitly converted to size_t before performing the relational operation (on size_t). See §6.5.8 and §6.3.1.8 of C11.

from libipt.

dandurisrihari avatar dandurisrihari commented on June 11, 2024

Thank you for the response,

This implicit conversion prevents an overflow in the comparison part of the loop. The value of n is promoted to a larger type (size_t), and then the comparison is made. This means that as long as n is within the range of uint8_t, it will be correctly compared against the value returned by pt_filter_addr_ncfg().

The incrementing of n (++n) still occurs within the bounds of uint8_t. If n reaches 255 and is incremented, it will overflow to 0

Could you test by returning a higher dummy value from pt_filter_addr_ncfg

from libipt.

markus-metzger avatar markus-metzger commented on June 11, 2024

There are only 4 filter configurations defined by the architecture and we reserve 4 more in the config structure.

If pt_filter_addr_ncfg() returned a big value, the loop would run indefinitely and pt_filter_addr_a/b() would allow accessing the filter configuration object out of bounds. It wouldn't even need to exceed the values supported by uint8_t to cause the latter.

from libipt.

dandurisrihari avatar dandurisrihari commented on June 11, 2024

Thanks. This should be fixed, right?

from libipt.

markus-metzger avatar markus-metzger commented on June 11, 2024

I see nothing that would need fixing. If pt_filter_addr_ncfg() returned a wrong value, there would be bugs. But it doesn't return a wrong value and it couldn't be tricked into returning a wrong value for some bogus or malicious user input.

The returned type could be narrowed or the argument type of the filter index argument of pt_filter_addr_a/b/cfg() could be widened, but none of that changes the fact that only values that index a filter in struct pt_conf_addr_filter are allowed.

from libipt.

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.