qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.8] gluster: Fix use after free in glfs_clear_preopened()
@ 2016-11-17 10:30 Kevin Wolf
  2016-11-17 11:53 ` Jeff Cody
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Wolf @ 2016-11-17 10:30 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, prasanna.kalever, jcody, qemu-devel

This fixes a use-after-free bug introduced in commit 6349c154. We need
to use QLIST_FOREACH_SAFE() when freeing elements in the loop. Spotted
by Coverity.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/gluster.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/gluster.c b/block/gluster.c
index 0ce15f7..891c13b 100644
--- a/block/gluster.c
+++ b/block/gluster.c
@@ -239,12 +239,13 @@ static glfs_t *glfs_find_preopened(const char *volume)
 static void glfs_clear_preopened(glfs_t *fs)
 {
     ListElement *entry = NULL;
+    ListElement *next;
 
     if (fs == NULL) {
         return;
     }
 
-    QLIST_FOREACH(entry, &glfs_list, list) {
+    QLIST_FOREACH_SAFE(entry, &glfs_list, list, next) {
         if (entry->saved.fs == fs) {
             if (--entry->saved.ref) {
                 return;
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH for-2.8] gluster: Fix use after free in glfs_clear_preopened()
  2016-11-17 10:30 [Qemu-devel] [PATCH for-2.8] gluster: Fix use after free in glfs_clear_preopened() Kevin Wolf
@ 2016-11-17 11:53 ` Jeff Cody
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Cody @ 2016-11-17 11:53 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-block, prasanna.kalever, qemu-devel

On Thu, Nov 17, 2016 at 11:30:08AM +0100, Kevin Wolf wrote:
> This fixes a use-after-free bug introduced in commit 6349c154. We need
> to use QLIST_FOREACH_SAFE() when freeing elements in the loop. Spotted
> by Coverity.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/gluster.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/block/gluster.c b/block/gluster.c
> index 0ce15f7..891c13b 100644
> --- a/block/gluster.c
> +++ b/block/gluster.c
> @@ -239,12 +239,13 @@ static glfs_t *glfs_find_preopened(const char *volume)
>  static void glfs_clear_preopened(glfs_t *fs)
>  {
>      ListElement *entry = NULL;
> +    ListElement *next;
>  
>      if (fs == NULL) {
>          return;
>      }
>  
> -    QLIST_FOREACH(entry, &glfs_list, list) {
> +    QLIST_FOREACH_SAFE(entry, &glfs_list, list, next) {
>          if (entry->saved.fs == fs) {
>              if (--entry->saved.ref) {
>                  return;
> -- 
> 1.8.3.1
> 

Thanks,

Applied to my block branch:

git://github.com/codyprime/qemu-kvm-jtc.git block

-Jeff

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

end of thread, other threads:[~2016-11-17 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-17 10:30 [Qemu-devel] [PATCH for-2.8] gluster: Fix use after free in glfs_clear_preopened() Kevin Wolf
2016-11-17 11:53 ` Jeff Cody

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).