Bug 15325

Summary: kernel: do_symlink_kernsrc is not reentrant when S is overriden
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Etienne Cordonnier <ecordonnier>
Component: kernelAssignee: Unassigned <unassigned>
Status: IN PROGRESS REVIEW --- QA Contact:
Severity: normal    
Priority: Medium CC: randy.macleod, tom.zanussi
Version: 5.1   
Target Milestone: 6.1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Etienne Cordonnier 2023-12-15 12:51:57 UTC
The function do_symlink_kernsrc is not reentrant in the case where S is defined to a non-default value.

How to reproduce (tested with commit 7d06e4e30b39a901a3d0b263d5de43f954c3270b of poky which is quite close to master):

- add this line to meta/recipes-kernel/linux/linux-yocto_6.5.bb:
S = "${WORKDIR}/my-kernel-source-dir"

- build linux-yocto a first time:
bitbake linux-yocto

This works, and you can see that the function do_symlink_kernsrc created a symlink :
```
poky/build$ ls -l tmp/work-shared/qemux86-64/
total 8
drwxr-xr-x 2 ecordonnier ecordonnier 4096 Dec 15 13:18 kernel-build-artifacts
drwxr-xr-x 2 ecordonnier ecordonnier 4096 Dec 15 13:18 kernel-source


poky/build$ ls -l tmp/work/qemux86_64-poky-linux/linux-yocto/6.5.13+git/
total 1480
...
...
lrwxrwxrwx   1 ecordonnier ecordonnier     73 Dec 15 13:18 my-kernel-source-dir -> /home/ecordonnier/dev/poky/build/tmp/work-shared/qemux86-64/kernel-source
```

- Build a second time (in reality this happened to me when building again after updating poky to a version which modified kernel.bbclass):
bitbake -C symlink_kernsrc linux-yocto

This will fail, and leave the directory structure in a completely broken state:
kernel-source is now a symlink to itself, and my-kernel-source-dir is a broken symlink:

```
poky/build$ ls -l tmp/work-shared/qemux86-64/
total 8
drwxr-xr-x 2 ecordonnier ecordonnier 4096 Dec 15 13:18 kernel-build-artifacts
lrwxrwxrwx 1 ecordonnier ecordonnier   73 Dec 15 13:18 kernel-source -> /home/ecordonnier/dev/poky/build/tmp/work-shared/qemux86-64/kernel-source

poky/build$ ls -l tmp/work/qemux86_64-poky-linux/linux-yocto/6.5.13+git/
...
lrwxrwxrwx   1 ecordonnier ecordonnier     73 Dec 15 13:20 my-kernel-source-dir -> /home/ecordonnier/dev/poky/build/tmp/work-shared/qemux86-64/kernel-source

```
Comment 2 Randy MacLeod 2023-12-21 15:32:56 UTC
Patch on list, thanks!
Comment 3 Randy MacLeod 2024-05-23 15:30:31 UTC
Etienne,
I took a quick look but didn't find a commit in master. 
Please provide a commit link if that exists.
Comment 4 Etienne Cordonnier 2024-05-23 15:33:28 UTC
Randy, there is no patch merged. I received some feedback after a couple of months, and then haven't found time to react on the feedback and work on a new version of the patch.
Comment 5 Randy MacLeod 2024-05-23 21:49:28 UTC
Thanks for the update, Etienne.
Comment 7 Randy MacLeod 2024-10-31 15:09:20 UTC
Bulk move of 5.1 bugs to 5.2. -- YP bug review (Randy)
Comment 8 Etienne Cordonnier 2025-04-29 07:30:28 UTC
I unassigned myself, because I don't know when I will have time to work on this. In principle this should be fixed, even though it's only a corner-case with some specific preconditions, so not high priority.
Comment 9 Randy MacLeod 2025-05-01 14:07:08 UTC
Bulk move of all unassigned 5.2 medium importance bugs to 5.3.