Announcement

Collapse
No announcement yet.

Kernel Memory Sanitizer Lands For Linux 6.1

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Kernel Memory Sanitizer Lands For Linux 6.1

    Phoronix: Kernel Memory Sanitizer Lands For Linux 6.1

    In addition to Linux 6.1 x86_64 defaulting to warning over W+X mappings and other security-minded improvements this merge window, another benefit of this next kernel is the mainlining of the Kernel Memory Sanitizer (KMSAN)...

    Phoronix, Linux Hardware Reviews, Linux hardware benchmarks, Linux server benchmarks, Linux benchmarking, Desktop Linux, Linux performance, Open Source graphics, Linux How To, Ubuntu benchmarks, Ubuntu hardware, Phoronix Test Suite

  • #2
    Is "unititialized variable" another class of issue that "doesn't exist in Rust" (eg: Rust compilers mandate assigning initial value when declaring variables) or is this one that happens there too?

    ps: I don't use Rust, so I don't know any details about it from my own experience, and the example is hypotetical. There is just so much talk about programing issues it might avoid that it got me curious
    Last edited by marlock; 12 October 2022, 05:20 PM. Reason: added a "ps"

    Comment


    • #3
      Originally posted by marlock View Post
      Is "unititialized variable" another class of issue that "doesn't exist in Rust" (eg: Rust compilers mandate assigning initial value when declaring variables) or is this one that happens there too?

      ps: I don't use Rust, so I don't know any details about it from my own experience, and the example is hypotetical. There is just so much talk about programing issues it might avoid that it got me curious
      In safe rust, every variable has to be initialized.

      You can use MaybeUninit::uninit() to obtain `MaybeUninit<T>` or `MaybeUninit<[T; N]>`, which contains uninitialized variable but cannot be read from.
      In order to actually read from them or convert them to a `T` or `[T; N]`, you would need unsafe as there is no guarantee that you correctly initialized these variables.

      Comment


      • #4
        Is there any valid usecase for not initializing a variable before using it?

        Comment


        • #5
          Originally posted by marlock View Post
          Is there any valid usecase for not initializing a variable before using it?
          Yes, reading from disk into a large buffer or for cases where you know the entire buffer is going to be overwritten before used.

          Comment


          • #6
            Originally posted by marlock View Post
            Is there any valid usecase for not initializing a variable before using it?
            Are we talking about C? Because, in C, there are definitely cases where you define a variable before you can initialize it to something meaningful.

            Depending how far out of your way you are prepared to go, you can work around most of those cases by defining single-use functions that exist solely for the purpose of initializing it. In C++, we can use lambdas for that. For the rest of the cases, you need to transform your code and make extensive use of techniques like tail-recursion.

            I think good compilers can typically transform such code into the linear equivalent, but it's not guaranteed and it doesn't always benefit readability or maintainability of the code.

            Therefore, I try to initialize variables to something meaningful, but I don't go too far out of my way to avoid uninitialized variables when I think it's not worth the trouble. Compilers are pretty good at catching use of uninitialized variables at compile time, but it's computationally impractical for them to do a perfect job of it.

            Comment

            Working...
            X