[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHGf_=pDn852sRadnXQMWx3rOTxGLy7876pxk1Ww4oJtkBAZbQ@mail.gmail.com>
Date: Thu, 27 Sep 2012 21:35:01 -0400
From: KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
To: Yasuaki Ishimatsu <isimatu.yasuaki@...fujitsu.com>
Cc: Ni zhan Chen <nizhan.chen@...il.com>, wency@...fujitsu.com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org,
rientjes@...gle.com, liuj97@...il.com, len.brown@...el.com,
benh@...nel.crashing.org, paulus@...ba.org, minchan.kim@...il.com,
akpm@...ux-foundation.org
Subject: Re: [PATCH 1/4] memory-hotplug: add memory_block_release
On Thu, Sep 27, 2012 at 8:24 PM, Yasuaki Ishimatsu
<isimatu.yasuaki@...fujitsu.com> wrote:
> Hi Chen,
>
>
> 2012/09/27 19:20, Ni zhan Chen wrote:
>>
>> Hi Congyang,
>>
>> 2012/9/27 <wency@...fujitsu.com>
>>
>>> From: Yasuaki Ishimatsu <isimatu.yasuaki@...fujitsu.com>
>>>
>>> When calling remove_memory_block(), the function shows following message
>>> at
>>> device_release().
>>>
>>> Device 'memory528' does not have a release() function, it is broken and
>>> must
>>> be fixed.
>>>
>>
>> What's the difference between the patch and original implemetation?
>
>
> The implementation is for removing a memory_block. So the purpose is
> same as original one. But original code is bad manner. kobject_cleanup()
> is called by remove_memory_block() at last. But release function for
> releasing memory_block is not registered. As a result, the kernel message
> is shown. IMHO, memory_block should be release by the releae function.
but your patch introduced use after free bug, if i understand correctly.
See unregister_memory() function. After your patch, kobject_put() call
release_memory_block() and kfree(). and then device_unregister() will
touch freed memory.
static void
unregister_memory(struct memory_block *memory)
{
BUG_ON(memory->dev.bus != &memory_subsys);
/* drop the ref. we got in remove_memory_block() */
kobject_put(&memory->dev.kobj);
device_unregister(&memory->dev);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists