From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web09.5912.1664356788713124317 for ; Wed, 28 Sep 2022 02:19:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=H4llsfH1; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 96E4F61D9C for ; Wed, 28 Sep 2022 09:19:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09CD0C43470 for ; Wed, 28 Sep 2022 09:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664356787; bh=Cdh53Xev/t4lAPWwzqpf32ynC0bv4RM6ZdJWRAlPGoE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=H4llsfH1USsBxq/ZrUurIQF7JyQ+HRTljLJnYgspwnT3TUdlpyr9Yomykn3V++rY8 foWTkYF6UvaSBW5fYnP8C/YfkpadN3KmlB3kwj6WKTHdhAAhfiW8CVVJ/UOuRn3ti4 TVurPGkB/U4BO1Hda0FgYRuIgBvLfoOun8m3EPzGvAHH3uX9C9rC1Pe1Gcngrinxx/ YTJKdXyOfjfv0F+r6i0RhDHBlhLTS6B16UAuYgHOiIf80t/lIRiCziQziQC3SD6EpT IsXjfsESR+SsfzOCfOoatTnZ5qZwhIVIKQi+79YGvUkoCq/JCzInW9WSHuKQZUlKfL RHdSVPZ44M8Sg== Received: by mail-lj1-f180.google.com with SMTP id h3so13700537lja.1 for ; Wed, 28 Sep 2022 02:19:46 -0700 (PDT) X-Gm-Message-State: ACrzQf1CQcTGSVQgRg7kK7d7NbGiDEr2ixGK2FTd6j68xlx3abxjB7ma mytmOUeblr5tknmSXt+75FW0/Dbohrdee7ec7O4= X-Google-Smtp-Source: AMsMyM6gSVQtEP6boa4MeARjhisVXW4sZd/IqL0toxBD9JjmJp0C2N3zm8MjZOqeEiedLF77geYCBMeExj+oKCitiBI= X-Received: by 2002:a2e:7314:0:b0:26a:ca18:60eb with SMTP id o20-20020a2e7314000000b0026aca1860ebmr10606781ljc.69.1664356784974; Wed, 28 Sep 2022 02:19:44 -0700 (PDT) MIME-Version: 1.0 References: <20220928074924.528583-1-yuanyu@google.com> <20220928074924.528583-2-yuanyu@google.com> In-Reply-To: <20220928074924.528583-2-yuanyu@google.com> From: "Ard Biesheuvel" Date: Wed, 28 Sep 2022 11:19:33 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 1/1] CryptoPkg: Fix integer overflow To: Yuan Yu , Jiewen Yao , Jian J Wang Cc: devel@edk2.groups.io, Jordan Justen , Laszlo Ersek , Anthony Perard , Julien Grall Content-Type: text/plain; charset="UTF-8" (cc Jiewen and Jian) On Wed, 28 Sept 2022 at 09:49, Yuan Yu wrote: > > SECSPERDAY is 86400 which exceeds the limit of a UINT16 which is 65536. > Therefore DayRemainder cannot use UINT16. This patch makes it UINT32. > > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Anthony Perard > Cc: Julien Grall > > Signed-off-by: Yuan Yu Hello Yuan, Thanks for the patch. Reviewed-by: Ard Biesheuvel Since this is a CryptoPkg change, the CryptoPkg maintainers are ultimately the ones that need to accept it, so I have added them to cc. > --- > CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c > index 7d28446d4b5c..bf8a5325817f 100644 > --- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c > +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c > @@ -118,7 +118,7 @@ gmtime ( > { > struct tm *GmTime; > UINT16 DayNo; > - UINT16 DayRemainder; > + UINT32 DayRemainder; > time_t Year; > time_t YearNo; > UINT16 TotalDays; > @@ -136,7 +136,7 @@ gmtime ( > ZeroMem ((VOID *)GmTime, (UINTN)sizeof (struct tm)); > > DayNo = (UINT16)(*timer / SECSPERDAY); > - DayRemainder = (UINT16)(*timer % SECSPERDAY); > + DayRemainder = (UINT32)(*timer % SECSPERDAY); > > GmTime->tm_sec = (int)(DayRemainder % SECSPERMIN); > GmTime->tm_min = (int)((DayRemainder % SECSPERHOUR) / SECSPERMIN); > -- > 2.37.3.998.g577e59143f-goog >