From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163416AbdEXKEz (ORCPT ); Wed, 24 May 2017 06:04:55 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33876 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163401AbdEXKEC (ORCPT ); Wed, 24 May 2017 06:04:02 -0400 From: Wei Yang To: akpm@linux-foundation.org, mhocko@suse.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH] mm/vmalloc: a slight change of compare target in __insert_vmap_area() Date: Wed, 24 May 2017 18:03:47 +0800 Message-Id: <20170524100347.8131-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The vmap RB tree store the elements in order and no overlap between any of them. The comparison in __insert_vmap_area() is to decide which direction the search should follow and make sure the new vmap_area is not overlap with any other. Current implementation fails to do the overlap check. When first "if" is not true, it means va->va_start >= tmp_va->va_end And with the truth xxx->va_end > xxx->va_start The deduction is va->va_end > tmp_va->va_start which is the condition in second "if". This patch changes a little of the comparison in __insert_vmap_area() to make sure it forbids the overlapped vmap_area. Signed-off-by: Wei Yang --- mm/vmalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 0b057628a7ba..8087451cb332 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -360,9 +360,9 @@ static void __insert_vmap_area(struct vmap_area *va) parent = *p; tmp_va = rb_entry(parent, struct vmap_area, rb_node); - if (va->va_start < tmp_va->va_end) + if (va->va_end <= tmp_va->va_start) p = &(*p)->rb_left; - else if (va->va_end > tmp_va->va_start) + else if (va->va_start >= tmp_va->va_end) p = &(*p)->rb_right; else BUG(); -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f72.google.com (mail-pg0-f72.google.com [74.125.83.72]) by kanga.kvack.org (Postfix) with ESMTP id 733F36B0314 for ; Wed, 24 May 2017 06:04:02 -0400 (EDT) Received: by mail-pg0-f72.google.com with SMTP id p29so109608864pgn.3 for ; Wed, 24 May 2017 03:04:02 -0700 (PDT) Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com. [2607:f8b0:400e:c05::241]) by mx.google.com with ESMTPS id w6si23753743pfk.420.2017.05.24.03.04.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 May 2017 03:04:01 -0700 (PDT) Received: by mail-pg0-x241.google.com with SMTP id s62so16607040pgc.0 for ; Wed, 24 May 2017 03:04:01 -0700 (PDT) From: Wei Yang Subject: [PATCH] mm/vmalloc: a slight change of compare target in __insert_vmap_area() Date: Wed, 24 May 2017 18:03:47 +0800 Message-Id: <20170524100347.8131-1-richard.weiyang@gmail.com> Sender: owner-linux-mm@kvack.org List-ID: To: akpm@linux-foundation.org, mhocko@suse.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang The vmap RB tree store the elements in order and no overlap between any of them. The comparison in __insert_vmap_area() is to decide which direction the search should follow and make sure the new vmap_area is not overlap with any other. Current implementation fails to do the overlap check. When first "if" is not true, it means va->va_start >= tmp_va->va_end And with the truth xxx->va_end > xxx->va_start The deduction is va->va_end > tmp_va->va_start which is the condition in second "if". This patch changes a little of the comparison in __insert_vmap_area() to make sure it forbids the overlapped vmap_area. Signed-off-by: Wei Yang --- mm/vmalloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 0b057628a7ba..8087451cb332 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -360,9 +360,9 @@ static void __insert_vmap_area(struct vmap_area *va) parent = *p; tmp_va = rb_entry(parent, struct vmap_area, rb_node); - if (va->va_start < tmp_va->va_end) + if (va->va_end <= tmp_va->va_start) p = &(*p)->rb_left; - else if (va->va_end > tmp_va->va_start) + else if (va->va_start >= tmp_va->va_end) p = &(*p)->rb_right; else BUG(); -- 2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org