Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2023-05-10 Thread Sebastian Huber

Hello Joel,

On 10.05.23 15:33, Joel Sherrill wrote:


Sebastian I know this is third party code that you just imported but 
this looks like a potentially serious issue.


Does anyone see how this could occur? Have a suggestion?

Minimum is to report it upstream. I did that years ago with another 
issue in zlib.


yes, we should report this upstream.

--
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.hu...@embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2022-10-10 Thread Chris Johns
Hi,

Thanks Coverity for picking up I forgot to add the new error string. :)

I will push the 1 line change.

Chris

On 10/10/2022 10:46 pm, Joel Sherrill wrote:
> 
> -- Forwarded message -
> From: mailto:scan-ad...@coverity.com>>
> Date: Mon, Oct 10, 2022, 12:22 AM
> Subject: New Defects reported by Coverity Scan for RTEMS
> To: mailto:bu...@rtems.org>>
> 
> 
> Hi,
> 
> Please find the latest report on new defect(s) introduced to RTEMS found with
> Coverity Scan.
> 
> 1 new defect(s) introduced to RTEMS found with Coverity Scan.
> 
> 
> New defect(s) Reported-by: Coverity Scan
> Showing 1 of 1 defect(s)
> 
> 
> ** CID 1515930:  Memory - illegal accesses  (OVERRUN)
> /cpukit/libmisc/rtems-fdt/rtems-fdt.c: 971 in rtems_fdt_strerror()
> 
> 
> 
> *** CID 1515930:  Memory - illegal accesses  (OVERRUN)
> /cpukit/libmisc/rtems-fdt/rtems-fdt.c: 971 in rtems_fdt_strerror()
> 965         "blob has references"
> 966       };
> 967       if (errval > -RTEMS_FDT_ERR_RTEMS_MIN)
> 968         return fdt_strerror (errval);
> 969       if (errval < -RTEMS_FDT_ERR_MAX)
> 970         return "invalid error code";
     CID 1515930:  Memory - illegal accesses  (OVERRUN)
     Overrunning array "errors" of 5 4-byte elements at element index 5 
(byte
> offset 23) using index "-errval - 100" (which evaluates to 5).
> 971       return errors[(-errval) - RTEMS_FDT_ERR_RTEMS_MIN];
> 972     }
> 973     
> 974     int
> 975     rtems_fdt_prop_value(const char* const path,
> 976                          const char* const propname,
> 
> 
> 
> To view the defects in Coverity Scan visit,
> https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3D3tGt_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMrx8nV9Pzi0hugn9s2FK6ZfLix8JmyqOKq3RkOqFldjBEAraGrjvpmsds-2B4Iivd5W95gEqWlcvVuG1EDWj6hubB5Z5pEtpqtddGnBcH49eyBbkHPbRwsax2k1rSx8EynyzF-2Fw-2BumI1vwItGf-2FpJNy6Us6XZ0o-2BY2bhnazRwWhumfA-3D-3D
>  
> 
> 
> ___
> build mailing list
> bu...@rtems.org 
> http://lists.rtems.org/mailman/listinfo/build
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2021-03-12 Thread Joel Sherrill
Luckily I think it is an easy one. Checking if an unsigned value is less
than 0.

Look back in the history. Ryan may have fixed it once and you just
accidentally
reverted it. He fixed a handful like this.

I'm sorry you were the first to be caught by it but I am thrilled to have
Coverity
run automatically about midnight Central time every night if there were any
changes to the RSB or RTEMS repos. Then it sends an email to build@ if
any new issues turned up. Definitely progress has been made here.

--joel

On Fri, Mar 12, 2021 at 7:22 AM Daniel Hellstrom  wrote:

> yes, it must have, so I will look into that.
>
> /Daniel
>
>On 2021-03-12 14:07, Joel Sherrill wrote:
>
> Without looking, I would assume this was introduced by Daniel's recent
> patches.
>
> -- Forwarded message -
> From: 
> Date: Fri, Mar 12, 2021, 12:55 AM
> Subject: New Defects reported by Coverity Scan for RTEMS
> To: 
>
>
> Hi,
>
> Please find the latest report on new defect(s) introduced to RTEMS found
> with Coverity Scan.
>
> 1 new defect(s) introduced to RTEMS found with Coverity Scan.
>
>
> New defect(s) Reported-by: Coverity Scan
> Showing 1 of 1 defect(s)
>
>
> ** CID 1473629:  Control flow issues  (NO_EFFECT)
> /bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()
>
>
>
> 
> *** CID 1473629:  Control flow issues  (NO_EFFECT)
> /bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()
> 317 bds = 1;
> 318 if (space_left < bds)
> 319 break;
> 320
> 321 /* Convert and write CAN message to DMA buffer */
> 322 dlc = grcan_len2dlc(source->len);
> >>> CID 1473629:  Control flow issues  (NO_EFFECT)
> >>> This less-than-zero comparison of an unsigned value is never true.
> "dlc < 0".
> 323 if (dlc < 0) {
> 324 /* Bad user input. Report the number of
> written messages
> 325  * or an error when non sent.
> 326  */
> 327 if (ret <= 0)
> 328 return GRCAN_RET_INVARG;
>
>
>
> 
> To view the defects in Coverity Scan visit,
> https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3DVX3j_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMppdCoTOdWUHKtQLrEQ1MfSyaNP2M1HWoDjjoKTjy-2FIq1HdvVcL1npIuQDJWa-2FDWEQ-2FAOQo8VzAxUCWwGfT9lbXVNqnU0jQl-2FWSYNQAJPY2Tylmw5hG5KcV6hC39VfLDFtSor5xgUxBh-2BcdibW34mNQFj7qSSTl6hW9DF4ywtf1oYStmZyjbwIV0D1AeB2dPto-3D
>
> ___
> build mailing list
> bu...@rtems.org
> http://lists.rtems.org/mailman/listinfo/build
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2021-03-12 Thread Daniel Hellstrom

yes, it must have, so I will look into that.

/Daniel

  


On 2021-03-12 14:07, Joel Sherrill wrote:
Without looking, I would assume this was introduced by Daniel's recent 
patches.


-- Forwarded message -
From: mailto:scan-ad...@coverity.com>>
Date: Fri, Mar 12, 2021, 12:55 AM
Subject: New Defects reported by Coverity Scan for RTEMS
To: mailto:bu...@rtems.org>>


Hi,

Please find the latest report on new defect(s) introduced to RTEMS 
found with Coverity Scan.


1 new defect(s) introduced to RTEMS found with Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)


** CID 1473629:  Control flow issues  (NO_EFFECT)
/bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()



*** CID 1473629:  Control flow issues  (NO_EFFECT)
/bsps/shared/grlib/can/grcanfd.c: 323 in grcan_hw_write_try_fd()
317                             bds = 1;
318                     if (space_left < bds)
319                             break;
320
321                     /* Convert and write CAN message to DMA buffer */
322                     dlc = grcan_len2dlc(source->len);
>>>     CID 1473629:  Control flow issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never 
true. "dlc < 0".

323                     if (dlc < 0) {
324                             /* Bad user input. Report the number 
of written messages

325                              * or an error when non sent.
326                              */
327                             if (ret <= 0)
328                                     return GRCAN_RET_INVARG;



To view the defects in Coverity Scan visit, 
https://u15810271.ct.sendgrid.net/ls/click?upn=HRESupC-2F2Czv4BOaCWWCy7my0P0qcxCbhZ31OYv50ypUUzi-2FdSNmuyRB7BEFT8xQ4-2B8hpujh0hTgQljRGId4Dg-3D-3DVX3j_EU3W9teASMK00lBXX9WT4lsogDrkCcNZLvg-2FVxwAXMppdCoTOdWUHKtQLrEQ1MfSyaNP2M1HWoDjjoKTjy-2FIq1HdvVcL1npIuQDJWa-2FDWEQ-2FAOQo8VzAxUCWwGfT9lbXVNqnU0jQl-2FWSYNQAJPY2Tylmw5hG5KcV6hC39VfLDFtSor5xgUxBh-2BcdibW34mNQFj7qSSTl6hW9DF4ywtf1oYStmZyjbwIV0D1AeB2dPto-3D 



___
build mailing list
bu...@rtems.org 
http://lists.rtems.org/mailman/listinfo/build 

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2020-12-09 Thread Sebastian Huber

On 09/12/2020 10:11, Sebastian Huber wrote:


On 08/12/2020 19:10, Gedare Bloom wrote:



Hi all,

I get a text report on new defects from Coverity. I don't know how I 
managed to sign up for it, and I'm not sure I can get it sent to any 
list automatically, but here is the current updated new defects. Just 
looks like two new ones related to static assertions.


-- Forwarded message -
From: mailto:scan-ad...@coverity.com>>
Date: Mon, Dec 7, 2020 at 7:38 AM
Subject: New Defects reported by Coverity Scan for RTEMS
To: mailto:ged...@gwmail.gwu.edu>>


Hi,

Please find the latest report on new defect(s) introduced to RTEMS 
found with Coverity Scan.


1 new defect(s) introduced to RTEMS found with Coverity Scan.
10 defect(s), reported by Coverity Scan earlier, were marked fixed in 
the recent build analyzed by Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)


** CID 1470570:    (PARSE_ERROR)
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()


 


*** CID 1470570:    (PARSE_ERROR)
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()
104      */
105     #pragma GCC diagnostic push
106     #pragma GCC diagnostic ignored "-Waddress"
107     #pragma GCC diagnostic ignored "-Wpragmas"
108     #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
109
>>>     CID 1470570:    (PARSE_ERROR)
>>>     type of cast must be integral
110     RTEMS_STATIC_ASSERT(
111       CONFIGURE_INIT_TASK_ENTRY_POINT != NULL,
112       CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL
113     );
114
115     #pragma GCC diagnostic pop
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()
104      */
105     #pragma GCC diagnostic push
106     #pragma GCC diagnostic ignored "-Waddress"
107     #pragma GCC diagnostic ignored "-Wpragmas"
108     #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
109
>>>     CID 1470570:    (PARSE_ERROR)
>>>     expression must be an integral constant expression
110     RTEMS_STATIC_ASSERT(
111       CONFIGURE_INIT_TASK_ENTRY_POINT != NULL,
112       CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL
113     );
114
115     #pragma GCC diagnostic pop


I checked an example code with three compilers and noticed no standard 
related warnings. I can ask on a C/C++ mailing list if the code is 
standard compliant. It could be Coverity bug.


#include 

void f(void);

static_assert(f != NULL, "f");

constexpr bool g()
{
  return f != NULL;
}

extern const bool b;

const bool b = g();

arm-rtems6-g++ -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
    .cpu arm7tdmi
    .eabi_attribute 20, 1
    .eabi_attribute 21, 1
    .eabi_attribute 23, 3
    .eabi_attribute 24, 1
    .eabi_attribute 25, 1
    .eabi_attribute 26, 2
    .eabi_attribute 30, 6
    .eabi_attribute 34, 0
    .eabi_attribute 18, 4
    .file   "test.cc"
test.cc:5:17: warning: the address of 'void f()' will never be NULL 
[-Waddress]

    5 | static_assert(f != NULL, "f");
  | ^
test.cc: In function 'constexpr bool g()':
test.cc:9:12: warning: the address of 'void f()' will never be NULL 
[-Waddress]

    9 |   return f != NULL;
  |    ^
    .text
    .global b
    .section    .rodata
    .type   b, %object
    .size   b, 1
b:
    .byte   1
    .ident  "GCC: (GNU) 10.2.1 20201203 (RTEMS 6, RSB 
ff6b2320ed34abab48751022085912217f42590d, Newlib 7fa8405)"



g++ -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
    .file   "test.cc"
test.cc:5:17: warning: the address of ‘void f()’ will never be NULL 
[-Waddress]

 static_assert(f != NULL, "f");
 ^
test.cc: In function ‘constexpr bool g()’:
test.cc:9:12: warning: the address of ‘void f()’ will never be NULL 
[-Waddress]

   return f != NULL;
    ^
    .text
    .globl  b
    .section    .rodata
    .type   b, @object
    .size   b, 1
b:
    .byte   1
    .ident  "GCC: (SUSE Linux) 7.5.0"
    .section    .note.GNU-stack,"",@progbits


clang -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
test.cc:5:15: warning: comparison of function 'f' not equal to a null 
pointer is always true [-Wtautological-pointer-compare]

static_assert(f != NULL, "f");
  ^    
test.cc:5:15: note: prefix with the address-of operator to silence 
this warning

static_assert(f != NULL, "f");
  ^
  &
test.cc:9:10: warning: comparison of function 'f' not equal to a null 
pointer is always true [-Wtautological-pointer-compare]

  return f != NULL;
 ^    
test.cc:9:10: note: prefix with the address-of operator to silence 
this warning

  return f != NULL;
 ^
 &
    .text
    .file   "test.cc"
    .type   b,@object   # @b
    .section    

Re: Fwd: New Defects reported by Coverity Scan for RTEMS

2020-12-09 Thread Sebastian Huber

On 08/12/2020 19:10, Gedare Bloom wrote:



Hi all,

I get a text report on new defects from Coverity. I don't know how I 
managed to sign up for it, and I'm not sure I can get it sent to any 
list automatically, but here is the current updated new defects. Just 
looks like two new ones related to static assertions.


-- Forwarded message -
From: mailto:scan-ad...@coverity.com>>
Date: Mon, Dec 7, 2020 at 7:38 AM
Subject: New Defects reported by Coverity Scan for RTEMS
To: mailto:ged...@gwmail.gwu.edu>>


