public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ruiyu" <ruiyu.ni@intel.com>
To: Boaz Kahana <Boaz.Kahana@phoenix.com>
Cc: "Tian, Feng" <feng.tian@intel.com>,
	"Ni, Ruiyu" <ruiyu.ni@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] FatPkg/EnhancedFatDxe: Fix potential hang in async file IO
Date: Wed, 14 Dec 2016 10:03:06 +0000	[thread overview]
Message-ID: <734D49CCEBEEF84792F5B80ED585239D5B8308C9@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20161214100122.264152-1-ruiyu.ni@intel.com>

Boaz,
Could you please verify this patch in your failed system?
I cannot reproduce the issue in my environment.

Thanks/Ray

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Ruiyu Ni
> Sent: Wednesday, December 14, 2016 6:01 PM
> To: edk2-devel@lists.01.org
> Cc: Tian, Feng <feng.tian@intel.com>; Boaz Kahana
> <Boaz.Kahana@phoenix.com>
> Subject: [edk2] [PATCH] FatPkg/EnhancedFatDxe: Fix potential hang in async
> file IO
> 
> FatQueueTask() is running at TPL_APPLICATION, while
> FatDestroySubtask() is running at TPL_NOTIFY, it's possible for a task
> containing 2 sub tasks, when the for-loop executes GetNextNode (&Task-
> >Subtasks, Link), the memory occupied by Link is freed in
> FatDestroySubtask().
> 
> The fix stores the next link in NextLink so that the delete in
> FatDestroySubtask() is safe.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Feng Tian <feng.tian@intel.com>
> Cc: Boaz Kahana <Boaz.Kahana@phoenix.com>
> ---
>  FatPkg/EnhancedFatDxe/Misc.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/FatPkg/EnhancedFatDxe/Misc.c b/FatPkg/EnhancedFatDxe/Misc.c
> index c035670..cef1acd 100644
> --- a/FatPkg/EnhancedFatDxe/Misc.c
> +++ b/FatPkg/EnhancedFatDxe/Misc.c
> @@ -1,7 +1,7 @@
>  /** @file
>    Miscellaneous functions.
> 
> -Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2005 - 2016, 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
> @@ -132,6 +132,7 @@ FatQueueTask (  {
>    EFI_STATUS          Status;
>    LIST_ENTRY          *Link;
> +  LIST_ENTRY          *NextLink;
>    FAT_SUBTASK         *Subtask;
> 
>    //
> @@ -149,9 +150,13 @@ FatQueueTask (
>    EfiReleaseLock (&FatTaskLock);
> 
>    Status = EFI_SUCCESS;
> -  for ( Link = GetFirstNode (&Task->Subtasks)
> +  //
> +  // Use NextLink to store the next link since Link might be freed in
> + the end of previous loop,  // resulting next link cannot be retrieved from
> Link.
> +  //
> +  for ( Link = GetFirstNode (&Task->Subtasks), NextLink = GetNextNode
> + (&Task->Subtasks, Link)
>        ; !IsNull (&Task->Subtasks, Link)
> -      ; Link = GetNextNode (&Task->Subtasks, Link)
> +      ; Link = NextLink, NextLink = GetNextNode (&Task->Subtasks, Link)
>        ) {
>      Subtask = CR (Link, FAT_SUBTASK, Link, FAT_SUBTASK_SIGNATURE);
>      if (Subtask->Write) {
> --
> 2.9.0.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


      reply	other threads:[~2016-12-14 10:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-14 10:01 [PATCH] FatPkg/EnhancedFatDxe: Fix potential hang in async file IO Ruiyu Ni
2016-12-14 10:03 ` Ni, Ruiyu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=734D49CCEBEEF84792F5B80ED585239D5B8308C9@SHSMSX103.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox