lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c6293062-a20c-490e-9694-4e517b918ccf@huawei.com>
Date:   Wed, 19 Oct 2022 15:17:44 +0800
From:   liulongfang <liulongfang@...wei.com>
To:     Jason Gunthorpe <jgg@...dia.com>
CC:     John Garry <john.garry@...wei.com>, <alex.williamson@...hat.com>,
        <shameerali.kolothum.thodi@...wei.com>, <cohuck@...hat.com>,
        <linux-kernel@...r.kernel.org>, <linuxarm@...neuler.org>
Subject: Re: [Linuxarm] [PATCH 1/2] hisi_acc_vfio_pci: Add debugfs to
 migration driver

On 2022/10/18 20:01, Jason Gunthorpe Wrote:
> On Tue, Oct 18, 2022 at 03:06:43PM +0800, liulongfang wrote:
>> On 2022/10/17 20:11, Jason Gunthorpe Wrote:
>>> On Mon, Oct 17, 2022 at 05:20:34PM +0800, liulongfang wrote:
>>>> On 2022/10/14 17:20, John Garry wrote:
>>>>> On 14/10/2022 03:57, Longfang Liu wrote:
>>>>>> +static void hisi_acc_vf_debugfs_init(struct hisi_acc_vf_core_device *hisi_acc_vdev)
>>>>>> +{
>>>>>> +    struct pci_dev *vf_pdev = hisi_acc_vdev->vf_dev;
>>>>>> +    struct device *dev = &vf_pdev->dev;
>>>>>> +    int ret;
>>>>>> +
>>>>>> +    if (!atomic_read(&hisi_acc_root_ref))
>>>>>> +        hisi_acc_debugfs_root = debugfs_create_dir("hisi_vfio_acc", NULL);
>>>>>> +    atomic_inc(&hisi_acc_root_ref);
>>>>>> +
>>>>>
>>>>> This looks totally racy, such that I wonder why even bother using an atomic for hisi_acc_root_ref.
>>>>
>>>>
>>>> When enabling VF, it is possible for multiple VMs to enable VF at the same time. The atomic variable
>>>> is used to ensure that only one "hisi_vfio_acc" is created. When other VFs are enabled,
>>>> it will not be created again, but will be used directly.
>>>
>>> It is still completely racy. Use a lock
>>>

Um! I understand your previous solution. Since we did not put module_init() in the driver,
to avoid competition, we first need to modify the module_init() interface of the driver,
then put debugfs_create_dir() into module_init(), and finally put debugfs_create_file()
into probe().

I will implement this way in the next version.

>>
>> Do you have any suggested solutions?
> 
> If you want to keep it like this, use a lock around the creation.
> 
> Jason
> .
> 
Thanks,
Longfang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