libressl/portable

Gentoo QA Notice for libressl-3.7.1

orbea opened this issue · 10 comments

orbea commented

On Gentoo when building libressl-3.7.1 with gcc-12.2.1_p20230121-r1 this warning is emitted .

  • QA Notice: Package triggers severe warnings which indicate that it may exhibit random runtime failures.
  • /var/tmp/portage/dev-libs/libressl-3.7.1/work/libressl-3.7.1/ssl/s3_cbc.c:529:9: warning: 'memcpy' forming offset 128 is out of the bounds [0, 128] of object 'hmac_pad' with type 'unsigned char[128]' [-Warray-bounds]

And the whole warning can be seen:

/var/tmp/portage/dev-libs/libressl-3.7.1/work/libressl-3.7.1/ssl/s3_cbc.c: In function 'ssl3_cbc_digest_record':
/var/tmp/portage/dev-libs/libressl-3.7.1/work/libressl-3.7.1/ssl/s3_cbc.c:529:9: warning: 'memcpy' forming offset 128 is out of the bounds [0, 128] of object 'hmac_pad' with type 'unsigned char[128]' [-Warray-bounds]
  529 |         memcpy(hmac_pad, mac_secret, mac_secret_length);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/var/tmp/portage/dev-libs/libressl-3.7.1/work/libressl-3.7.1/ssl/s3_cbc.c:403:23: note: 'hmac_pad' declared here
  403 |         unsigned char hmac_pad[MAX_HASH_BLOCK_SIZE];
      |                       ^~~~~~~~
botovq commented
orbea commented

Thanks that patch silences the compiler warning and QA notice, wouldn't it be better to be explicit with the noreturn attribute to make gcc (And Gentoo's QA) happy? Or is there some reason to not merge it? It might seem silly, but is it actually problematic?

botovq commented
orbea commented

Oh, thanks for explaining, I didn't catch that earlier. I suppose this issue can be closed when the new release is out?

orbea commented

Actually there is an issue with this approach, libvncserver-0.9.14 now fails.

samu: job failed: /usr/lib/ccache/bin/x86_64-gentoo-linux-musl-gcc -DLIBVNCSERVER_HAVE_LIBJPEG -DLIBVNCSERVER_HAVE_LIBPNG -DLIBVNCSERVER_HAVE_LIBZ -DLIBVNCSERVER_WITH_WEBSOCKETS -Dvncserver_EXPORTS -I/var/tmp/portage/net-libs/libvncserver-0.9.14/work/libvncserver-LibVNCServer-0.9.14 -I/var/tmp/portage/net-libs/libvncserver-0.9.14/work/libvncserver-LibVNCServer-0.9.14_build -I/var/tmp/portage/net-libs/libvncserver-0.9.14/work/libvncserver-LibVNCServer-0.9.14/libvncserver -I/var/tmp/portage/net-libs/libvncserver-0.9.14/work/libvncserver-LibVNCServer-0.9.14/common  -O2 -pipe -Werror=implicit-function-declaration -Werror=implicit-int -fPIC -std=gnu90 -MD -MT CMakeFiles/vncserver.dir/libvncserver/rfbssl_openssl.c.o -MF CMakeFiles/vncserver.dir/libvncserver/rfbssl_openssl.c.o.d -o CMakeFiles/vncserver.dir/libvncserver/rfbssl_openssl.c.o -c /var/tmp/portage/net-libs/libvncserver-0.9.14/work/libvncserver-LibVNCServer-0.9.14/libvncserver/rfbssl_openssl.c
In file included from /usr/include/openssl/bio.h:69,
                 from /usr/include/openssl/evp.h:67,
                 from /usr/include/openssl/hmac.h:67,
                 from /usr/include/openssl/ssl.h:150,
                 from /var/tmp/portage/net-libs/libvncserver-0.9.14/work/libvncserver-LibVNCServer-0.9.14/libvncserver/rfbssl_openssl.c:25:
/usr/include/openssl/crypto.h:491:7: error: expected ';' before 'void'
  491 | __dead void OpenSSLDie(const char *file, int line, const char *assertion);
      |       ^~~~~
      |       ;
samu: subcommand failed
 * ERROR: net-libs/libvncserver-0.9.14::gentoo failed (compile phase)
botovq commented
botovq commented
orbea commented

Yea, I can confirm that didn't work while your second suggestion does.

diff --git a/include/openssl/crypto.h b/include/openssl/crypto.h
index 066f624..98a2b06 100644
--- a/include/openssl/crypto.h
+++ b/include/openssl/crypto.h
@@ -132,6 +132,10 @@
 extern "C" {
 #endif
 
+#ifndef __dead
+#define __dead
+#endif
+
 /* Backward compatibility to SSLeay */
 /* This is more to be used to check the correct DLL is being used
  * in the MS world. */
@@ -488,7 +492,7 @@ typedef int *CRYPTO_MEM_LEAK_CB(unsigned long, const char *, int, int, void *);
 int CRYPTO_mem_leaks_cb(CRYPTO_MEM_LEAK_CB *cb);
 
 /* die if we have to */
-void OpenSSLDie(const char *file, int line, const char *assertion);
+__dead void OpenSSLDie(const char *file, int line, const char *assertion);
 #define OPENSSL_assert(e)       (void)((e) ? 0 : (OpenSSLDie(__FILE__, __LINE__, #e),1))
 
 uint64_t OPENSSL_cpu_caps(void);

However I share your sentiment that it seems a bit silly, but I am not sure if its bad enough to not silence warnings even if they are false positives? I'll leave it the best judgement of the libressl developers, feel free to close this issue if you feel that is best.