Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1572922 > unrolled thread

Re: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues

Started byJason Wang <jasowang@redhat.com>
First post2017-02-03 09:00 +0100
Last post2017-02-03 11:00 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues Jason Wang <jasowang@redhat.com> - 2017-02-03 09:00 +0100
    Re: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues Christoph Hellwig <hch@lst.de> - 2017-02-03 09:30 +0100
      Re: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues Jason Wang <jasowang@redhat.com> - 2017-02-03 10:50 +0100
        Re: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues Christoph Hellwig <hch@lst.de> - 2017-02-03 11:00 +0100
          Re: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues Jason Wang <jasowang@redhat.com> - 2017-02-03 11:00 +0100

#1572922 — Re: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues

FromJason Wang <jasowang@redhat.com>
Date2017-02-03 09:00 +0100
SubjectRe: [PATCH 2/9] virtio_pci: use shared interrupts for virtqueues
Message-ID<t6GWL-7cT-19@gated-at.bofh.it>

On 2017年01月27日 16:16, Christoph Hellwig wrote:
> +		snprintf(vp_dev->msix_names[i + 1],
> +			 sizeof(*vp_dev->msix_names), "%s-%s",
>   			 dev_name(&vp_dev->vdev.dev), names[i]);
>   		err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec),
> -				  vring_interrupt, 0,
> -				  vp_dev->msix_names[msix_vec],
> -				  vqs[i]);
> +				  vring_interrupt, IRQF_SHARED,
> +				  vp_dev->msix_names[i + 1], vqs[i]);

Do we need to check per_vq_vectors before dereferencing msix_names[i + 1] ?

Thanks

[toc] | [next] | [standalone]


#1572939

FromChristoph Hellwig <hch@lst.de>
Date2017-02-03 09:30 +0100
Message-ID<t6HpM-7CB-7@gated-at.bofh.it>
In reply to#1572922
On Fri, Feb 03, 2017 at 03:54:54PM +0800, Jason Wang wrote:
> On 2017年01月27日 16:16, Christoph Hellwig wrote:
>> +		snprintf(vp_dev->msix_names[i + 1],
>> +			 sizeof(*vp_dev->msix_names), "%s-%s",
>>   			 dev_name(&vp_dev->vdev.dev), names[i]);
>>   		err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec),
>> -				  vring_interrupt, 0,
>> -				  vp_dev->msix_names[msix_vec],
>> -				  vqs[i]);
>> +				  vring_interrupt, IRQF_SHARED,
>> +				  vp_dev->msix_names[i + 1], vqs[i]);
>
> Do we need to check per_vq_vectors before dereferencing msix_names[i + 1] ?

No, we need to allocate the array larger in that case as want proper
names for the interrupts.

[toc] | [prev] | [next] | [standalone]


#1572971

FromJason Wang <jasowang@redhat.com>
Date2017-02-03 10:50 +0100
Message-ID<t6IFc-8jr-9@gated-at.bofh.it>
In reply to#1572939

On 2017年02月03日 16:26, Christoph Hellwig wrote:
> On Fri, Feb 03, 2017 at 03:54:54PM +0800, Jason Wang wrote:
>> On 2017年01月27日 16:16, Christoph Hellwig wrote:
>>> +		snprintf(vp_dev->msix_names[i + 1],
>>> +			 sizeof(*vp_dev->msix_names), "%s-%s",
>>>    			 dev_name(&vp_dev->vdev.dev), names[i]);
>>>    		err = request_irq(pci_irq_vector(vp_dev->pci_dev, msix_vec),
>>> -				  vring_interrupt, 0,
>>> -				  vp_dev->msix_names[msix_vec],
>>> -				  vqs[i]);
>>> +				  vring_interrupt, IRQF_SHARED,
>>> +				  vp_dev->msix_names[i + 1], vqs[i]);
>> Do we need to check per_vq_vectors before dereferencing msix_names[i + 1] ?
> No, we need to allocate the array larger in that case as want proper
> names for the interrupts.

Consider the case of !per_vq_vectors, the size of msix_names is 2, but 
snprintf can do out of bound accessing here. (We name the msix shared by 
virtqueues with something like "%s-virtqueues" before the patch).

Thanks

[toc] | [prev] | [next] | [standalone]


#1572984

FromChristoph Hellwig <hch@lst.de>
Date2017-02-03 11:00 +0100
Message-ID<t6IOT-8nh-41@gated-at.bofh.it>
In reply to#1572971
On Fri, Feb 03, 2017 at 05:47:41PM +0800, Jason Wang wrote:
>> No, we need to allocate the array larger in that case as want proper
>> names for the interrupts.
>
> Consider the case of !per_vq_vectors, the size of msix_names is 2, but 
> snprintf can do out of bound accessing here. (We name the msix shared by 
> virtqueues with something like "%s-virtqueues" before the patch).

Yes, that's what I meant above - we need to allocate a large array
starting with this patch.  I'll fix it up for the next version.

[toc] | [prev] | [next] | [standalone]


#1572987

FromJason Wang <jasowang@redhat.com>
Date2017-02-03 11:00 +0100
Message-ID<t6IOT-8nh-61@gated-at.bofh.it>
In reply to#1572984

On 2017年02月03日 17:52, Christoph Hellwig wrote:
> On Fri, Feb 03, 2017 at 05:47:41PM +0800, Jason Wang wrote:
>>> No, we need to allocate the array larger in that case as want proper
>>> names for the interrupts.
>> Consider the case of !per_vq_vectors, the size of msix_names is 2, but
>> snprintf can do out of bound accessing here. (We name the msix shared by
>> virtqueues with something like "%s-virtqueues" before the patch).
> Yes, that's what I meant above - we need to allocate a large array
> starting with this patch.  I'll fix it up for the next version.

I see.

Thanks

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web