<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15325</bug_id>
          
          <creation_ts>2023-12-15 12:51:57 +0000</creation_ts>
          <short_desc>kernel: do_symlink_kernsrc is not reentrant when S is overriden</short_desc>
          <delta_ts>2026-03-25 23:48:55 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>kernel</component>
          <version>5.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>IN PROGRESS REVIEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>6.1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Etienne Cordonnier">ecordonnier</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>tom.zanussi</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>97576</commentid>
    <comment_count>0</comment_count>
    <who name="Etienne Cordonnier">ecordonnier</who>
    <bug_when>2023-12-15 12:51:57 +0000</bug_when>
    <thetext>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 = &quot;${WORKDIR}/my-kernel-source-dir&quot;

- 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 -&gt; /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 -&gt; /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 -&gt; /home/ecordonnier/dev/poky/build/tmp/work-shared/qemux86-64/kernel-source

```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97622</commentid>
    <comment_count>1</comment_count>
    <who name="Etienne Cordonnier">ecordonnier</who>
    <bug_when>2023-12-19 13:41:37 +0000</bug_when>
    <thetext>https://lists.openembedded.org/g/openembedded-core/topic/patch_v4_kernel_bbclass/103262114</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>97632</commentid>
    <comment_count>2</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-12-21 15:32:56 +0000</bug_when>
    <thetext>Patch on list, thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99071</commentid>
    <comment_count>3</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-05-23 15:30:31 +0000</bug_when>
    <thetext>Etienne,
I took a quick look but didn&apos;t find a commit in master. 
Please provide a commit link if that exists.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99072</commentid>
    <comment_count>4</comment_count>
    <who name="Etienne Cordonnier">ecordonnier</who>
    <bug_when>2024-05-23 15:33:28 +0000</bug_when>
    <thetext>Randy, there is no patch merged. I received some feedback after a couple of months, and then haven&apos;t found time to react on the feedback and work on a new version of the patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99074</commentid>
    <comment_count>5</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-05-23 21:49:28 +0000</bug_when>
    <thetext>Thanks for the update, Etienne.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>99094</commentid>
    <comment_count>6</comment_count>
    <who name="Etienne Cordonnier">ecordonnier</who>
    <bug_when>2024-05-27 09:11:36 +0000</bug_when>
    <thetext>This was the latest feedback I got: https://lists.openembedded.org/g/openembedded-core/message/195238?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Acreated%2C%2Creentrant%2C20%2C2%2C0%2C103308574</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100076</commentid>
    <comment_count>7</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-10-31 15:09:20 +0000</bug_when>
    <thetext>Bulk move of 5.1 bugs to 5.2. -- YP bug review (Randy)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101769</commentid>
    <comment_count>8</comment_count>
    <who name="Etienne Cordonnier">ecordonnier</who>
    <bug_when>2025-04-29 07:30:28 +0000</bug_when>
    <thetext>I unassigned myself, because I don&apos;t know when I will have time to work on this. In principle this should be fixed, even though it&apos;s only a corner-case with some specific preconditions, so not high priority.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>101821</commentid>
    <comment_count>9</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2025-05-01 14:07:08 +0000</bug_when>
    <thetext>Bulk move of all unassigned 5.2 medium importance bugs to 5.3.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>