Thread (5 messages) 5 messages, 2 authors, 2019-03-01

Re: [PATCH 0/1] Fix NULL pointer dereference in register_disk

From: zhengbin (A) <hidden>
Date: 2019-03-01 01:27:26

Thanks
That can/should be done when we actually deal with error handling properly
in this path. I have applied your patch.
-->So when we will actually deal with error handling properly?

On 2019/3/1 5:02, Jens Axboe wrote:
On 2/20/19 6:27 AM, zhengbin wrote:
quoted
When I use syzkaller test kernel, there is a NULL pointer dereference
in register_disk. The better solution is add return code to
__device_add_disk. There is a patchset(http://lists.infradead.org/pipermail
/linux-nvme/2016-August/005860.html) from Fam Zheng, int this patchset, the
modify is as follows:
 int device_add_disk() {
        ...alloc A...
        retval = alloc B
        if (retval)
            goto fail;
        ...
	fail:
	    return retval;  --->did not free A
   }
There are many callers, ie:
loop_add-->add_disk-->device_add_disk-->__device_add_disk
loop_remove-->del_gendisk
----->This will free all resources, inclue B(free fail)

Maybe the better way is that if device_add_disk return fail, it should
free all resources? This needs to modify all the callers(Otherwise the
callers will double free), unfortunately, I am not very familiar with it.
That can/should be done when we actually deal with error handling properly
in this path. I have applied your patch.
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help