All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [honister] elfutils: Fix null pointer dereference with upstream patch.
@ 2022-06-13  9:14 ian.dev
  2022-06-13  9:20 ` [poky] " Anuj Mittal
  0 siblings, 1 reply; 3+ messages in thread
From: ian.dev @ 2022-06-13  9:14 UTC (permalink / raw)
  To: poky

Compilation with recent gcc flags a null pointer dereference warning
which is promoted to an error and causes failure to build.

Fixed in upstream patch by Mark Wielaard:
3d9f1288: [PATCH] elflint.c: Don't dereference databits if bad
This patch is included in 0.186 release but not in 0.185.

Patchfile here has the Changelog blob removed to allow it to apply.

Signed-off-by: Ian Jamison <ian.dev@arkver.com>
---
 .../elfutils/elfutils_0.185.bb                |  1 +
 ...001-dont-dereference-databits-if-bad.patch | 39 +++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 meta/recipes-devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch

diff --git a/meta/recipes-devtools/elfutils/elfutils_0.185.bb b/meta/recipes-devtools/elfutils/elfutils_0.185.bb
index f4769e3632..64a5038ed3 100644
--- a/meta/recipes-devtools/elfutils/elfutils_0.185.bb
+++ b/meta/recipes-devtools/elfutils/elfutils_0.185.bb
@@ -23,6 +23,7 @@ SRC_URI = "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
            file://0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch \
            file://0001-debuginfod-debuginfod-client.c-correct-string-format.patch \
            file://glibc-2.34-fix.patch \
+           file://0001-dont-dereference-databits-if-bad.patch \
            "
 SRC_URI:append:libc-musl = " \
            file://0002-musl-libs.patch \
diff --git a/meta/recipes-devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch b/meta/recipes-devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch
new file mode 100644
index 0000000000..d80c7acad8
--- /dev/null
+++ b/meta/recipes-devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch
@@ -0,0 +1,39 @@
+From 3d9f12883d0c131bd4ab6045e1f60d3fe6d150ea Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <mark@klomp.org>
+Date: Wed, 6 Oct 2021 23:37:42 +0200
+Subject: [PATCH] elflint.c: Don't dereference databits if bad
+
+elflint.c: In function 'check_sections':
+elflint.c:4105:48: error: null pointer dereference [-Werror=null-dereference]
+4105 |                                  idx < databits->d_size && ! bad;
+     |                                        ~~~~~~~~^~~~~~~~
+
+Fix this by testing for ! bad first.
+
+Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
+Signed-off-by: Mark Wielaard <mark@klomp.org>
+---
+
+NB: Upstream patch with Changelog blob removed since it doesn't apply cleanly.
+    Diffstat below is the original.
+
+ src/ChangeLog | 4 ++++
+ src/elflint.c | 2 +-
+ 2 files changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/elflint.c b/src/elflint.c
+index 1ce756847..ef7725ce7 100644
+--- a/src/elflint.c
++++ b/src/elflint.c
+@@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but is read from the file in segment of prog
+ 			    bad = (databits == NULL
+ 				   || databits->d_size != shdr->sh_size);
+ 			    for (size_t idx = 0;
+-				 idx < databits->d_size && ! bad;
++				 ! bad && idx < databits->d_size;
+ 				 idx++)
+ 			      bad = ((char *) databits->d_buf)[idx] != 0;
+ 
+-- 
+2.31.1
+
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [poky] [PATCH] [honister] elfutils: Fix null pointer dereference with upstream patch.
  2022-06-13  9:14 [PATCH] [honister] elfutils: Fix null pointer dereference with upstream patch ian.dev
@ 2022-06-13  9:20 ` Anuj Mittal
  2022-06-13  9:29   ` Ian Jamison
  0 siblings, 1 reply; 3+ messages in thread
From: Anuj Mittal @ 2022-06-13  9:20 UTC (permalink / raw)
  To: ian.dev, poky

On Mon, 2022-06-13 at 10:14 +0100, Ian Jamison wrote:
> Compilation with recent gcc flags a null pointer dereference warning
> which is promoted to an error and causes failure to build.
> 
> Fixed in upstream patch by Mark Wielaard:
> 3d9f1288: [PATCH] elflint.c: Don't dereference databits if bad
> This patch is included in 0.186 release but not in 0.185.
> 
> Patchfile here has the Changelog blob removed to allow it to apply.

honister branch is no longer maintained. This page has more information
on supported branches:

https://wiki.yoctoproject.org/wiki/Releases

Thanks,

Anuj

> 
> Signed-off-by: Ian Jamison <ian.dev@arkver.com>
> ---
>  .../elfutils/elfutils_0.185.bb                |  1 +
>  ...001-dont-dereference-databits-if-bad.patch | 39
> +++++++++++++++++++
>  2 files changed, 40 insertions(+)
>  create mode 100644 meta/recipes-devtools/elfutils/files/0001-dont-
> dereference-databits-if-bad.patch
> 
> diff --git a/meta/recipes-devtools/elfutils/elfutils_0.185.bb
> b/meta/recipes-devtools/elfutils/elfutils_0.185.bb
> index f4769e3632..64a5038ed3 100644
> --- a/meta/recipes-devtools/elfutils/elfutils_0.185.bb
> +++ b/meta/recipes-devtools/elfutils/elfutils_0.185.bb
> @@ -23,6 +23,7 @@ SRC_URI =
> "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
>            
> file://0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch
>  \
>            
> file://0001-debuginfod-debuginfod-client.c-correct-string-format.patch
>  \
>             file://glibc-2.34-fix.patch \
> +           file://0001-dont-dereference-databits-if-bad.patch \
>             "
>  SRC_URI:append:libc-musl = " \
>             file://0002-musl-libs.patch \
> diff --git a/meta/recipes-devtools/elfutils/files/0001-dont-
> dereference-databits-if-bad.patch b/meta/recipes-
> devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch
> new file mode 100644
> index 0000000000..d80c7acad8
> --- /dev/null
> +++ b/meta/recipes-devtools/elfutils/files/0001-dont-dereference-
> databits-if-bad.patch
> @@ -0,0 +1,39 @@
> +From 3d9f12883d0c131bd4ab6045e1f60d3fe6d150ea Mon Sep 17 00:00:00
> 2001
> +From: Mark Wielaard <mark@klomp.org>
> +Date: Wed, 6 Oct 2021 23:37:42 +0200
> +Subject: [PATCH] elflint.c: Don't dereference databits if bad
> +
> +elflint.c: In function 'check_sections':
> +elflint.c:4105:48: error: null pointer dereference [-Werror=null-
> dereference]
> +4105 |                                  idx < databits->d_size && !
> bad;
> +     |                                        ~~~~~~~~^~~~~~~~
> +
> +Fix this by testing for ! bad first.
> +
> +Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
> +Signed-off-by: Mark Wielaard <mark@klomp.org>
> +---
> +
> +NB: Upstream patch with Changelog blob removed since it doesn't
> apply cleanly.
> +    Diffstat below is the original.
> +
> + src/ChangeLog | 4 ++++
> + src/elflint.c | 2 +-
> + 2 files changed, 5 insertions(+), 1 deletion(-)
> +
> +diff --git a/src/elflint.c b/src/elflint.c
> +index 1ce756847..ef7725ce7 100644
> +--- a/src/elflint.c
> ++++ b/src/elflint.c
> +@@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but is
> read from the file in segment of prog
> +                           bad = (databits == NULL
> +                                  || databits->d_size != shdr-
> >sh_size);
> +                           for (size_t idx = 0;
> +-                               idx < databits->d_size && ! bad;
> ++                               ! bad && idx < databits->d_size;
> +                                idx++)
> +                             bad = ((char *) databits->d_buf)[idx]
> != 0;
> + 
> +-- 
> +2.31.1
> +
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [poky] [PATCH] [honister] elfutils: Fix null pointer dereference with upstream patch.
  2022-06-13  9:20 ` [poky] " Anuj Mittal
@ 2022-06-13  9:29   ` Ian Jamison
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Jamison @ 2022-06-13  9:29 UTC (permalink / raw)
  To: Anuj Mittal, poky

On 13/06/2022 10:20, Anuj Mittal wrote:
> On Mon, 2022-06-13 at 10:14 +0100, Ian Jamison wrote:
>> Compilation with recent gcc flags a null pointer dereference warning
>> which is promoted to an error and causes failure to build.
>>
>> Fixed in upstream patch by Mark Wielaard:
>> 3d9f1288: [PATCH] elflint.c: Don't dereference databits if bad
>> This patch is included in 0.186 release but not in 0.185.
>>
>> Patchfile here has the Changelog blob removed to allow it to apply.
> honister branch is no longer maintained. This page has more information
> on supported branches:
>
> https://wiki.yoctoproject.org/wiki/Releases

Thanks for the info Anuj. On IRC yesterday Ross suggested I submit the 
patch, but never mind. EOL is EOL.

Since IMX/Freescale latest release is based on honister I'll just have 
to keep this as a local patch then.

Regards,
Ian

>
> Thanks,
>
> Anuj
>
>> Signed-off-by: Ian Jamison <ian.dev@arkver.com>
>> ---
>>   .../elfutils/elfutils_0.185.bb                |  1 +
>>   ...001-dont-dereference-databits-if-bad.patch | 39
>> +++++++++++++++++++
>>   2 files changed, 40 insertions(+)
>>   create mode 100644 meta/recipes-devtools/elfutils/files/0001-dont-
>> dereference-databits-if-bad.patch
>>
>> diff --git a/meta/recipes-devtools/elfutils/elfutils_0.185.bb
>> b/meta/recipes-devtools/elfutils/elfutils_0.185.bb
>> index f4769e3632..64a5038ed3 100644
>> --- a/meta/recipes-devtools/elfutils/elfutils_0.185.bb
>> +++ b/meta/recipes-devtools/elfutils/elfutils_0.185.bb
>> @@ -23,6 +23,7 @@ SRC_URI =
>> "https://sourceware.org/elfutils/ftp/${PV}/${BP}.tar.bz2 \
>>             
>> file://0001-tests-Makefile.am-compile-test_nlist-with-standard-C.patch
>>   \
>>             
>> file://0001-debuginfod-debuginfod-client.c-correct-string-format.patch
>>   \
>>              file://glibc-2.34-fix.patch \
>> +           file://0001-dont-dereference-databits-if-bad.patch \
>>              "
>>   SRC_URI:append:libc-musl = " \
>>              file://0002-musl-libs.patch \
>> diff --git a/meta/recipes-devtools/elfutils/files/0001-dont-
>> dereference-databits-if-bad.patch b/meta/recipes-
>> devtools/elfutils/files/0001-dont-dereference-databits-if-bad.patch
>> new file mode 100644
>> index 0000000000..d80c7acad8
>> --- /dev/null
>> +++ b/meta/recipes-devtools/elfutils/files/0001-dont-dereference-
>> databits-if-bad.patch
>> @@ -0,0 +1,39 @@
>> +From 3d9f12883d0c131bd4ab6045e1f60d3fe6d150ea Mon Sep 17 00:00:00
>> 2001
>> +From: Mark Wielaard <mark@klomp.org>
>> +Date: Wed, 6 Oct 2021 23:37:42 +0200
>> +Subject: [PATCH] elflint.c: Don't dereference databits if bad
>> +
>> +elflint.c: In function 'check_sections':
>> +elflint.c:4105:48: error: null pointer dereference [-Werror=null-
>> dereference]
>> +4105 |                                  idx < databits->d_size && !
>> bad;
>> +     |                                        ~~~~~~~~^~~~~~~~
>> +
>> +Fix this by testing for ! bad first.
>> +
>> +Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
>> +Signed-off-by: Mark Wielaard <mark@klomp.org>
>> +---
>> +
>> +NB: Upstream patch with Changelog blob removed since it doesn't
>> apply cleanly.
>> +    Diffstat below is the original.
>> +
>> + src/ChangeLog | 4 ++++
>> + src/elflint.c | 2 +-
>> + 2 files changed, 5 insertions(+), 1 deletion(-)
>> +
>> +diff --git a/src/elflint.c b/src/elflint.c
>> +index 1ce756847..ef7725ce7 100644
>> +--- a/src/elflint.c
>> ++++ b/src/elflint.c
>> +@@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but is
>> read from the file in segment of prog
>> +                           bad = (databits == NULL
>> +                                  || databits->d_size != shdr-
>>> sh_size);
>> +                           for (size_t idx = 0;
>> +-                               idx < databits->d_size && ! bad;
>> ++                               ! bad && idx < databits->d_size;
>> +                                idx++)
>> +                             bad = ((char *) databits->d_buf)[idx]
>> != 0;
>> +
>> +--
>> +2.31.1
>> +
>>
>>
>>
>
> 
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-13  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13  9:14 [PATCH] [honister] elfutils: Fix null pointer dereference with upstream patch ian.dev
2022-06-13  9:20 ` [poky] " Anuj Mittal
2022-06-13  9:29   ` Ian Jamison

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.