lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20210310114053.GA9028@amd>
Date:   Wed, 10 Mar 2021 12:40:54 +0100
From:   Pavel Machek <pavel@....cz>
To:     jikos@...nel.org, Linus Torvalds <torvalds@...ux-foundation.org>,
        oneukum@...e.com, kernel list <linux-kernel@...r.kernel.org>
Subject: Re: 5.12-rc1-dontuse: Detecting known-bad commits to prevent bisect
 disasters

Hi!

I forgot to Cc lkml... Fixing that now.

Best regards,
							Pavel

> Would there be interest in a tool to detect known-bad commits
> automatically?
> 
> Something like this?
> 
> ".known-bad" file would have to be copied out of git at begining of
> the bisection...
> 
> And no, I don't have right commits in the example file, I'd have to
> search for the right commits.
> 
> Best regards,
> 							Pavel
> 
> commit 75ad04e3fdf1d32a24e4203b628093560a2d7ac6
> Author: Pavel Machek <pavel@....cz>
> Date:   Wed Mar 10 12:05:42 2021 +0100
> 
>     Add tool for detecting known-bad commits.
> 
> diff --git a/.known-bad b/.known-bad
> new file mode 100644
> index 000000000000..e86d6ffb260f
> --- /dev/null
> +++ b/.known-bad
> @@ -0,0 +1,4 @@
> +* 5.12-rc1 corrupts filesystems data using swap files
> +Bad: 3650b228f83adda7e5ee532e2b90429c03f7bafd
> +Fix: 3cea11cd5e3b00d91caf0b4730194039b45c5adf
> +
> diff --git a/tools/known-bad b/tools/known-bad
> new file mode 100755
> index 000000000000..36ef4f7033f4
> --- /dev/null
> +++ b/tools/known-bad
> @@ -0,0 +1,81 @@
> +#!/usr/bin/python3
> +import os
> +import sys
> +
> +def pcmd(c):
> +    return os.popen(c).readline()[:-1]
> +
> +def is_ancestor(this, anc):
> +    c1 = pcmd("git rev-parse %s" % this)
> +    c2 = pcmd("git rev-parse %s" % anc)
> +    if c1 == c2:
> +        return True
> +    r = os.system("git merge-base --is-ancestor %s %s" % (this, anc))
> +    if r == 0:
> +        return False
> +    if r == 256:
> +        return True
> +    print("Problem searching for ancestors:", r, this, anc)
> +    sys.exit(2)
> +
> +def known_bad(this, buggy, fix):
> +    if is_ancestor(this, fix):
> +        return False
> +    if is_ancestor(this, buggy):
> +        return True
> +    return False
> +
> +def test_suite():
> +    print("Anc false: ", is_ancestor("3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    print("Anc true: ", is_ancestor("3cea11cd5e3b00d91caf0b4730194039b45c5891", "3650b228f83adda7e5ee532e2b90429c03f7b9ec"))
> +    print("Anc same true: ", is_ancestor("3cea11cd5e3b00d91caf0b4730194039b45c5891", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    #print("Anc non false: ", is_ancestor("3cea11cd5e3b00d91caf0b4730194039b45c5891", "3cea11cd5e3b00d91caf0b4730194039b45c5892"))
> +    
> +    # HEAD, v5.10-rc1, v5.10-rc2
> +    print("Expect false: ", known_bad("HEAD", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    # v5.10, v5.10-rc1, v5.10-rc2
> +    print("Expect false: ", known_bad("2c85ebc57b3e1817b6ce1a6b703928e113a90442", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    # v5.10-rc1, v5.10-rc1, v5.10-rc2
> +    print("Expect true: ", known_bad("3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +    print("Expect true: ", known_bad("3cea11cd5e3b00d91caf0b4730194039b45c5891^", "3650b228f83adda7e5ee532e2b90429c03f7b9ec", "3cea11cd5e3b00d91caf0b4730194039b45c5891"))
> +
> +def check_fixed(title, this, bad, is_fixed):
> +    v = True
> +    if v: print("Problem %s... %s %s", (title, this, bad))
> +    if is_fixed:
> +        if v: print("...is fixed")
> +        return
> +    if not is_ancestor(this, bad):
> +        if v: print("...is not present")
> +        return
> +    print("Problem %s is present in current tree", title)
> +
> +def check_file(this, f):
> +    title = None
> +    is_fixed = False
> +    for l in open(f).readlines():
> +        if l[-1] == "\n":
> +            l = l[:-1]
> +        if l[:2] == "* ":
> +            if title:
> +                check_fixed(title, this, bad, is_fixed)
> +            title = l
> +            is_fixed = False
> +            continue
> +        if l[:5] == "Bad: ":
> +            bad = l[5:]
> +            continue
> +        if l[:5] == "Fix: ":
> +            print("This is a fix: ",l[5:])
> +            if not is_fixed:
> +                if is_ancestor(this, l[5:]):
> +                    is_fixed = True
> +            continue
> +        if l[:1] == "#":
> +            continue
> +        print("Unrecognized line ", l)
> +
> +    check_fixed(title, this, bad, is_fixed)
> +            
> +test_suite()
> +check_file("HEAD", ".known-bad")
> 
> 



-- 
http://www.livejournal.com/~pavelmachek

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