public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] MdeModulePkg/UdfDxe: Fix NULL pointer dereference
@ 2017-09-12  1:30 Paulo Alcantara
  2017-09-12 11:27 ` Laszlo Ersek
  0 siblings, 1 reply; 4+ messages in thread
From: Paulo Alcantara @ 2017-09-12  1:30 UTC (permalink / raw)
  To: edk2-devel
  Cc: Paulo Alcantara, Star Zeng, Eric Dong, Ruiyu Ni, Laszlo Ersek,
	Steven Shi

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=704

For root directory, the FID (File Identifier Descriptor) pointer is
accessible through PRIVATE_UDF_FILE_DATA.Root, whereas non-root
directory and regular files, their FIDs are accessible through
PRIVATE_UDF_FILE_DATA.File.

In UdfSetPosition(), the FID was retrieved through
PRIVATE_UDF_FILE_DATA.File, hence when calling it with a root directory,
PRIVATE_UDF_FILE_DATA.File.FileIdentifierDescriptor would be NULL and
then dereferenced.

This patch fixes the NULL pointer dereference by calling _FILE() to
transparently return the correct UDF_FILE_INFO * which points to a valid
FID descriptor of a specific file.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Steven Shi <steven.shi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reported-by: Steven Shi <steven.shi@intel.com>
Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
---
 MdeModulePkg/Universal/Disk/UdfDxe/File.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
index 8b9339567f..a1eb2196df 100644
--- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
+++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
@@ -690,7 +690,8 @@ UdfSetPosition (
 
   PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);
 
-  FileIdentifierDesc = PrivFileData->File.FileIdentifierDesc;
+  FileIdentifierDesc = _FILE (PrivFileData)->FileIdentifierDesc;
+  ASSERT (FileIdentifierDesc != NULL);
   if (IS_FID_DIRECTORY_FILE (FileIdentifierDesc)) {
     //
     // If the file handle is a directory, the _only_ position that may be set is
-- 
2.11.0



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

* Re: [PATCH] MdeModulePkg/UdfDxe: Fix NULL pointer dereference
  2017-09-12  1:30 [PATCH] MdeModulePkg/UdfDxe: Fix NULL pointer dereference Paulo Alcantara
@ 2017-09-12 11:27 ` Laszlo Ersek
  2017-09-14 13:59   ` Paulo Alcantara
  0 siblings, 1 reply; 4+ messages in thread
From: Laszlo Ersek @ 2017-09-12 11:27 UTC (permalink / raw)
  To: Paulo Alcantara, edk2-devel; +Cc: Ruiyu Ni, Eric Dong, Star Zeng

On 09/12/17 03:30, Paulo Alcantara wrote:
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=704
> 
> For root directory, the FID (File Identifier Descriptor) pointer is
> accessible through PRIVATE_UDF_FILE_DATA.Root, whereas non-root
> directory and regular files, their FIDs are accessible through
> PRIVATE_UDF_FILE_DATA.File.
> 
> In UdfSetPosition(), the FID was retrieved through
> PRIVATE_UDF_FILE_DATA.File, hence when calling it with a root directory,
> PRIVATE_UDF_FILE_DATA.File.FileIdentifierDescriptor would be NULL and
> then dereferenced.
> 
> This patch fixes the NULL pointer dereference by calling _FILE() to
> transparently return the correct UDF_FILE_INFO * which points to a valid
> FID descriptor of a specific file.
> 
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Steven Shi <steven.shi@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Reported-by: Steven Shi <steven.shi@intel.com>
> Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
> ---
>  MdeModulePkg/Universal/Disk/UdfDxe/File.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> index 8b9339567f..a1eb2196df 100644
> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
> @@ -690,7 +690,8 @@ UdfSetPosition (
>  
>    PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);
>  
> -  FileIdentifierDesc = PrivFileData->File.FileIdentifierDesc;
> +  FileIdentifierDesc = _FILE (PrivFileData)->FileIdentifierDesc;
> +  ASSERT (FileIdentifierDesc != NULL);
>    if (IS_FID_DIRECTORY_FILE (FileIdentifierDesc)) {
>      //
>      // If the file handle is a directory, the _only_ position that may be set is
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks!
Laszlo


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

* Re: [PATCH] MdeModulePkg/UdfDxe: Fix NULL pointer dereference
  2017-09-12 11:27 ` Laszlo Ersek
@ 2017-09-14 13:59   ` Paulo Alcantara
  2017-09-15  1:39     ` Zeng, Star
  0 siblings, 1 reply; 4+ messages in thread
From: Paulo Alcantara @ 2017-09-14 13:59 UTC (permalink / raw)
  To: Laszlo Ersek, edk2-devel; +Cc: Ruiyu Ni, Eric Dong, Star Zeng



