linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ptrlist: use after free in last_ptr_list()
@ 2016-06-13  9:45 Dan Carpenter
  2016-11-02 12:48 ` Luc Van Oostenryck
  0 siblings, 1 reply; 10+ messages in thread
From: Dan Carpenter @ 2016-06-13  9:45 UTC (permalink / raw)
  To: linux-sparse

This change is similar to 2e7dd34d11cb ('ptrlist: reading deleted items
in NEXT_PTR_LIST()').  If we use DELETE_CURRENT_PTR() then we can end up
with a list->nr that is zero meaning that we have to go back another
list->prev to find what we want.  Otherwise we dereference 0xf0f0f0f0
and crash.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 ptrlist.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ptrlist.h b/ptrlist.h
index 61e159f..6f90c8f 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -78,6 +78,8 @@ static inline void *last_ptr_list(struct ptr_list *list)
 	if (!list)
 		return NULL;
 	list = list->prev;
+	while (list->nr == 0)
+		list = list->prev;
 	return PTR_ENTRY(list, list->nr-1);
 }
 
-- 
2.8.1


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

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

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-13  9:45 [PATCH] ptrlist: use after free in last_ptr_list() Dan Carpenter
2016-11-02 12:48 ` Luc Van Oostenryck
2016-11-02 14:52   ` Christopher Li
2016-11-02 15:23     ` Luc Van Oostenryck
2016-11-04 10:44       ` Luc Van Oostenryck
2016-11-05  0:30         ` Christopher Li
2016-11-06  8:49           ` Luc Van Oostenryck
2016-11-07 10:00             ` Luc Van Oostenryck
2016-11-16 22:46               ` Christopher Li
2016-11-16 23:22                 ` Luc Van Oostenryck

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).