Hi,

A possible fix for this issue during the do_patch task might be the following:

 

diff --git a/recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch b/recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch

index 8a9fb7c..66c86ee 100644

--- a/recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch

+++ b/recipes-security/selinux/libselinux/0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch

@@ -17,8 +17,8 @@ Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>

 

 diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c

 index d1ce830c5..6993be6fd 100644

---- a/libselinux/src/selinux_restorecon.c

-+++ b/libselinux/src/selinux_restorecon.c

+--- a/src/selinux_restorecon.c

++++ b/src/selinux_restorecon.c

 @@ -1154,6 +1154,8 @@ void selinux_restorecon_set_sehandle(struct selabel_handle *hndl)

        size_t num_specfiles, fc_digest_len;

  

Basically in the patch file: 0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch remove “libselinux” from a/libselinux/src/selinux_restorecon.c and b/libselinux/src/selinux_restorecon.c

 

I tested it and works fine.

 

From: Maurizio Macrina <mmacrina@catchpoint.com>
Date: Monday, 8 November 2021 at 14:13
To: jonas.brich@bmw.de <jonas.brich@bmw.de>, yocto@lists.yoctoproject.org <yocto@lists.yoctoproject.org>
Subject: Re: [yocto] meta-selinux: dunfell: libselinux: 0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch fails to apply

Hello Jonas,

I’ve also recently hit an error during the do_patch task of libselinux.

001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch has been recently added to the dunfell branch but fails to apply:

 

ERROR: Applying patch '0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch' on target directory '/yocto/c2100-catchpoint-system-image/poky/build/tmp/work/core2-64-poky-linux/libselinux/3.0-r0/libselinux-3.0'

Command Error: 'quilt --quiltrc /yocto/c2100-catchpoint-system-image/poky/build/tmp/work/core2-64-poky-linux/libselinux/3.0-r0/recipe-sysroot-native/etc/quiltrc push' exited with 0  Output:

Applying patch 0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch

can't find file to patch at input line 22

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|From 08f5e30177218fae7ce9f5c8d6856690126b2b30 Mon Sep 17 00:00:00 2001

|From: Ji Qin <jiqin.ji@huawei.com>

|Date: Sun, 14 Jun 2020 21:20:23 -0400

|Subject: [PATCH] libselinux: Fix NULL pointer use in

| selinux_restorecon_set_sehandle

|

|error occur when selinux_restorecon_default_handle return NULL in

|restorecon_init.

|

|fixes: https://github.com/SELinuxProject/selinux/issues/249

|

|Signed-off-by: Ji Qin <jiqin.ji@huawei.com>

|Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>

|---

| libselinux/src/selinux_restorecon.c | 2 ++

| 1 file changed, 2 insertions(+)

|

|diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c

|index d1ce830c5..6993be6fd 100644

|--- a/libselinux/src/selinux_restorecon.c

|+++ b/libselinux/src/selinux_restorecon.c

--------------------------

No file to patch.  Skipping patch.

1 out of 1 hunk ignored

Patch 0001-Fix-NULL-pointer-use-in-selinux_restorecon_set_sehandle.patch does not apply (enforce with -f)

DEBUG: Python function patch_do_patch finished

DEBUG: Python function do_patch finished

 

I’ve attached the corresponding log.

 

What would be the suggested fix for this?

I don’t think the leading a/b in the path is the issue here, other patch files have the same path.

 

Thanks.

 

Regards.

 

Maurizio Macrina

Senior Software Engineer  | Catchpoint

P:  +39 3472458541

E:  mmacrina@catchpoint.com  

www.catchpoint.com

 

cid464070800*image001.png@01D7AF12.EF411150