lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20231218024631.735225-1-a869920004@gmail.com>
Date: Mon, 18 Dec 2023 02:46:31 +0000
From: Yusong Gao <a869920004@...il.com>
To: jarkko@...nel.org
Cc: a869920004@...il.com,
	davem@...emloft.net,
	dhowells@...hat.com,
	dimitri.ledkov@...onical.com,
	dwmw2@...radead.org,
	herbert@...dor.apana.org.au,
	juergh@...ton.me,
	keyrings@...r.kernel.org,
	linux-crypto@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	lists@...ience.com,
	zohar@...ux.ibm.com
Subject: Re: [PATCH v5 RESEND] sign-file: Fix incorrect return values check

On Thu, Dec 14, 2023 at 2:25 AM Jarkko Sakkinen <jarkko@...nel.org>
wrote:
>
> On Wed Dec 13, 2023 at 4:44 AM EET, Yusong Gao wrote:
> > There are some wrong return values check in sign-file when call
> > OpenSSL
> > API. The ERR() check cond is wrong because of the program only check
> > the
> > return value is < 0 which ignored the return val is 0. For example:
> > 1. CMS_final() return 1 for success or 0 for failure.
> > 2. i2d_CMS_bio_stream() returns 1 for success or 0 for failure.
> > 3. i2d_TYPEbio() return 1 for success and 0 for failure.
> q
> >
> > Link: https://www.openssl.org/docs/manmaster/man3/
> > Fixes: e5a2e3c84782 ("scripts/sign-file.c: Add support for signing
> > with a raw signature")

Yeah, thanks for point out, I get it. 
I will add it when next time I submit patches.

>
> Given that:
>
> $ git describe --contains  e5a2e3c84782
> v4.6-rc1~127^2^2~14
>
> Should have also:
>
> Cc: stable@...r.kernel.org # v4.6+
>
>
> > Signed-off-by: Yusong Gao <a869920004@...il.com>
> > Reviewed-by: Juerg Haefliger <juerg.haefliger@...onical.com>
> > ---
> > V5: No change.
> > V4: Change to more strict check mode.
> > V3: Removed redundant empty line.
> > V1, V2: Clarify the description of git message.
> > ---
> >  scripts/sign-file.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/scripts/sign-file.c b/scripts/sign-file.c
> > index 598ef5465f82..3edb156ae52c 100644
> > --- a/scripts/sign-file.c
> > +++ b/scripts/sign-file.c
> > @@ -322,7 +322,7 @@ int main(int argc, char **argv)
> >                                    CMS_NOSMIMECAP | use_keyid |
> >                                    use_signed_attrs),
> >                   "CMS_add1_signer");
> > -             ERR(CMS_final(cms, bm, NULL, CMS_NOCERTS | CMS_BINARY)
> > < 0,
> > +             ERR(CMS_final(cms, bm, NULL, CMS_NOCERTS | CMS_BINARY)
> > != 1,
> >                   "CMS_final");
> > 
> >  #else
> > @@ -341,10 +341,10 @@ int main(int argc, char **argv)
> >                       b = BIO_new_file(sig_file_name, "wb");
> >                       ERR(!b, "%s", sig_file_name);
> >  #ifndef USE_PKCS7
> > -                     ERR(i2d_CMS_bio_stream(b, cms, NULL, 0) < 0,
> > +                     ERR(i2d_CMS_bio_stream(b, cms, NULL, 0) != 1,
> >                           "%s", sig_file_name);
> >  #else
> > -                     ERR(i2d_PKCS7_bio(b, pkcs7) < 0,
> > +                     ERR(i2d_PKCS7_bio(b, pkcs7) != 1,
> >                           "%s", sig_file_name);
> >  #endif
> >                       BIO_free(b);
> > @@ -374,9 +374,9 @@ int main(int argc, char **argv)
> > 
> >       if (!raw_sig) {
> >  #ifndef USE_PKCS7
> > -             ERR(i2d_CMS_bio_stream(bd, cms, NULL, 0) < 0, "%s",
> > dest_name);
> > +             ERR(i2d_CMS_bio_stream(bd, cms, NULL, 0) != 1, "%s",
> > dest_name);
> >  #else
> > -             ERR(i2d_PKCS7_bio(bd, pkcs7) < 0, "%s", dest_name);
> > +             ERR(i2d_PKCS7_bio(bd, pkcs7) != 1, "%s", dest_name);
> >  #endif
> >       } else {
> >               BIO *b;
> > @@ -396,7 +396,7 @@ int main(int argc, char **argv)
> >       ERR(BIO_write(bd, &sig_info, sizeof(sig_info)) < 0, "%s",
> >       dest_name);
> >       ERR(BIO_write(bd, magic_number, sizeof(magic_number) - 1) < 0,
> >       "%s", dest_name);
> > 
> > -     ERR(BIO_free(bd) < 0, "%s", dest_name);
> > +     ERR(BIO_free(bd) != 1, "%s", dest_name);
> > 
> >       /* Finally, if we're signing in place, replace the original.
> >       */
> >       if (replace_orig)
>
>
> BR, Jarkko


BR, Yusong Gao

Powered by blists - more mailing lists