libselinux: set free'd data to NULL
PATCH 1/1 libselinux: set free'd data to NULL
Fixes segfault in selabel_open() on systems with SELinux disabled and without any SELinux policy installed introduced by commit 5876aca0484f ("libselinux: free data on selabel open failure"):
$ sestatus
SELinux status: disabled $ cat /etc/selinux/config
cat: /etc/selinux/config: No such file or directory $ matchpathcon /abc
[1] 907999 segmentation fault (core dumped) matchpathcon /abc--- libselinux/src/label_backends_android.c | 1 + libselinux/src/label_file.c | 1 + libselinux/src/label_media.c | 1 + libselinux/src/label_x.c | 1 + 4 files changed, 4 insertions(+)
libselinux/src/label_backends_android.c +1 -0
@@ -260,6 +260,7 @@ static void closef(struct selabel_handle *rec)free (data->spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *property_lookup(struct selabel_handle *rec,
libselinux/src/label_file.c +1 -0
@@ -942,6 +942,7 @@ static void closef(struct selabel_handle *rec)free (last_area); }free (data); + rec->data =NULL ; }// Finds all the matches of |key| in the given context. Returns the result in
libselinux/src/label_media.c +1 -0
@@ -183,6 +183,7 @@ static void close(struct selabel_handle *rec)free (spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *lookup(struct selabel_handle *rec,
libselinux/src/label_x.c +1 -0
@@ -210,6 +210,7 @@ static void close(struct selabel_handle *rec)free (spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *lookup(struct selabel_handle *rec,
Signature · 1 line
2.45.2
Quoted 5 lines · Petr Lautrbach
Fixes segfault in
selabel_open()on systems with SELinux disabled and without any SELinux policy installed introduced by commit5876aca0484f("libselinux: free data on selabel open failure"):
Quoted 9 lines
$ sestatus SELinux status: disabled$ cat /etc/selinux/config cat: /etc/selinux/config: No such file or directory$ matchpathcon /abc [1] 907999 segmentation fault (core dumped) matchpathcon /abc
I was able to recreate the problem and verify that this fixes it.
Quoted 60 lines
Signed-off-by Petr Lautrbach <[email protected]>--- libselinux/src/label_backends_android.c | 1 + libselinux/src/label_file.c | 1 + libselinux/src/label_media.c | 1 + libselinux/src/label_x.c | 1 + 4 files changed, 4 insertions(+)libselinux/src/label_backends_android.c +1
-0@@ -260,6 +260,7 @@ static void closef(struct selabel_handle *rec)free (data->spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *property_lookup(struct selabel_handle *rec,libselinux/src/label_file.c +1
-0@@ -942,6 +942,7 @@ static void closef(struct selabel_handle *rec)free (last_area); }free (data); + rec->data =NULL ; }// Finds all the matches of |key| in the given context. Returns the result in libselinux/src/label_media.c +1
-0@@ -183,6 +183,7 @@ static void close(struct selabel_handle *rec)free (spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *lookup(struct selabel_handle *rec,libselinux/src/label_x.c +1
-1@@ -210,6 +210,7 @@ static void close(struct selabel_handle *rec)free (spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *lookup(struct selabel_handle *rec, --2.45.2
Quoted 12 lines · James Carter
Quoted 11 lines · Petr Lautrbach
Fixes segfault in
selabel_open()on systems with SELinux disabled and without any SELinux policy installed introduced by commit5876aca0484f("libselinux: free data on selabel open failure"):$ sestatus SELinux status: disabled$ cat /etc/selinux/config cat: /etc/selinux/config: No such file or directory
Quoted 6 lines
Quoted 3 lines
$ matchpathcon /abc [1] 907999 segmentation fault (core dumped) matchpathcon /abcI was able to recreate the problem and verify that this fixes it.
Acked-by James Carter <[email protected]>
This is merged now.
Quoted 61 lines
Quoted 61 lines
Signed-off-by Petr Lautrbach <[email protected]>--- libselinux/src/label_backends_android.c | 1 + libselinux/src/label_file.c | 1 + libselinux/src/label_media.c | 1 + libselinux/src/label_x.c | 1 + 4 files changed, 4 insertions(+)libselinux/src/label_backends_android.c +1
-0@@ -260,6 +260,7 @@ static void closef(struct selabel_handle *rec)free (data->spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *property_lookup(struct selabel_handle *rec,libselinux/src/label_file.c +1
-0@@ -942,6 +942,7 @@ static void closef(struct selabel_handle *rec)free (last_area); }free (data); + rec->data =NULL ; }// Finds all the matches of |key| in the given context. Returns the result in libselinux/src/label_media.c +1
-0@@ -183,6 +183,7 @@ static void close(struct selabel_handle *rec)free (spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *lookup(struct selabel_handle *rec,libselinux/src/label_x.c +1
-1@@ -210,6 +210,7 @@ static void close(struct selabel_handle *rec)free (spec_arr);free (data); + rec->data =NULL ; } static struct selabel_lookup_rec *lookup(struct selabel_handle *rec, --2.45.2