[PATCH 3/4] nvmet: Add controllers to configfs

Max Gurtovoy maxg at mellanox.com
Sun Oct 15 06:25:59 PDT 2017



On 10/15/2017 11:49 AM, roy wrote:
> Hi,
> 
> I think there is a potential problem here. for example in the next scenario:
> 
> core X is reading .../controllers/N/hostnqn and core Y is handling 
> nvmet_ctrl_free. basically
> 
> core Y can free the ctrl while core X will try to do sprintf on 
> ctrl->hostnqn which will cause NULL dereference.
> 
> Am I missing something?
> 

we delete the ctrl_configfs before freeing the ctrl. parallel processing 
should be protected by internal configfs mutex, just like in the case of 
reading namespace or port items.

for example:

static ssize_t nvmet_ns_enable_show(struct config_item *item, char *page)
{
         return sprintf(page, "%d\n", to_nvmet_ns(item)->enabled);
}

What I do see is an option for freeing the port (by rmdir ../ports/1/) 
and then ctrl->port will point to freed memory. I guess we can cache the 
needed values we want to show.



More information about the Linux-nvme mailing list