Announcement

Collapse
No announcement yet.

Whoops: Linux's strcmp() For The m68k Has Always Been Broken

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

  • Whoops: Linux's strcmp() For The m68k Has Always Been Broken

    Phoronix: Whoops: Linux's strcmp() For The m68k Has Always Been Broken

    It turns out the hand-written Assembly code providing an optimized string comparison "strcmp" function for the Motorola 68000 (m68k) processor architecture has "always been broken" and only now uncovered at the end of 2022...

    https://www.phoronix.com/news/Linux-...-Always-Broken

  • #2
    It's a good thing I don't run Linux in my calculator then... Or in my car ECU... Or the Space Shuttle for that matter.

    Comment


    • #3
      How?! We thought nobody would ever find out! Why now?!

      Comment


      • #4
        Yay less handcruft asm.

        Comment


        • #5
          Does that counts as scream test?

          Comment


          • #6
            long life to asm!!!

            Comment


            • #7
              I believe this is it in 6.1:

              grep -A 15 strcmp linux-6.1/arch/m68k/include/asm/string.h
              static inline int strcmp(const char *cs, const char *ct)
              {
              char res;

              asm ("\n"
              "1: move.b (%0)+,%2\n" /* get *cs */
              " cmp.b (%1)+,%2\n" /* compare a byte */
              " jne 2f\n" /* not equal, break out */
              " tst.b %2\n" /* at end of cs? */
              " jne 1b\n" /* no, keep going */
              " jra 3f\n" /* strings are equal */
              "2: sub.b -(%1),%2\n" /* *cs - *ct */
              "3:"
              : "+a" (cs), "+a" (ct), "=d" (res));
              return res;
              }

              ‚Äč

              Comment


              • #8
                Originally posted by Brisse View Post
                Or the Space Shuttle for that matter.
                You are safe if you can arrange to restore and launch a Space Shuttle. The Space Shuttle main processor (AP-101) used an IBM S/360 derived instruction set (you could test user mode programs on mainframes of the era).

                Comment


                • #9
                  More than the bug itself, I wonder how Linus spotted this...

                  Comment


                  • #10
                    Who runs m68k on a modern kernel?

                    Comment

                    Working...
                    X