diff mbox series

[scarthgap,06/21] devtool: prevent 'devtool modify -n' from corrupting kernel Git repos

Message ID 17570092dd08b72ec025a159cc3915fc94344a76.1781270474.git.jeremy.rosen@smile.fr
State RFC, archived
Headers show
Series [scarthgap,01/21] libpng: Fix CVE-2026-33416 | expand

Commit Message

Jeremy Rosen June 12, 2026, 2:25 p.m. UTC
From: Enrico Jörns <ejo@pengutronix.de>

Running 'devtool modify -n' on a kernel recipe that inherits
'kernel-yocto' can unintentionally corrupt an existing Git repo or
worktree.

The work-shared optimization introduced in 3c3a9bae ("devtool/standard.py:
Update devtool modify to copy source from work-shared if its already
downloaded") is not skipped when '--no-extract' ('args.no_extract') is set.

As a result, for kernel builds where STAGING_KERNEL_DIR was already
populated when running 'devtool modify -n', the existing source tree is
overwritten (via oe.path.copyhardlinktree()) with the contents of
STAGING_KERNEL_DIR.

Fix by adding 'and not args.no_extract' to the kernel-yocto guard
condition.

(cherry picked from commit d383ea37e4987ecabe011226f1a8e658a52ede12)
Signed-off-by: Enrico Jörns <ejo@pengutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Jeremy Rosen <jeremy.rosen@smile.fr>
---
 scripts/lib/devtool/standard.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 908869cc4f..e1e519ce5b 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -841,7 +841,8 @@  def modify(args, config, basepath, workspace):
         commits = {}
         check_commits = False
 
-        if bb.data.inherits_class('kernel-yocto', rd):
+        if bb.data.inherits_class('kernel-yocto', rd) and not args.no_extract:
+
             # Current set kernel version
             kernelVersion = rd.getVar('LINUX_VERSION')
             srcdir = rd.getVar('STAGING_KERNEL_DIR')