On 9/12/2017 8:27 AM, Laszlo Ersek wrote:
> On 09/12/17 03:30, Paulo Alcantara wrote:
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=704
>>
>> For root directory, the FID (File Identifier Descriptor) pointer is
>> accessible through PRIVATE_UDF_FILE_DATA.Root, whereas non-root
>> directory and regular files, their FIDs are accessible through
>> PRIVATE_UDF_FILE_DATA.File.
>>
>> In UdfSetPosition(), the FID was retrieved through
>> PRIVATE_UDF_FILE_DATA.File, hence when calling it with a root directory,
>> PRIVATE_UDF_FILE_DATA.File.FileIdentifierDescriptor would be NULL and
>> then dereferenced.
>>
>> This patch fixes the NULL pointer dereference by calling _FILE() to
>> transparently return the correct UDF_FILE_INFO * which points to a valid
>> FID descriptor of a specific file.
>>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Cc: Eric Dong <eric.dong@intel.com>
>> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Laszlo Ersek <lersek@redhat.com>
>> Cc: Steven Shi <steven.shi@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Reported-by: Steven Shi <steven.shi@intel.com>
>> Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
>> ---
>>   MdeModulePkg/Universal/Disk/UdfDxe/File.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
>> index 8b9339567f..a1eb2196df 100644
>> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
>> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
>> @@ -690,7 +690,8 @@ UdfSetPosition (
>>   
>>     PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);
>>   
>> -  FileIdentifierDesc = PrivFileData->File.FileIdentifierDesc;
>> +  FileIdentifierDesc = _FILE (PrivFileData)->FileIdentifierDesc;
>> +  ASSERT (FileIdentifierDesc != NULL);
>>     if (IS_FID_DIRECTORY_FILE (FileIdentifierDesc)) {
>>       //
>>       // If the file handle is a directory, the _only_ position that may be set is
>>
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Ping? :-)

Thanks!
Paulo


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

* Re: [PATCH] MdeModulePkg/UdfDxe: Fix NULL pointer dereference
  2017-09-14 13:59   ` Paulo Alcantara
@ 2017-09-15  1:39     ` Zeng, Star
  0 siblings, 0 replies; 4+ messages in thread
From: Zeng, Star @ 2017-09-15  1:39 UTC (permalink / raw)
  To: Paulo Alcantara, Laszlo Ersek, edk2-devel@lists.01.org
  Cc: Ni, Ruiyu, Dong, Eric, Zeng, Star

Reviewed-by: Star Zeng <star.zeng@intel.com> and pushed at 11b4463e096523fe03ac840472d483652ae93904.


Thanks,
Star
-----Original Message-----
From: Paulo Alcantara [mailto:pcacjr@zytor.com] 
Sent: Thursday, September 14, 2017 9:59 PM
To: Laszlo Ersek <lersek@redhat.com>; edk2-devel@lists.01.org
Cc: Ni, Ruiyu <ruiyu.ni@intel.com>; Dong, Eric <eric.dong@intel.com>; Zeng, Star <star.zeng@intel.com>
Subject: Re: [edk2] [PATCH] MdeModulePkg/UdfDxe: Fix NULL pointer dereference



On 9/12/2017 8:27 AM, Laszlo Ersek wrote:
> On 09/12/17 03:30, Paulo Alcantara wrote:
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=704
>>
>> For root directory, the FID (File Identifier Descriptor) pointer is 
>> accessible through PRIVATE_UDF_FILE_DATA.Root, whereas non-root 
>> directory and regular files, their FIDs are accessible through 
>> PRIVATE_UDF_FILE_DATA.File.
>>
>> In UdfSetPosition(), the FID was retrieved through 
>> PRIVATE_UDF_FILE_DATA.File, hence when calling it with a root 
>> directory, PRIVATE_UDF_FILE_DATA.File.FileIdentifierDescriptor would 
>> be NULL and then dereferenced.
>>
>> This patch fixes the NULL pointer dereference by calling _FILE() to 
>> transparently return the correct UDF_FILE_INFO * which points to a 
>> valid FID descriptor of a specific file.
>>
>> Cc: Star Zeng <star.zeng@intel.com>
>> Cc: Eric Dong <eric.dong@intel.com>
>> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
>> Cc: Laszlo Ersek <lersek@redhat.com>
>> Cc: Steven Shi <steven.shi@intel.com>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Reported-by: Steven Shi <steven.shi@intel.com>
>> Signed-off-by: Paulo Alcantara <pcacjr@zytor.com>
>> ---
>>   MdeModulePkg/Universal/Disk/UdfDxe/File.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/MdeModulePkg/Universal/Disk/UdfDxe/File.c 
>> b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
>> index 8b9339567f..a1eb2196df 100644
>> --- a/MdeModulePkg/Universal/Disk/UdfDxe/File.c
>> +++ b/MdeModulePkg/Universal/Disk/UdfDxe/File.c
>> @@ -690,7 +690,8 @@ UdfSetPosition (
>>   
>>     PrivFileData = PRIVATE_UDF_FILE_DATA_FROM_THIS (This);
>>   
>> -  FileIdentifierDesc = PrivFileData->File.FileIdentifierDesc;
>> +  FileIdentifierDesc = _FILE (PrivFileData)->FileIdentifierDesc;
>> +  ASSERT (FileIdentifierDesc != NULL);
>>     if (IS_FID_DIRECTORY_FILE (FileIdentifierDesc)) {
>>       //
>>       // If the file handle is a directory, the _only_ position that 
>> may be set is
>>
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Ping? :-)

Thanks!
Paulo

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

end of thread, other threads:[~2017-09-15  1:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12  1:30 [PATCH] MdeModulePkg/UdfDxe: Fix NULL pointer dereference Paulo Alcantara
2017-09-12 11:27 ` Laszlo Ersek
2017-09-14 13:59   ` Paulo Alcantara
2017-09-15  1:39     ` Zeng, Star

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