Hi,

Please find the latest report on new defect(s) introduced to RTEMS 
found with Coverity Scan.


1 new defect(s) introduced to RTEMS found with Coverity Scan.
10 defect(s), reported by Coverity Scan earlier, were marked fixed in 
the recent build analyzed by Coverity Scan.


New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)


** CID 1470570:    (PARSE_ERROR)
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()



*** CID 1470570:    (PARSE_ERROR)
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()
104      */
105     #pragma GCC diagnostic push
106     #pragma GCC diagnostic ignored "-Waddress"
107     #pragma GCC diagnostic ignored "-Wpragmas"
108     #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
109
>>>     CID 1470570:    (PARSE_ERROR)
>>>     type of cast must be integral
110     RTEMS_STATIC_ASSERT(
111       CONFIGURE_INIT_TASK_ENTRY_POINT != NULL,
112       CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL
113     );
114
115     #pragma GCC diagnostic pop
/cpukit/include/rtems/confdefs/inittask.h: 110 in ()
104      */
105     #pragma GCC diagnostic push
106     #pragma GCC diagnostic ignored "-Waddress"
107     #pragma GCC diagnostic ignored "-Wpragmas"
108     #pragma GCC diagnostic ignored "-Wtautological-pointer-compare"
109
>>>     CID 1470570:    (PARSE_ERROR)
>>>     expression must be an integral constant expression
110     RTEMS_STATIC_ASSERT(
111       CONFIGURE_INIT_TASK_ENTRY_POINT != NULL,
112       CONFIGURE_INIT_TASK_ENTRY_POINT_MUST_NOT_BE_NULL
113     );
114
115     #pragma GCC diagnostic pop


I checked an example code with three compilers and noticed no standard 
related warnings. I can ask on a C/C++ mailing list if the code is 
standard compliant. It could be Coverity bug.


#include 

void f(void);

static_assert(f != NULL, "f");

constexpr bool g()
{
  return f != NULL;
}

extern const bool b;

const bool b = g();

arm-rtems6-g++ -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
    .cpu arm7tdmi
    .eabi_attribute 20, 1
    .eabi_attribute 21, 1
    .eabi_attribute 23, 3
    .eabi_attribute 24, 1
    .eabi_attribute 25, 1
    .eabi_attribute 26, 2
    .eabi_attribute 30, 6
    .eabi_attribute 34, 0
    .eabi_attribute 18, 4
    .file   "test.cc"
test.cc:5:17: warning: the address of 'void f()' will never be NULL 
[-Waddress]

    5 | static_assert(f != NULL, "f");
  | ^
test.cc: In function 'constexpr bool g()':
test.cc:9:12: warning: the address of 'void f()' will never be NULL 
[-Waddress]

    9 |   return f != NULL;
  |    ^
    .text
    .global b
    .section    .rodata
    .type   b, %object
    .size   b, 1
b:
    .byte   1
    .ident  "GCC: (GNU) 10.2.1 20201203 (RTEMS 6, RSB 
ff6b2320ed34abab48751022085912217f42590d, Newlib 7fa8405)"



g++ -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
    .file   "test.cc"
test.cc:5:17: warning: the address of ‘void f()’ will never be NULL 
[-Waddress]

 static_assert(f != NULL, "f");
 ^
test.cc: In function ‘constexpr bool g()’:
test.cc:9:12: warning: the address of ‘void f()’ will never be NULL 
[-Waddress]

   return f != NULL;
    ^
    .text
    .globl  b
    .section    .rodata
    .type   b, @object
    .size   b, 1
b:
    .byte   1
    .ident  "GCC: (SUSE Linux) 7.5.0"
    .section    .note.GNU-stack,"",@progbits


clang -Wall -Wextra -pedantic -std=c++11 -S -o - test.cc
test.cc:5:15: warning: comparison of function 'f' not equal to a null 
pointer is always true [-Wtautological-pointer-compare]

static_assert(f != NULL, "f");
  ^    
test.cc:5:15: note: prefix with the address-of operator to silence this 
warning

static_assert(f != NULL, "f");
  ^
  &
test.cc:9:10: warning: comparison of function 'f' not equal to a null 
pointer is always true [-Wtautological-pointer-compare]

  return f != NULL;
 ^    
test.cc:9:10: note: prefix with the address-of operator to silence this 
warning

  return f != NULL;
 ^
 &
    .text
    .file   "test.cc"
    .type   b,@object   # @b
    .section    .rodata,"a",@progbits
    .globl  b
b: