public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error
@ 2017-10-17 19:16 Laszlo Ersek
  2017-10-17 19:28 ` Ard Biesheuvel
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Laszlo Ersek @ 2017-10-17 19:16 UTC (permalink / raw)
  To: edk2-devel-01
  Cc: Ard Biesheuvel, Chao Zhang, Gary Lin, Leif Lindholm, Long Qin

Commit 53c6ff180327 ("SecurityPkg:AuthVariableLib:Implement ECR1707 for
Private Auth Variable", 2017-09-12) introduced the following build
failure under several GCC toolchain versions:

> SecurityPkg/Library/AuthVariableLib/AuthService.c: In function
> 'CalculatePrivAuthVarSignChainSHA256Digest':
> SecurityPkg/Library/AuthVariableLib/AuthService.c:1567:58: error:
> pointer targets in passing argument 3 of 'X509GetCommonName' differ in
> signedness [-Werror=pointer-sign]
>    Status = X509GetCommonName(SignerCert, SignerCertSize, CertCommonName, &CertCommonNameSize);
>                                                           ^~~~~~~~~~~~~~
> In file included from
> SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h:34:0,
>                  from
>                  SecurityPkg/Library/AuthVariableLib/AuthService.c:32:
> CryptoPkg/Include/Library/BaseCryptLib.h:2202:1: note: expected 'CHAR8 *
> {aka char *}' but argument is of type 'UINT8 * {aka unsigned char *}'
>  X509GetCommonName (
>  ^~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors

Fix it by changing the type of "CertCommonName" to array-of-CHAR8.

Locations where "CertCommonName" is used in the
CalculatePrivAuthVarSignChainSHA256Digest() function:

- it is taken the size of -- not impacted by this patch;

- passed to X509GetCommonName() as an argument -- the patch fixes the
  build error;

- passed to Sha256Update() as argument for "IN CONST VOID  *Data" -- not
  impacted by the patch;

- passed to AsciiStrLen() as argument -- drop the now-superfluous explicit
  cast.

Since we are touching the Sha256Update() function call, fix the coding
style too:

- the line is overlong, so break each argument to its own line;

- insert a space between "AsciiStrLen" and the opening paren "(".

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Long Qin <qin.long@intel.com>
Reported-by: Gary Lin <glin@suse.com>
Suggested-by: Gary Lin <glin@suse.com>
Suggested-by: Long Qin <qin.long@intel.com>
Fixes: 53c6ff18032737fabb644a9e0c781d91a6830248
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
    The GCC build has been broken for too long by now; I'll push the patch
    as soon as I get any Reviewed-by.

 SecurityPkg/Library/AuthVariableLib/AuthService.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c
index 7188ff600823..2966811fa7ff 100644
--- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
+++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
@@ -1554,7 +1554,7 @@ CalculatePrivAuthVarSignChainSHA256Digest(
 {
   UINT8                   *TbsCert;
   UINTN                   TbsCertSize;
-  UINT8                   CertCommonName[128];
+  CHAR8                   CertCommonName[128];
   UINTN                   CertCommonNameSize;
   BOOLEAN                 CryptoStatus;
   EFI_STATUS              Status;
@@ -1590,7 +1590,11 @@ CalculatePrivAuthVarSignChainSHA256Digest(
   //
   // '\0' is forced in CertCommonName. No overflow issue
   //
-  CryptoStatus = Sha256Update (mHashCtx, CertCommonName, AsciiStrLen((CHAR8 *)CertCommonName));
+  CryptoStatus = Sha256Update (
+                   mHashCtx,
+                   CertCommonName,
+                   AsciiStrLen (CertCommonName)
+                   );
   if (!CryptoStatus) {
     return EFI_ABORTED;
   }
-- 
2.14.1.3.gb7cf6e02401b



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

* Re: [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error
  2017-10-17 19:16 [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error Laszlo Ersek
@ 2017-10-17 19:28 ` Ard Biesheuvel
  2017-10-17 19:42 ` Leif Lindholm
  2017-10-17 19:54 ` Laszlo Ersek
  2 siblings, 0 replies; 5+ messages in thread
From: Ard Biesheuvel @ 2017-10-17 19:28 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-01, Chao Zhang, Gary Lin, Leif Lindholm, Long Qin

On 17 October 2017 at 20:16, Laszlo Ersek <lersek@redhat.com> wrote:
> Commit 53c6ff180327 ("SecurityPkg:AuthVariableLib:Implement ECR1707 for
> Private Auth Variable", 2017-09-12) introduced the following build
> failure under several GCC toolchain versions:
>
>> SecurityPkg/Library/AuthVariableLib/AuthService.c: In function
>> 'CalculatePrivAuthVarSignChainSHA256Digest':
>> SecurityPkg/Library/AuthVariableLib/AuthService.c:1567:58: error:
>> pointer targets in passing argument 3 of 'X509GetCommonName' differ in
>> signedness [-Werror=pointer-sign]
>>    Status = X509GetCommonName(SignerCert, SignerCertSize, CertCommonName, &CertCommonNameSize);
>>                                                           ^~~~~~~~~~~~~~
>> In file included from
>> SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h:34:0,
>>                  from
>>                  SecurityPkg/Library/AuthVariableLib/AuthService.c:32:
>> CryptoPkg/Include/Library/BaseCryptLib.h:2202:1: note: expected 'CHAR8 *
>> {aka char *}' but argument is of type 'UINT8 * {aka unsigned char *}'
>>  X509GetCommonName (
>>  ^~~~~~~~~~~~~~~~~
>> cc1: all warnings being treated as errors
>
> Fix it by changing the type of "CertCommonName" to array-of-CHAR8.
>
> Locations where "CertCommonName" is used in the
> CalculatePrivAuthVarSignChainSHA256Digest() function:
>
> - it is taken the size of -- not impacted by this patch;
>
> - passed to X509GetCommonName() as an argument -- the patch fixes the
>   build error;
>
> - passed to Sha256Update() as argument for "IN CONST VOID  *Data" -- not
>   impacted by the patch;
>
> - passed to AsciiStrLen() as argument -- drop the now-superfluous explicit
>   cast.
>
> Since we are touching the Sha256Update() function call, fix the coding
> style too:
>
> - the line is overlong, so break each argument to its own line;
>
> - insert a space between "AsciiStrLen" and the opening paren "(".
>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Long Qin <qin.long@intel.com>
> Reported-by: Gary Lin <glin@suse.com>
> Suggested-by: Gary Lin <glin@suse.com>
> Suggested-by: Long Qin <qin.long@intel.com>
> Fixes: 53c6ff18032737fabb644a9e0c781d91a6830248
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>
> Notes:
>     The GCC build has been broken for too long by now; I'll push the patch
>     as soon as I get any Reviewed-by.
>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>


>  SecurityPkg/Library/AuthVariableLib/AuthService.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c
> index 7188ff600823..2966811fa7ff 100644
> --- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
> +++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
> @@ -1554,7 +1554,7 @@ CalculatePrivAuthVarSignChainSHA256Digest(
>  {
>    UINT8                   *TbsCert;
>    UINTN                   TbsCertSize;
> -  UINT8                   CertCommonName[128];
> +  CHAR8                   CertCommonName[128];
>    UINTN                   CertCommonNameSize;
>    BOOLEAN                 CryptoStatus;
>    EFI_STATUS              Status;
> @@ -1590,7 +1590,11 @@ CalculatePrivAuthVarSignChainSHA256Digest(
>    //
>    // '\0' is forced in CertCommonName. No overflow issue
>    //
> -  CryptoStatus = Sha256Update (mHashCtx, CertCommonName, AsciiStrLen((CHAR8 *)CertCommonName));
> +  CryptoStatus = Sha256Update (
> +                   mHashCtx,
> +                   CertCommonName,
> +                   AsciiStrLen (CertCommonName)
> +                   );
>    if (!CryptoStatus) {
>      return EFI_ABORTED;
>    }
> --
> 2.14.1.3.gb7cf6e02401b
>


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

* Re: [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error
  2017-10-17 19:16 [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error Laszlo Ersek
  2017-10-17 19:28 ` Ard Biesheuvel
@ 2017-10-17 19:42 ` Leif Lindholm
  2017-10-17 19:54 ` Laszlo Ersek
  2 siblings, 0 replies; 5+ messages in thread
From: Leif Lindholm @ 2017-10-17 19:42 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel-01, Ard Biesheuvel, Chao Zhang, Gary Lin, Long Qin

On Tue, Oct 17, 2017 at 09:16:46PM +0200, Laszlo Ersek wrote:
> Commit 53c6ff180327 ("SecurityPkg:AuthVariableLib:Implement ECR1707 for
> Private Auth Variable", 2017-09-12) introduced the following build
> failure under several GCC toolchain versions:
> 
> > SecurityPkg/Library/AuthVariableLib/AuthService.c: In function
> > 'CalculatePrivAuthVarSignChainSHA256Digest':
> > SecurityPkg/Library/AuthVariableLib/AuthService.c:1567:58: error:
> > pointer targets in passing argument 3 of 'X509GetCommonName' differ in
> > signedness [-Werror=pointer-sign]
> >    Status = X509GetCommonName(SignerCert, SignerCertSize, CertCommonName, &CertCommonNameSize);
> >                                                           ^~~~~~~~~~~~~~
> > In file included from
> > SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h:34:0,
> >                  from
> >                  SecurityPkg/Library/AuthVariableLib/AuthService.c:32:
> > CryptoPkg/Include/Library/BaseCryptLib.h:2202:1: note: expected 'CHAR8 *
> > {aka char *}' but argument is of type 'UINT8 * {aka unsigned char *}'
> >  X509GetCommonName (
> >  ^~~~~~~~~~~~~~~~~
> > cc1: all warnings being treated as errors
> 
> Fix it by changing the type of "CertCommonName" to array-of-CHAR8.
> 
> Locations where "CertCommonName" is used in the
> CalculatePrivAuthVarSignChainSHA256Digest() function:
> 
> - it is taken the size of -- not impacted by this patch;
> 
> - passed to X509GetCommonName() as an argument -- the patch fixes the
>   build error;
> 
> - passed to Sha256Update() as argument for "IN CONST VOID  *Data" -- not
>   impacted by the patch;
> 
> - passed to AsciiStrLen() as argument -- drop the now-superfluous explicit
>   cast.
> 
> Since we are touching the Sha256Update() function call, fix the coding
> style too:
> 
> - the line is overlong, so break each argument to its own line;
> 
> - insert a space between "AsciiStrLen" and the opening paren "(".
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Long Qin <qin.long@intel.com>
> Reported-by: Gary Lin <glin@suse.com>
> Suggested-by: Gary Lin <glin@suse.com>
> Suggested-by: Long Qin <qin.long@intel.com>
> Fixes: 53c6ff18032737fabb644a9e0c781d91a6830248
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

On the one hand, I am wondering whether that API _should_ be using
UINT8 rather than an architecture-dependent type.
On the other hand, that would be a much bigger change, and master is
currently broken.

Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>

/
    Leif

> ---
> 
> Notes:
>     The GCC build has been broken for too long by now; I'll push the patch
>     as soon as I get any Reviewed-by.
> 
>  SecurityPkg/Library/AuthVariableLib/AuthService.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c
> index 7188ff600823..2966811fa7ff 100644
> --- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
> +++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
> @@ -1554,7 +1554,7 @@ CalculatePrivAuthVarSignChainSHA256Digest(
>  {
>    UINT8                   *TbsCert;
>    UINTN                   TbsCertSize;
> -  UINT8                   CertCommonName[128];
> +  CHAR8                   CertCommonName[128];
>    UINTN                   CertCommonNameSize;
>    BOOLEAN                 CryptoStatus;
>    EFI_STATUS              Status;
> @@ -1590,7 +1590,11 @@ CalculatePrivAuthVarSignChainSHA256Digest(
>    //
>    // '\0' is forced in CertCommonName. No overflow issue
>    //
> -  CryptoStatus = Sha256Update (mHashCtx, CertCommonName, AsciiStrLen((CHAR8 *)CertCommonName));
> +  CryptoStatus = Sha256Update (
> +                   mHashCtx,
> +                   CertCommonName,
> +                   AsciiStrLen (CertCommonName)
> +                   );
>    if (!CryptoStatus) {
>      return EFI_ABORTED;
>    }
> -- 
> 2.14.1.3.gb7cf6e02401b
> 


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

* Re: [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error
  2017-10-17 19:16 [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error Laszlo Ersek
  2017-10-17 19:28 ` Ard Biesheuvel
  2017-10-17 19:42 ` Leif Lindholm
@ 2017-10-17 19:54 ` Laszlo Ersek
  2017-10-18  6:46   ` Gary Lin
  2 siblings, 1 reply; 5+ messages in thread
From: Laszlo Ersek @ 2017-10-17 19:54 UTC (permalink / raw)
  To: edk2-devel-01
  Cc: Long Qin, Gary Lin, Leif Lindholm, Chao Zhang, Ard Biesheuvel

On 10/17/17 21:16, Laszlo Ersek wrote:
> Commit 53c6ff180327 ("SecurityPkg:AuthVariableLib:Implement ECR1707 for
> Private Auth Variable", 2017-09-12) introduced the following build
> failure under several GCC toolchain versions:
> 
>> SecurityPkg/Library/AuthVariableLib/AuthService.c: In function
>> 'CalculatePrivAuthVarSignChainSHA256Digest':
>> SecurityPkg/Library/AuthVariableLib/AuthService.c:1567:58: error:
>> pointer targets in passing argument 3 of 'X509GetCommonName' differ in
>> signedness [-Werror=pointer-sign]
>>    Status = X509GetCommonName(SignerCert, SignerCertSize, CertCommonName, &CertCommonNameSize);
>>                                                           ^~~~~~~~~~~~~~
>> In file included from
>> SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h:34:0,
>>                  from
>>                  SecurityPkg/Library/AuthVariableLib/AuthService.c:32:
>> CryptoPkg/Include/Library/BaseCryptLib.h:2202:1: note: expected 'CHAR8 *
>> {aka char *}' but argument is of type 'UINT8 * {aka unsigned char *}'
>>  X509GetCommonName (
>>  ^~~~~~~~~~~~~~~~~
>> cc1: all warnings being treated as errors
> 
> Fix it by changing the type of "CertCommonName" to array-of-CHAR8.
> 
> Locations where "CertCommonName" is used in the
> CalculatePrivAuthVarSignChainSHA256Digest() function:
> 
> - it is taken the size of -- not impacted by this patch;
> 
> - passed to X509GetCommonName() as an argument -- the patch fixes the
>   build error;
> 
> - passed to Sha256Update() as argument for "IN CONST VOID  *Data" -- not
>   impacted by the patch;
> 
> - passed to AsciiStrLen() as argument -- drop the now-superfluous explicit
>   cast.
> 
> Since we are touching the Sha256Update() function call, fix the coding
> style too:
> 
> - the line is overlong, so break each argument to its own line;
> 
> - insert a space between "AsciiStrLen" and the opening paren "(".
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Chao Zhang <chao.b.zhang@intel.com>
> Cc: Gary Lin <glin@suse.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Long Qin <qin.long@intel.com>
> Reported-by: Gary Lin <glin@suse.com>
> Suggested-by: Gary Lin <glin@suse.com>
> Suggested-by: Long Qin <qin.long@intel.com>
> Fixes: 53c6ff18032737fabb644a9e0c781d91a6830248
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
> 
> Notes:
>     The GCC build has been broken for too long by now; I'll push the patch
>     as soon as I get any Reviewed-by.
> 
>  SecurityPkg/Library/AuthVariableLib/AuthService.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c
> index 7188ff600823..2966811fa7ff 100644
> --- a/SecurityPkg/Library/AuthVariableLib/AuthService.c
> +++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c
> @@ -1554,7 +1554,7 @@ CalculatePrivAuthVarSignChainSHA256Digest(
>  {
>    UINT8                   *TbsCert;
>    UINTN                   TbsCertSize;
> -  UINT8                   CertCommonName[128];
> +  CHAR8                   CertCommonName[128];
>    UINTN                   CertCommonNameSize;
>    BOOLEAN                 CryptoStatus;
>    EFI_STATUS              Status;
> @@ -1590,7 +1590,11 @@ CalculatePrivAuthVarSignChainSHA256Digest(
>    //
>    // '\0' is forced in CertCommonName. No overflow issue
>    //
> -  CryptoStatus = Sha256Update (mHashCtx, CertCommonName, AsciiStrLen((CHAR8 *)CertCommonName));
> +  CryptoStatus = Sha256Update (
> +                   mHashCtx,
> +                   CertCommonName,
> +                   AsciiStrLen (CertCommonName)
> +                   );
>    if (!CryptoStatus) {
>      return EFI_ABORTED;
>    }
> 

Awesome; in such a short time, I got *two* R-b's. :)

Commit 11b74aa4724a.

Thanks!
Laszlo


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

* Re: [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error
  2017-10-17 19:54 ` Laszlo Ersek
@ 2017-10-18  6:46   ` Gary Lin
  0 siblings, 0 replies; 5+ messages in thread
From: Gary Lin @ 2017-10-18  6:46 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel-01, Long Qin, Leif Lindholm, Chao Zhang,
	Ard Biesheuvel

On Tue, Oct 17, 2017 at 09:54:04PM +0200, Laszlo Ersek wrote:
> On 10/17/17 21:16, Laszlo Ersek wrote:
> > Commit 53c6ff180327 ("SecurityPkg:AuthVariableLib:Implement ECR1707 for
> > Private Auth Variable", 2017-09-12) introduced the following build
> > failure under several GCC toolchain versions:
> > 
-->8--
> 
> Awesome; in such a short time, I got *two* R-b's. :)
> 
> Commit 11b74aa4724a.
Thanks for pushing the fix!

Gary Lin


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

end of thread, other threads:[~2017-10-18  6:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-17 19:16 [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error Laszlo Ersek
2017-10-17 19:28 ` Ard Biesheuvel
2017-10-17 19:42 ` Leif Lindholm
2017-10-17 19:54 ` Laszlo Ersek
2017-10-18  6:46   ` Gary Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox