Re: [PATCH] ptrlist: use after free in last_ptr_list()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 2, 2016 at 8:48 PM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
>> +     while (list->nr == 0)
>> +             list = list->prev;

Yes, it can deed loop here when the whole list is empty.

>                 FOR_EACH_PTR_REVERSE(list, ptr) {
>                         DELETE_CURRENT_PTR(ptr);
>                         last = last_ptr_list((struct ptr_list *)list);
>                 } END_FOR_EACH_PTR_REVERSE(ptr);
>         }
> loops forever on a list with 1 element with your patch.
> Without your patch, last_ptr_list() return an invalid pointer instead of NULL.
>

I can see what is going on now. The while loop should
check for the list->prev has been loop back to the tail of
the list.

Some thing like this should fix it, I haven't test it at all.

list = tail = list->prev;
while (list->nr == 0) {
     list = list->prev;
     if (list == tail)
           return NULL;
}

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux