From patchwork Fri Jul 3 10:07:08 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 91646 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2F8EC43458 for ; Fri, 3 Jul 2026 10:07:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.89119.1783073235802959216 for ; Fri, 03 Jul 2026 03:07:16 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@arm.com header.s=foss header.b=CFik/EX5; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AEB2B22D7 for ; Fri, 3 Jul 2026 03:07:10 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B15D33F905 for ; Fri, 3 Jul 2026 03:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783073235; bh=Unn4jZGJeLb+0r1txSsJKjx3Q7llXAzKYZNnVToLtPg=; h=From:To:Subject:Date:From; b=CFik/EX5LyOwaXlH9sDZZFrZ6/y/q24igyOfkD7TR6Xmd6TWTtBzzninkR2o7/XQf sXdJkhOc/bNuClyEppxT3/ik4PX1iabbVg3BsllzWQNQQq9pAH83xBoWwur2JH4pFu IGVLBPlAD+BureJ98hgwAdlWMdYNOk7sNET7XFNk= From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH v2 1/3] classes/insane: create one CachedPath instance in qa_check_staged Date: Fri, 3 Jul 2026 11:07:08 +0100 Message-ID: <20260703100710.2901608-1-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 03 Jul 2026 10:07:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/240103 There's no need to create a new CachedPath instance for every file that we want to scan, just create one at the beginning of the function. Signed-off-by: Ross Burton --- meta/classes-global/insane.bbclass | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass index a788817c89d..942b6e500d5 100644 --- a/meta/classes-global/insane.bbclass +++ b/meta/classes-global/insane.bbclass @@ -732,6 +732,10 @@ def qa_check_staged(path,d): workdir = os.path.join(tmpdir, "work") recipesysroot = d.getVar("RECIPE_SYSROOT") + # package_qa_check_shebang_size needs the global cpath to be already created + global cpath + cpath = oe.cachedpath.CachedPath() + if bb.data.inherits_class("native", d) or bb.data.inherits_class("cross", d): pkgconfigcheck = workdir else: @@ -775,10 +779,7 @@ def qa_check_staged(path,d): oe.qa.handle_error("pkgconfig", error_msg, d) if not skip_shebang_size: - global cpath - cpath = oe.cachedpath.CachedPath() package_qa_check_shebang_size(path, "", d, None) - cpath = None # Walk over all files in a directory and call func def package_qa_walk(checkfuncs, package, d): From patchwork Fri Jul 3 10:07:09 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 91645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C837FC44500 for ; Fri, 3 Jul 2026 10:07:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.89120.1783073236261703699 for ; Fri, 03 Jul 2026 03:07:16 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@arm.com header.s=foss header.b=NbLANrjl; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 685D52696 for ; Fri, 3 Jul 2026 03:07:11 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 620AD3F905 for ; Fri, 3 Jul 2026 03:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783073235; bh=93cwS9NiqmnrOQcK7YmFmXgk9+cTiBN0FmMqW+P4Puk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NbLANrjlwrzvqoOrbLoopegKt8vZ24Aa8gOnrEinhSnrgWWmlhXU5LsnNtD80Y9yF sK68HOks+fAnDqXKDp6OvhM66BHYOaOBGZfPyAriz3tpOZQhroS35zVG+RrLaDWCkI Is4WUldJ/5oT4nxfeQ5u93K6pa8xNvD04Bj3cG6o= From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH v2 2/3] classes/insane: clean up do_qa_sysroot Date: Fri, 3 Jul 2026 11:07:09 +0100 Message-ID: <20260703100710.2901608-2-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260703100710.2901608-1-ross.burton@arm.com> References: <20260703100710.2901608-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 03 Jul 2026 10:07:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/240104 do_populate_sysroot copies SYSROOT_DIRS into SYSROOT_DESTDIR, so there's no need to loop over SYSROOT_DIRS when checking files: qa_check_staged can just recurse down the entire tree. Signed-off-by: Ross Burton --- meta/classes-global/insane.bbclass | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass index 942b6e500d5..1818ce2168d 100644 --- a/meta/classes-global/insane.bbclass +++ b/meta/classes-global/insane.bbclass @@ -1225,9 +1225,7 @@ addtask do_package_qa_setscene python do_qa_sysroot() { bb.note("QA checking do_populate_sysroot") - sysroot_destdir = d.expand('${SYSROOT_DESTDIR}') - for sysroot_dir in d.expand('${SYSROOT_DIRS}').split(): - qa_check_staged(sysroot_destdir + sysroot_dir, d) + qa_check_staged(d.getVar("SYSROOT_DESTDIR"), d) oe.qa.exit_with_message_if_errors("do_populate_sysroot for this recipe installed files with QA issues", d) } do_populate_sysroot[postfuncs] += "do_qa_sysroot" From patchwork Fri Jul 3 10:07:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 91647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id EEEA9C43602 for ; Fri, 3 Jul 2026 10:07:25 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.msgproc02-g2.89958.1783073236807211727 for ; Fri, 03 Jul 2026 03:07:16 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="dkim: body hash did not verify" header.i=@arm.com header.s=foss header.b=TgjoMTyd; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A31A22D7 for ; Fri, 3 Jul 2026 03:07:12 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1CBCD3F905 for ; Fri, 3 Jul 2026 03:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1783073236; bh=VJcHMQ2VrkFwJnvLUwaWwioxVDLCSDo7JF1XmCsHm9U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TgjoMTyd++usz07y6/a5JR7gGie4SToOiKLlAs5l1F4SBhFHf7IajR9FYd/9Uld99 WSW9eAvAmEJ/9tYwkeBs/P665BZmSWxACv160Len2mmcbryJYYTVpPhjKvxS7RLGbE 1UOVpp0n6QqQgpSC5ipikFdvq0Gvcu1i5iBpRCuQ= From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH v2 3/3] classes/insane: increase shebang size limit Date: Fri, 3 Jul 2026 11:07:10 +0100 Message-ID: <20260703100710.2901608-3-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260703100710.2901608-1-ross.burton@arm.com> References: <20260703100710.2901608-1-ross.burton@arm.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Fri, 03 Jul 2026 10:07:25 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/240105 Since Linux 5.1 the shebang buffer has been 256 bytes[1], so update the check to match. Also rewrite the test, create a variable for the magic number (that has the same name as the kernel #define), read double that so we either have a full line, or definitely are over the buffer, don't pointlessly try to decode the bytes as UTF-8, and consolidate the test logic to entirely inside the try block. Also update the tests: sysroot-shebang-test needs updating to write a longer shebang, and generalise the test case so that the string being searched for isn't so specific. [1] linux 6eb3c3d0a52dc ("exec: increase BINPRM_BUF_SIZE to 256") Signed-off-by: Ross Burton --- .../sysroot-test/sysroot-shebang-test_1.0.bb | 4 ++-- meta/classes-global/insane.bbclass | 23 ++++++++----------- meta/lib/oeqa/selftest/cases/sysroot.py | 3 +-- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/meta-selftest/recipes-test/sysroot-test/sysroot-shebang-test_1.0.bb b/meta-selftest/recipes-test/sysroot-test/sysroot-shebang-test_1.0.bb index 6c834be8976..106ddd54262 100644 --- a/meta-selftest/recipes-test/sysroot-test/sysroot-shebang-test_1.0.bb +++ b/meta-selftest/recipes-test/sysroot-test/sysroot-shebang-test_1.0.bb @@ -1,11 +1,11 @@ -SUMMARY = "Check that shebang does not exceed 128 characters" +SUMMARY = "Check that shebang does not exceed 256 characters" LICENSE = "CLOSED" INHIBIT_DEFAULT_DEPS = "1" EXCLUDE_FROM_WORLD = "1" do_install() { install -d ${D}${bindir} - echo '#!BiM3cnVd1Amtv6PG+FynrQiVMbZnX5ELgF21q3EkuB+44JEGWtq8TvBJ7EGidfVs3eR3wVOUbLnjYDlKUWcm7YC/ute7f+KDHbwxziRUSUBZAUqgjiQdfQ0HnxajI0ozbM863E9JV9k13yZKYfh9/zR77Y6Dl4Dd3zOWS75LSpkAXV' > ${D}${bindir}/max-shebang + echo '#!4Shfcy9Ej8gPKDGNkyhmtxrwPinmpZQ1pCS3snbdqlNx7YfmTpHkeJakCMaDnQXx4c4TmtyJpGBn5F7IO1FShYG9EwtALDOsRKEDOJKRj2L7hW92wZTzlqx4mMqREqNa7Hrwql4DYVv8vmEMhIwvtHO3UaVpgvLY9Y3HhfopUVUMZJi5Xs9KKkRisrM0HBePG67tbeWL9ZstNuPKH1ikyeNB7PprwLrsjZ6EngCrhFTfYzRSuXhdrQQBBsLZBRDsy5QE' > ${D}${bindir}/max-shebang chmod 755 ${D}${bindir}/max-shebang } diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass index 1818ce2168d..c1d8b165866 100644 --- a/meta/classes-global/insane.bbclass +++ b/meta/classes-global/insane.bbclass @@ -83,25 +83,22 @@ QAPATHTEST[shebang-size] = "package_qa_check_shebang_size" def package_qa_check_shebang_size(path, name, d, elf): global cpath + # From kernel 5.1 onwards (specifically linux 6eb3c3d0a52dc ("exec: increase + # BINPRM_BUF_SIZE to 256")) the shebang buffer was increased from 128 bytes + # to 256 bytes. + BINPRM_BUF_SIZE = 256 + if elf or cpath.islink(path) or not cpath.isfile(path): return try: with open(path, 'rb') as f: - stanza = f.readline(130) + stanza = f.readline(BINPRM_BUF_SIZE * 2) + if stanza.startswith(b'#!') and len(stanza) > BINPRM_BUF_SIZE: + oe.qa.handle_error("shebang-size", "%s: %s maximum shebang size exceeded, the maximum size is %d" % (name, package_qa_clean_path(path, d, name), BINPRM_BUF_SIZE), d) + return except IOError: - return - - if stanza.startswith(b'#!'): - try: - stanza.decode("utf-8") - except UnicodeDecodeError: - #If it is not a text file, it is not a script - return - - if len(stanza) > 129: - oe.qa.handle_error("shebang-size", "%s: %s maximum shebang size exceeded, the maximum size is 128." % (name, package_qa_clean_path(path, d, name)), d) - return + pass QAPATHTEST[libexec] = "package_qa_check_libexec" def package_qa_check_libexec(path,name, d, elf): diff --git a/meta/lib/oeqa/selftest/cases/sysroot.py b/meta/lib/oeqa/selftest/cases/sysroot.py index ef854f6feeb..bdf7ad35a53 100644 --- a/meta/lib/oeqa/selftest/cases/sysroot.py +++ b/meta/lib/oeqa/selftest/cases/sysroot.py @@ -44,9 +44,8 @@ TESTSTRING:pn-sysroot-test-arch2 = "%s" Expected: Fail when a shebang bigger than the max shebang-size is reached. Author: Paulo Neves """ - expected = "maximum shebang size exceeded, the maximum size is 128. [shebang-size]" res = bitbake("sysroot-shebang-test-native -c populate_sysroot", ignore_status=True) - self.assertTrue(expected in res.output, msg=res.output) + self.assertTrue("[shebang-size]" in res.output, msg=res.output) self.assertTrue(res.status != 0) def test_sysroot_la(self):