public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v3 0/5] Fix undefined behavior in signed left shift
@ 2017-04-12  1:52 Hao Wu
  2017-04-12  1:52 ` [PATCH v3 1/5] MdeModulePkg/ScsiDiskDxe: " Hao Wu
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Hao Wu @ 2017-04-12  1:52 UTC (permalink / raw)
  To: edk2-devel, guoheyi; +Cc: Hao Wu, Feng Tian

After searching the whole code base, more cases are found related with:
'LastLba3 << 24'

Send a new patch series (V3 based on the patch for ScsiDisk) to fix the
suspicious undefined behavior in signed left shift.

Cc: Feng Tian <feng.tian@intel.com>

Hao Wu (5):
  MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift
  MdeModulePkg/IdeBusPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UfsBlkIoPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UsbBotPei: Fix undefined behavior in signed left shift
  IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in signed left shift

 IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c  | 6 +++---
 MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c         | 4 ++--
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c       | 4 ++--
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c | 6 +++---
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c          | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)

-- 
2.12.0.windows.1



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

* [PATCH v3 1/5] MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift
  2017-04-12  1:52 [PATCH v3 0/5] Fix undefined behavior in signed left shift Hao Wu
@ 2017-04-12  1:52 ` Hao Wu
  2017-04-12  1:52 ` [PATCH v3 2/5] MdeModulePkg/IdeBusPei: " Hao Wu
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Hao Wu @ 2017-04-12  1:52 UTC (permalink / raw)
  To: edk2-devel, guoheyi; +Cc: Hao Wu

In function GetMediaInfo(), the following expression:
ScsiDiskDevice->BlkIo.Media->LastBlock =  (Capacity10->LastLba3 << 24) |
                                          (Capacity10->LastLba2 << 16) |
                                          (Capacity10->LastLba1 << 8)  |
                                           Capacity10->LastLba0;
will involve undefined behavior in signed left shift operations.

Since Capacity10->LastLbaX is of type UINT8, and
ScsiDiskDevice->BlkIo.Media->LastBlock is of type UINT64. Therefore,
Capacity10->LastLbaX will be promoted to int (32 bits, signed) first,
and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Capacity10->LastLba3 is 1, (Capacity10->LastLba3 << 24)
will be out of the range within int type. The undefined behavior of the
signed left shift will lead to a potential of setting the high 32 bits
of ScsiDiskDevice->BlkIo.Media->LastBlock to 1 during the cast from type
int to type UINT64.

This commit will add an explicit UINT32 type cast for
Capacity10->LastLba3 to resolve this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
index b5eff25b9b..2289f20152 100644
--- a/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
+++ b/MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c
@@ -1,7 +1,7 @@
 /** @file
   SCSI disk driver that layers on every SCSI IO protocol in the system.
 
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -2754,7 +2754,7 @@ GetMediaInfo (
   UINT8       *Ptr;
 
   if (!ScsiDiskDevice->Cdb16Byte) {
-    ScsiDiskDevice->BlkIo.Media->LastBlock =  (Capacity10->LastLba3 << 24) |
+    ScsiDiskDevice->BlkIo.Media->LastBlock =  ((UINT32) Capacity10->LastLba3 << 24) |
                                               (Capacity10->LastLba2 << 16) |
                                               (Capacity10->LastLba1 << 8)  |
                                                Capacity10->LastLba0;
-- 
2.12.0.windows.1



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

* [PATCH v3 2/5] MdeModulePkg/IdeBusPei: Fix undefined behavior in signed left shift
  2017-04-12  1:52 [PATCH v3 0/5] Fix undefined behavior in signed left shift Hao Wu
  2017-04-12  1:52 ` [PATCH v3 1/5] MdeModulePkg/ScsiDiskDxe: " Hao Wu
@ 2017-04-12  1:52 ` Hao Wu
  2017-04-12  1:52 ` [PATCH v3 3/5] MdeModulePkg/UfsBlkIoPei: " Hao Wu
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Hao Wu @ 2017-04-12  1:52 UTC (permalink / raw)
  To: edk2-devel, guoheyi; +Cc: Hao Wu, Feng Tian

In function ReadCapacity(), the following expression:
MediaInfo->LastBlock = (Data.LastLba3 << 24) |
  (Data.LastLba2 << 16) |
  (Data.LastLba1 << 8) |
  Data.LastLba0;

(There is also a similar case in this function.)

will involve undefined behavior in signed left shift operations.

Since Data.LastLbaX is of type UINT8, and MediaInfo->LastBlock is of type
UINTN. Therefore, Data.LastLbaX will be promoted to int (32 bits, signed)
first, and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Data.LastLba3 is 1, (Data.LastLba3 << 24) will be out of
the range within int type. The undefined behavior of the signed left shift
will lead to a potential of setting the high 32 bits of
MediaInfo->LastBlock to 1 during the cast from type int to type UINT64
for X64 builds.

This commit will add an explicit UINT32 type cast for Data.LastLba3 to
resolve this issue.

Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c b/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c
index b1ab34d597..58bef161fb 100644
--- a/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c
+++ b/MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c
@@ -2140,7 +2140,7 @@ ReadCapacity (
 
     if (MediaInfo->DeviceType == IdeCDROM) {
 
-      MediaInfo->LastBlock    = (Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
+      MediaInfo->LastBlock    = ((UINT32) Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
       MediaInfo->MediaPresent = TRUE;
       //
       // Because the user data portion in the sector of the Data CD supported
@@ -2161,7 +2161,7 @@ ReadCapacity (
         MediaInfo2->MediaPresent = FALSE;
         MediaInfo2->LastBlock    = 0;
       } else {
-        MediaInfo->LastBlock = (FormatData.LastLba3 << 24) |
+        MediaInfo->LastBlock = ((UINT32) FormatData.LastLba3 << 24) |
           (FormatData.LastLba2 << 16) |
           (FormatData.LastLba1 << 8) |
           FormatData.LastLba0;
-- 
2.12.0.windows.1



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

* [PATCH v3 3/5] MdeModulePkg/UfsBlkIoPei: Fix undefined behavior in signed left shift
  2017-04-12  1:52 [PATCH v3 0/5] Fix undefined behavior in signed left shift Hao Wu
  2017-04-12  1:52 ` [PATCH v3 1/5] MdeModulePkg/ScsiDiskDxe: " Hao Wu
  2017-04-12  1:52 ` [PATCH v3 2/5] MdeModulePkg/IdeBusPei: " Hao Wu
@ 2017-04-12  1:52 ` Hao Wu
  2017-04-12  1:52 ` [PATCH v3 4/5] MdeModulePkg/UsbBotPei: " Hao Wu
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Hao Wu @ 2017-04-12  1:52 UTC (permalink / raw)
  To: edk2-devel, guoheyi; +Cc: Hao Wu, Feng Tian

In function UfsBlockIoPeimGetMediaInfo(), the following expression:
Private->Media[DeviceIndex].LastBlock  = (Capacity16.LastLba3 << 24) |
  (Capacity16.LastLba2 << 16) |
  (Capacity16.LastLba1 << 8) |
  Capacity16.LastLba0;

(There is also a similar case in this function.)

will involve undefined behavior in signed left shift operations.

Since Capacity16.LastLbaX is of type UINT8, and
Private->Media[DeviceIndex].LastBlock is of type UINT64. Therefore,
Capacity16.LastLbaX will be promoted to int (32 bits, signed) first, and
then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Capacity16.LastLba3 is 1, (Capacity16.LastLba3 << 24) will
be out of the range within int type. The undefined behavior of the signed
left shift will lead to a potential of setting the high 32 bits of
Private->Media[DeviceIndex].LastBlock to 1 during the cast from type int
to type UINT64.

This commit will add an explicit UINT32 type cast for Capacity16.LastLba3
to resolve this issue.

Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
index cd7c59edae..ddeee3e1bc 100644
--- a/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
+++ b/MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -737,11 +737,11 @@ UfsBlockIoPeimGetMediaInfo (
     if (EFI_ERROR (Status)) {
       return EFI_DEVICE_ERROR;
     }
-    Private->Media[DeviceIndex].LastBlock  = (Capacity16.LastLba3 << 24) | (Capacity16.LastLba2 << 16) | (Capacity16.LastLba1 << 8) | Capacity16.LastLba0;
+    Private->Media[DeviceIndex].LastBlock  = ((UINT32)Capacity16.LastLba3 << 24) | (Capacity16.LastLba2 << 16) | (Capacity16.LastLba1 << 8) | Capacity16.LastLba0;
     Private->Media[DeviceIndex].LastBlock |= LShiftU64 ((UINT64)Capacity16.LastLba7, 56) | LShiftU64((UINT64)Capacity16.LastLba6, 48) | LShiftU64 ((UINT64)Capacity16.LastLba5, 40) | LShiftU64 ((UINT64)Capacity16.LastLba4, 32);
     Private->Media[DeviceIndex].BlockSize  = (Capacity16.BlockSize3 << 24) | (Capacity16.BlockSize2 << 16) | (Capacity16.BlockSize1 << 8) | Capacity16.BlockSize0;
   } else {
-    Private->Media[DeviceIndex].LastBlock  = (Capacity.LastLba3 << 24) | (Capacity.LastLba2 << 16) | (Capacity.LastLba1 << 8) | Capacity.LastLba0;
+    Private->Media[DeviceIndex].LastBlock  = ((UINT32)Capacity.LastLba3 << 24) | (Capacity.LastLba2 << 16) | (Capacity.LastLba1 << 8) | Capacity.LastLba0;
     Private->Media[DeviceIndex].BlockSize  = (Capacity.BlockSize3 << 24) | (Capacity.BlockSize2 << 16) | (Capacity.BlockSize1 << 8) | Capacity.BlockSize0;
   }
 
-- 
2.12.0.windows.1



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

* [PATCH v3 4/5] MdeModulePkg/UsbBotPei: Fix undefined behavior in signed left shift
  2017-04-12  1:52 [PATCH v3 0/5] Fix undefined behavior in signed left shift Hao Wu
                   ` (2 preceding siblings ...)
  2017-04-12  1:52 ` [PATCH v3 3/5] MdeModulePkg/UfsBlkIoPei: " Hao Wu
@ 2017-04-12  1:52 ` Hao Wu
  2017-04-12  1:52 ` [PATCH v3 5/5] IntelFWMdlPkg/IdeBusDxe: " Hao Wu
  2017-04-12  1:53 ` [PATCH v3 0/5] " Tian, Feng
  5 siblings, 0 replies; 8+ messages in thread
From: Hao Wu @ 2017-04-12  1:52 UTC (permalink / raw)
  To: edk2-devel, guoheyi; +Cc: Hao Wu, Feng Tian

In function PeiUsbReadCapacity(), the following expression:
LastBlock = (Data.LastLba3 << 24) |
  (Data.LastLba2 << 16) |
  (Data.LastLba1 << 8) |
  Data.LastLba0;

(There is also a similar case in function PeiUsbReadFormattedCapacity().)

will involve undefined behavior in signed left shift operations.

Since Data.LastLbaX is of type UINT8, they will be promoted to int (32
bits, signed) first, and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Data.LastLba3 is 1, (Data.LastLba3 << 24) will be out of
the range within int type. The undefined behavior of the signed left shift
might incur potential issues.

This commit will add an explicit UINT32 type cast for Data.LastLba3 to
refine the codes.

Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
index eaad626d61..72bde756eb 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
@@ -1,7 +1,7 @@
 /** @file
 Pei USB ATATPI command implementations.
 
-Copyright (c) 1999 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 1999 - 2017, Intel Corporation. All rights reserved.<BR>
   
 This program and the accompanying materials
 are licensed and made available under the terms and conditions
@@ -274,7 +274,7 @@ PeiUsbReadCapacity (
   if (EFI_ERROR (Status)) {
     return EFI_DEVICE_ERROR;
   }
-  LastBlock = (Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
+  LastBlock = ((UINT32) Data.LastLba3 << 24) | (Data.LastLba2 << 16) | (Data.LastLba1 << 8) | Data.LastLba0;
 
   if (LastBlock == 0xFFFFFFFF) {
     DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));
@@ -346,7 +346,7 @@ PeiUsbReadFormattedCapacity (
     PeiBotDevice->Media2.LastBlock     = 0;
 
   } else {
-    LastBlock = (FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;
+    LastBlock = ((UINT32) FormatData.LastLba3 << 24) | (FormatData.LastLba2 << 16) | (FormatData.LastLba1 << 8) | FormatData.LastLba0;
     if (LastBlock == 0xFFFFFFFF) {
       DEBUG ((EFI_D_INFO, "The usb device LBA count is larger than 0xFFFFFFFF!\n"));
     }
-- 
2.12.0.windows.1



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

* [PATCH v3 5/5] IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in signed left shift
  2017-04-12  1:52 [PATCH v3 0/5] Fix undefined behavior in signed left shift Hao Wu
                   ` (3 preceding siblings ...)
  2017-04-12  1:52 ` [PATCH v3 4/5] MdeModulePkg/UsbBotPei: " Hao Wu
@ 2017-04-12  1:52 ` Hao Wu
  2017-04-12  1:53 ` [PATCH v3 0/5] " Tian, Feng
  5 siblings, 0 replies; 8+ messages in thread
From: Hao Wu @ 2017-04-12  1:52 UTC (permalink / raw)
  To: edk2-devel, guoheyi; +Cc: Hao Wu, Feng Tian

In function AtapiReadCapacity(), the following expression:
IdeDev->BlkIo.Media->LastBlock = (Data.LastLba3 << 24) |
  (Data.LastLba2 << 16) |
  (Data.LastLba1 << 8) |
  Data.LastLba0;

(There is also a similar case in this function.)

will involve undefined behavior in signed left shift operations.

Since Data.LastLbaX is of type UINT8, and
IdeDev->BlkIo.Media->LastBlock is of type UINT64. Therefore,
Data.LastLbaX will be promoted to int (32 bits, signed) first,
and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Data.LastLba3 is 1, (Data.LastLba3 << 24) will be out of
the range within int type. The undefined behavior of the signed left shift
will lead to a potential of setting the high 32 bits of
IdeDev->BlkIo.Media->LastBlock to 1 during the cast from type int to type
UINT64.

This commit will add an explicit UINT32 type cast for Data.LastLba3 to
resolve this issue.

Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
 IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
index 1a3cb2e0a0..c641dc5714 100644
--- a/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
+++ b/IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c
@@ -1,7 +1,7 @@
 /** @file
    This file contains all helper functions on the ATAPI command 
   
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
   This program and the accompanying materials                          
   are licensed and made available under the terms and conditions of the BSD License         
   which accompanies this distribution.  The full text of the license may be found at        
@@ -1053,7 +1053,7 @@ AtapiReadCapacity (
 	if (!EFI_ERROR (Status) && *SResult == SenseNoSenseKey) {
       if (IdeDev->Type == IdeCdRom) {
 
-        IdeDev->BlkIo.Media->LastBlock = (Data.LastLba3 << 24) |
+        IdeDev->BlkIo.Media->LastBlock = ((UINT32) Data.LastLba3 << 24) |
           (Data.LastLba2 << 16) |
           (Data.LastLba1 << 8) |
           Data.LastLba0;
@@ -1076,7 +1076,7 @@ AtapiReadCapacity (
           IdeDev->BlkIo.Media->LastBlock    = 0;
         } else {
 
-          IdeDev->BlkIo.Media->LastBlock =  (FormatData.LastLba3 << 24) |
+          IdeDev->BlkIo.Media->LastBlock = ((UINT32) FormatData.LastLba3 << 24) |
             (FormatData.LastLba2 << 16) | 
             (FormatData.LastLba1 << 8)  |
             FormatData.LastLba0;
-- 
2.12.0.windows.1



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

* Re: [PATCH v3 0/5] Fix undefined behavior in signed left shift
  2017-04-12  1:52 [PATCH v3 0/5] Fix undefined behavior in signed left shift Hao Wu
                   ` (4 preceding siblings ...)
  2017-04-12  1:52 ` [PATCH v3 5/5] IntelFWMdlPkg/IdeBusDxe: " Hao Wu
@ 2017-04-12  1:53 ` Tian, Feng
  2017-04-12  1:55   ` Tian, Feng
  5 siblings, 1 reply; 8+ messages in thread
From: Tian, Feng @ 2017-04-12  1:53 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org, guoheyi@huawei.com; +Cc: Tian, Feng

Series reviewed-by: Feng Tian <feng.tian@intel.com>

-----Original Message-----
From: Wu, Hao A 
Sent: Wednesday, April 12, 2017 9:52 AM
To: edk2-devel@lists.01.org; guoheyi@huawei.com
Cc: Wu, Hao A <hao.a.wu@intel.com>; Tian, Feng <feng.tian@intel.com>
Subject: [PATCH v3 0/5] Fix undefined behavior in signed left shift

After searching the whole code base, more cases are found related with:
'LastLba3 << 24'

Send a new patch series (V3 based on the patch for ScsiDisk) to fix the suspicious undefined behavior in signed left shift.

Cc: Feng Tian <feng.tian@intel.com>

Hao Wu (5):
  MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift
  MdeModulePkg/IdeBusPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UfsBlkIoPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UsbBotPei: Fix undefined behavior in signed left shift
  IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in signed left shift

 IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c  | 6 +++---
 MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c         | 4 ++--
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c       | 4 ++--
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c | 6 +++---
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c          | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)

--
2.12.0.windows.1



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

* Re: [PATCH v3 0/5] Fix undefined behavior in signed left shift
  2017-04-12  1:53 ` [PATCH v3 0/5] " Tian, Feng
@ 2017-04-12  1:55   ` Tian, Feng
  0 siblings, 0 replies; 8+ messages in thread
From: Tian, Feng @ 2017-04-12  1:55 UTC (permalink / raw)
  To: Wu, Hao A, edk2-devel@lists.01.org, guoheyi@huawei.com; +Cc: Tian, Feng

PS: lt's a typo on pkg name: IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in signed left shift

-----Original Message-----
From: Tian, Feng 
Sent: Wednesday, April 12, 2017 9:53 AM
To: Wu, Hao A <hao.a.wu@intel.com>; edk2-devel@lists.01.org; guoheyi@huawei.com
Cc: Tian, Feng <feng.tian@intel.com>
Subject: RE: [PATCH v3 0/5] Fix undefined behavior in signed left shift

Series reviewed-by: Feng Tian <feng.tian@intel.com>

-----Original Message-----
From: Wu, Hao A 
Sent: Wednesday, April 12, 2017 9:52 AM
To: edk2-devel@lists.01.org; guoheyi@huawei.com
Cc: Wu, Hao A <hao.a.wu@intel.com>; Tian, Feng <feng.tian@intel.com>
Subject: [PATCH v3 0/5] Fix undefined behavior in signed left shift

After searching the whole code base, more cases are found related with:
'LastLba3 << 24'

Send a new patch series (V3 based on the patch for ScsiDisk) to fix the suspicious undefined behavior in signed left shift.

Cc: Feng Tian <feng.tian@intel.com>

Hao Wu (5):
  MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift
  MdeModulePkg/IdeBusPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UfsBlkIoPei: Fix undefined behavior in signed left shift
  MdeModulePkg/UsbBotPei: Fix undefined behavior in signed left shift
  IntelFWMdlPkg/IdeBusDxe: Fix undefined behavior in signed left shift

 IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Atapi.c  | 6 +++---
 MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.c         | 4 ++--
 MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.c       | 4 ++--
 MdeModulePkg/Bus/Ufs/UfsBlockIoPei/UfsBlockIoPei.c | 6 +++---
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c          | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)

--
2.12.0.windows.1



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

end of thread, other threads:[~2017-04-12  1:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-12  1:52 [PATCH v3 0/5] Fix undefined behavior in signed left shift Hao Wu
2017-04-12  1:52 ` [PATCH v3 1/5] MdeModulePkg/ScsiDiskDxe: " Hao Wu
2017-04-12  1:52 ` [PATCH v3 2/5] MdeModulePkg/IdeBusPei: " Hao Wu
2017-04-12  1:52 ` [PATCH v3 3/5] MdeModulePkg/UfsBlkIoPei: " Hao Wu
2017-04-12  1:52 ` [PATCH v3 4/5] MdeModulePkg/UsbBotPei: " Hao Wu
2017-04-12  1:52 ` [PATCH v3 5/5] IntelFWMdlPkg/IdeBusDxe: " Hao Wu
2017-04-12  1:53 ` [PATCH v3 0/5] " Tian, Feng
2017-04-12  1:55   ` Tian, Feng

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