Re: [yocto-patches] [pseudo] [PATCH] Only copy xattrs on a rename if it's cross-filesystem
Richard Purdie <[email protected]>
| Newsgroups | org.yoctoproject.lists.yocto-patches |
|---|---|
| Message-ID | <a0772e3cd3ba1ca5f983ba4d1702d3b2e557e373.camel@linuxfoundation.org> |
On Wed, 2026-04-22 at 09:26 -0400, Daniel Burgener via lists.yoctoproject.org wrote: > On 4/8/2026 9:55 AM, Daniel Burgener via lists.yoctoproject.org wrote: > > On 3/11/2026 1:59 PM, Daniel Burgener via lists.yoctoproject.org wrote: > > > On same file-system renames, the path update in the db means that the > > > xattrs are already present, and copying results in duplicates. This was > > > previously masked by the bug fixed in > > > d1db9c219abf92f15303486a409292237f1fc790, since that prevented the > > > xattr copying. Now that that bug is fixed, we started observing this > > > issue in 1.9.3. > > > > > > AI-Generated: Code fix by Claude Haiku 4.5. Test code by me. > > > > > > Signed-off-by: Daniel Burgener <[email protected]> > > > --- > > > pseudo_db.c | 4 +++- > > > test/test-xattr.sh | 12 ++++++++++++ > > > 2 files changed, 15 insertions(+), 1 deletion(-) > > > > > > diff --git a/pseudo_db.c b/pseudo_db.c > > > index 9713e0c..6a33f20 100644 > > > --- a/pseudo_db.c > > > +++ b/pseudo_db.c > > > @@ -2196,7 +2196,9 @@ pdb_update_inode(pseudo_msg_t *msg) { > > > found_existing = !pdb_find_file_path(oldmsg); > > > if (found_existing) { > > > /* we have an existing file entry */ > > > - pdb_copy_xattrs(oldmsg, msg); > > > + if (oldmsg->dev != msg->dev || oldmsg->ino != msg->ino) { > > > + pdb_copy_xattrs(oldmsg, msg); > > > + } > > > } > > > sqlite3_bind_int(update, 1, msg->dev); > > > sqlite3_bind_int64(update, 2, signed_ino(msg->ino)); > > > diff --git a/test/test-xattr.sh b/test/test-xattr.sh > > > index 6ac6b3c..89fbd35 100755 > > > --- a/test/test-xattr.sh > > > +++ b/test/test-xattr.sh > > > @@ -65,6 +65,18 @@ then > > > exit 1 > > > fi > > > +mv f1 f2 > > > +attrs=`getfattr -d -m - f2 | grep -v '^#'` > > > +expected=$'security.dummy="test_f2"\nuser.dummy="test_f1"' > > > +if [ "$attrs" != "$expected" ] > > > +then > > > + #echo "Fail, unpexected getfattr result '$attrs'" > > > + rm -f f1 > > > + rm -f f2 > > > + exit 1 > > > +fi > > > + > > > #echo "Passed." > > > rm -f f1 > > > +rm -f f2 > > > exit 0 > > > > Gentle ping on this patch. Any feedback? > > > > -Daniel > > > > Pinging again on this. If I've done something wrong in submitting, > please let me know so I can get this reviewed. > > I'll also note that while I did use AI for the fix, this is an actual > bug we're encountering in our environment, not something picked up by an > LLM scanning the code base. Specifically, we (in a pseudo environment) > populate a directory structure, and then do: > > setfiles -m -v -E -F ${FILE_CONTEXTS} -r ${FOO_SQUASHFS_ROOT} > ${FOO_SQUASHFS_ROOT} > mksquashfs "$FOO_SQUASHFS_ROOT" "$PATH_FOO" -noappend > # mv some files into ${FOO_SQUASHFS_ROOT} > setfiles -m -v -E -F ${FILE_CONTEXTS} -r ${FOO_SQUASHFS_ROOT} > mksquashfs "$FOO_SQUASHFS_ROOT" "$PATH_BAR" -noappend > > We observe the second mksquashfs fail due to duplicate selinux xattrs. > My understanding is that the code touched in this patch seems to rename > the original file, which preserves the xattrs in the pseudodb, and then > copy the xattrs as well, resulting in duplicate xattrs. Sorry about the delay, we've been struggling a bit for review cycles. I think this looks right to me. Copying Mark to see what he thinks. Cheers, Richard