* [PATCH 1/3] classes/insane: increase shebang size limit
@ 2026-06-30 14:07 Ross Burton
2026-06-30 14:07 ` [PATCH 2/3] classes/insane: create one CachedPath instance in qa_check_staged Ross Burton
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Ross Burton @ 2026-06-30 14:07 UTC (permalink / raw)
To: openembedded-core
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), don't pointlessly try to decode
the bytes as UTF-8, and consolidate the test logic to entirely inside
the try block.
[1] linux 6eb3c3d0a52dc ("exec: increase BINPRM_BUF_SIZE to 256")
---
meta/classes-global/insane.bbclass | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index 4250331af12..08bff7dca45 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 is 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)
+ 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):
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] classes/insane: create one CachedPath instance in qa_check_staged
2026-06-30 14:07 [PATCH 1/3] classes/insane: increase shebang size limit Ross Burton
@ 2026-06-30 14:07 ` Ross Burton
2026-06-30 14:08 ` [PATCH 3/3] classes/insane: clean up do_qa_sysroot Ross Burton
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Ross Burton @ 2026-06-30 14:07 UTC (permalink / raw)
To: openembedded-core
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 <ross.burton@arm.com>
---
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 08bff7dca45..68ad78c39d6 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -729,6 +729,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:
@@ -772,10 +776,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):
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] classes/insane: clean up do_qa_sysroot
2026-06-30 14:07 [PATCH 1/3] classes/insane: increase shebang size limit Ross Burton
2026-06-30 14:07 ` [PATCH 2/3] classes/insane: create one CachedPath instance in qa_check_staged Ross Burton
@ 2026-06-30 14:08 ` Ross Burton
2026-07-01 6:01 ` [OE-core] [PATCH 1/3] classes/insane: increase shebang size limit Jörg Sommer
2026-07-01 11:28 ` Mathieu Dubois-Briand
3 siblings, 0 replies; 6+ messages in thread
From: Ross Burton @ 2026-06-30 14:08 UTC (permalink / raw)
To: openembedded-core
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 <ross.burton@arm.com>
---
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 68ad78c39d6..9640738f49f 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -1222,9 +1222,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"
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [OE-core] [PATCH 1/3] classes/insane: increase shebang size limit
2026-06-30 14:07 [PATCH 1/3] classes/insane: increase shebang size limit Ross Burton
2026-06-30 14:07 ` [PATCH 2/3] classes/insane: create one CachedPath instance in qa_check_staged Ross Burton
2026-06-30 14:08 ` [PATCH 3/3] classes/insane: clean up do_qa_sysroot Ross Burton
@ 2026-07-01 6:01 ` Jörg Sommer
2026-07-01 11:28 ` Mathieu Dubois-Briand
3 siblings, 0 replies; 6+ messages in thread
From: Jörg Sommer @ 2026-07-01 6:01 UTC (permalink / raw)
To: ross.burton; +Cc: openembedded-core
[-- Attachment #1: Type: text/plain, Size: 915 bytes --]
Ross Burton via lists.openembedded.org schrieb am Di 30. Jun, 15:07 (+0100):
> diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
> index 4250331af12..08bff7dca45 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 is was increased from 128 bytes
The »is« is too much.
Regards, Jörg
--
Navimatix GmbH T: 03641 - 327 99 0
Tatzendpromenade 2 F: 03641 - 526 306
07745 Jena www.navimatix.de
Geschäftsführer: Steffen Späthe, Jan Rommeley
Registergericht: Amtsgericht Jena, HRB 501480
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5000 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [OE-core] [PATCH 1/3] classes/insane: increase shebang size limit
2026-06-30 14:07 [PATCH 1/3] classes/insane: increase shebang size limit Ross Burton
` (2 preceding siblings ...)
2026-07-01 6:01 ` [OE-core] [PATCH 1/3] classes/insane: increase shebang size limit Jörg Sommer
@ 2026-07-01 11:28 ` Mathieu Dubois-Briand
2026-07-01 12:49 ` Ross Burton
3 siblings, 1 reply; 6+ messages in thread
From: Mathieu Dubois-Briand @ 2026-07-01 11:28 UTC (permalink / raw)
To: ross.burton, openembedded-core
On Tue Jun 30, 2026 at 4:07 PM CEST, Ross Burton via lists.openembedded.org wrote:
> 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), don't pointlessly try to decode
> the bytes as UTF-8, and consolidate the test logic to entirely inside
> the try block.
>
> [1] linux 6eb3c3d0a52dc ("exec: increase BINPRM_BUF_SIZE to 256")
> ---
Hi Ross,
Thanks for your patch.
I believe you also need to update the test_sysroot_max_shebang selftest
/ sysroot-shebang-test-native recipe:
2026-07-01 11:25:35,511 - oe-selftest - INFO - FAIL: sysroot.SysrootTests.test_sysroot_max_shebang (subunit.RemotedTestCase)
2026-07-01 11:25:35,511 - oe-selftest - INFO - ----------------------------------------------------------------------
2026-07-01 11:25:35,511 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/sysroot.py", line 49, in test_sysroot_max_shebang
self.assertTrue(expected in res.output, msg=res.output)
File "/usr/lib/python3.12/unittest/case.py", line 727, in assertTrue
raise self.failureException(msg)
AssertionError: False is not true : NOTE: Reconnecting to bitbake server...
https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4183
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4010
Thanks,
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [OE-core] [PATCH 1/3] classes/insane: increase shebang size limit
2026-07-01 11:28 ` Mathieu Dubois-Briand
@ 2026-07-01 12:49 ` Ross Burton
0 siblings, 0 replies; 6+ messages in thread
From: Ross Burton @ 2026-07-01 12:49 UTC (permalink / raw)
To: Mathieu Dubois-Briand; +Cc: openembedded-core@lists.openembedded.org
Hilariously, I was thinking I should write a test case and didn’t even think to check there was one already…
Sorry to break your build, v2 coming soon.
Ross
> On 1 Jul 2026, at 12:28, Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> wrote:
>
> On Tue Jun 30, 2026 at 4:07 PM CEST, Ross Burton via lists.openembedded.org wrote:
>> 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), don't pointlessly try to decode
>> the bytes as UTF-8, and consolidate the test logic to entirely inside
>> the try block.
>>
>> [1] linux 6eb3c3d0a52dc ("exec: increase BINPRM_BUF_SIZE to 256")
>> ---
>
> Hi Ross,
>
> Thanks for your patch.
>
> I believe you also need to update the test_sysroot_max_shebang selftest
> / sysroot-shebang-test-native recipe:
>
> 2026-07-01 11:25:35,511 - oe-selftest - INFO - FAIL: sysroot.SysrootTests.test_sysroot_max_shebang (subunit.RemotedTestCase)
> 2026-07-01 11:25:35,511 - oe-selftest - INFO - ----------------------------------------------------------------------
> 2026-07-01 11:25:35,511 - oe-selftest - INFO - testtools.testresult.real._StringException: Traceback (most recent call last):
> File "/srv/pokybuild/yocto-worker/oe-selftest-debian/build/layers/openembedded-core/meta/lib/oeqa/selftest/cases/sysroot.py", line 49, in test_sysroot_max_shebang
> self.assertTrue(expected in res.output, msg=res.output)
> File "/usr/lib/python3.12/unittest/case.py", line 727, in assertTrue
> raise self.failureException(msg)
> AssertionError: False is not true : NOTE: Reconnecting to bitbake server...
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/35/builds/4183
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4010
>
> Thanks,
> Mathieu
>
> --
> Mathieu Dubois-Briand, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-01 12:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 14:07 [PATCH 1/3] classes/insane: increase shebang size limit Ross Burton
2026-06-30 14:07 ` [PATCH 2/3] classes/insane: create one CachedPath instance in qa_check_staged Ross Burton
2026-06-30 14:08 ` [PATCH 3/3] classes/insane: clean up do_qa_sysroot Ross Burton
2026-07-01 6:01 ` [OE-core] [PATCH 1/3] classes/insane: increase shebang size limit Jörg Sommer
2026-07-01 11:28 ` Mathieu Dubois-Briand
2026-07-01 12:49 ` Ross Burton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox