* [PATCH 0/2] xen: fix bugs in error conditions @ 2018-02-26 17:36 Amit Shah 2018-02-26 17:36 ` [PATCH 1/2] xen: fix out-of-bounds irq unbind for MSI message groups Amit Shah 2018-02-26 17:36 ` [PATCH 2/2] xen: events: free irqs in error condition Amit Shah 0 siblings, 2 replies; 8+ messages in thread From: Amit Shah @ 2018-02-26 17:36 UTC (permalink / raw) To: xen-devel Cc: linux-kernel, Amit Shah, Roger Pau Monné, David Vrabel, Boris Ostrovsky, Eduardo Valentin, Juergen Gross, Thomas Gleixner, K. Y. Srinivasan, Liu Shuo, Anoob Soman Hello, These bugs were found during code review. Details in the commits. Please review and apply. CC: Roger Pau Monné <roger.pau@citrix.com> CC: David Vrabel <david.vrabel@citrix.com> CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> CC: Eduardo Valentin <eduval@amazon.com> CC: Juergen Gross <jgross@suse.com> CC: Thomas Gleixner <tglx@linutronix.de> CC: "K. Y. Srinivasan" <kys@microsoft.com> CC: Liu Shuo <shuo.a.liu@intel.com> CC: Anoob Soman <anoob.soman@citrix.com> Amit Shah (2): xen: fix out-of-bounds irq unbind for MSI message groups xen: events: free irqs in error condition drivers/xen/events/events_base.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.7.3.AMZN Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] xen: fix out-of-bounds irq unbind for MSI message groups 2018-02-26 17:36 [PATCH 0/2] xen: fix bugs in error conditions Amit Shah @ 2018-02-26 17:36 ` Amit Shah 2018-02-26 20:02 ` Boris Ostrovsky 2018-02-26 17:36 ` [PATCH 2/2] xen: events: free irqs in error condition Amit Shah 1 sibling, 1 reply; 8+ messages in thread From: Amit Shah @ 2018-02-26 17:36 UTC (permalink / raw) To: xen-devel Cc: linux-kernel, Amit Shah, stable, Roger Pau Monné, David Vrabel, Boris Ostrovsky, Eduardo Valentin, Juergen Gross, Thomas Gleixner, K. Y. Srinivasan, Liu Shuo, Anoob Soman When an MSI descriptor was not available, the error path would try to unbind an irq that was never acquired - potentially unbinding an unrelated irq. Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") Reported-by: Hooman Mirhadi <mirhadih@amazon.com> CC: <stable@vger.kernel.org> CC: Roger Pau Monné <roger.pau@citrix.com> CC: David Vrabel <david.vrabel@citrix.com> CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> CC: Eduardo Valentin <eduval@amazon.com> CC: Juergen Gross <jgross@suse.com> CC: Thomas Gleixner <tglx@linutronix.de> CC: "K. Y. Srinivasan" <kys@microsoft.com> CC: Liu Shuo <shuo.a.liu@intel.com> CC: Anoob Soman <anoob.soman@citrix.com> Signed-off-by: Amit Shah <aams@amazon.com> --- drivers/xen/events/events_base.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index 1ab4bd1..b6b8b29 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -749,6 +749,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, } ret = irq_set_msi_desc(irq, msidesc); + i--; if (ret < 0) goto error_irq; out: -- 2.7.3.AMZN Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] xen: fix out-of-bounds irq unbind for MSI message groups 2018-02-26 17:36 ` [PATCH 1/2] xen: fix out-of-bounds irq unbind for MSI message groups Amit Shah @ 2018-02-26 20:02 ` Boris Ostrovsky 0 siblings, 0 replies; 8+ messages in thread From: Boris Ostrovsky @ 2018-02-26 20:02 UTC (permalink / raw) To: Amit Shah, xen-devel Cc: linux-kernel, stable, Roger Pau Monné, David Vrabel, Eduardo Valentin, Juergen Gross, Thomas Gleixner, K. Y. Srinivasan, Liu Shuo, Anoob Soman On 02/26/2018 12:36 PM, Amit Shah wrote: > When an MSI descriptor was not available, the error path would try to > unbind an irq that was never acquired - potentially unbinding an > unrelated irq. > > Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") > Reported-by: Hooman Mirhadi <mirhadih@amazon.com> > CC: <stable@vger.kernel.org> > CC: Roger Pau Monné <roger.pau@citrix.com> > CC: David Vrabel <david.vrabel@citrix.com> > CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> > CC: Eduardo Valentin <eduval@amazon.com> > CC: Juergen Gross <jgross@suse.com> > CC: Thomas Gleixner <tglx@linutronix.de> > CC: "K. Y. Srinivasan" <kys@microsoft.com> > CC: Liu Shuo <shuo.a.liu@intel.com> > CC: Anoob Soman <anoob.soman@citrix.com> > Signed-off-by: Amit Shah <aams@amazon.com> > --- > drivers/xen/events/events_base.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c > index 1ab4bd1..b6b8b29 100644 > --- a/drivers/xen/events/events_base.c > +++ b/drivers/xen/events/events_base.c > @@ -749,6 +749,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, > } > > ret = irq_set_msi_desc(irq, msidesc); > + i--; > if (ret < 0) > goto error_irq; We really only need to do this in case of an error. (And this patch needs to go to stable trees as well.) Thanks -boris ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] xen: events: free irqs in error condition 2018-02-26 17:36 [PATCH 0/2] xen: fix bugs in error conditions Amit Shah 2018-02-26 17:36 ` [PATCH 1/2] xen: fix out-of-bounds irq unbind for MSI message groups Amit Shah @ 2018-02-26 17:36 ` Amit Shah 2018-02-26 18:14 ` Roger Pau Monné 1 sibling, 1 reply; 8+ messages in thread From: Amit Shah @ 2018-02-26 17:36 UTC (permalink / raw) To: xen-devel Cc: linux-kernel, Amit Shah, stable, Roger Pau Monné, David Vrabel, Boris Ostrovsky, Eduardo Valentin, Juergen Gross, Thomas Gleixner, K. Y. Srinivasan, Liu Shuo, Anoob Soman In case of errors in irq setup for MSI, free up the allocated irqs. Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") Reported-by: Hooman Mirhadi <mirhadih@amazon.com> CC: <stable@vger.kernel.org> CC: Roger Pau Monné <roger.pau@citrix.com> CC: David Vrabel <david.vrabel@citrix.com> CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> CC: Eduardo Valentin <eduval@amazon.com> CC: Juergen Gross <jgross@suse.com> CC: Thomas Gleixner <tglx@linutronix.de> CC: "K. Y. Srinivasan" <kys@microsoft.com> CC: Liu Shuo <shuo.a.liu@intel.com> CC: Anoob Soman <anoob.soman@citrix.com> Signed-off-by: Amit Shah <aams@amazon.com> --- drivers/xen/events/events_base.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index b6b8b29..96aa575 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -758,6 +758,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, error_irq: for (; i >= 0; i--) __unbind_from_irq(irq + i); + xen_free_irq(irq); mutex_unlock(&irq_mapping_update_lock); return ret; } -- 2.7.3.AMZN Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xen: events: free irqs in error condition 2018-02-26 17:36 ` [PATCH 2/2] xen: events: free irqs in error condition Amit Shah @ 2018-02-26 18:14 ` Roger Pau Monné 2018-02-26 18:57 ` Shah, Amit 0 siblings, 1 reply; 8+ messages in thread From: Roger Pau Monné @ 2018-02-26 18:14 UTC (permalink / raw) To: Amit Shah Cc: xen-devel, linux-kernel, stable, David Vrabel, Boris Ostrovsky, Eduardo Valentin, Juergen Gross, Thomas Gleixner, K. Y. Srinivasan, Liu Shuo, Anoob Soman On Mon, Feb 26, 2018 at 05:36:35PM +0000, Amit Shah wrote: > In case of errors in irq setup for MSI, free up the allocated irqs. > > Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") > Reported-by: Hooman Mirhadi <mirhadih@amazon.com> > CC: <stable@vger.kernel.org> > CC: Roger Pau Monné <roger.pau@citrix.com> > CC: David Vrabel <david.vrabel@citrix.com> > CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> > CC: Eduardo Valentin <eduval@amazon.com> > CC: Juergen Gross <jgross@suse.com> > CC: Thomas Gleixner <tglx@linutronix.de> > CC: "K. Y. Srinivasan" <kys@microsoft.com> > CC: Liu Shuo <shuo.a.liu@intel.com> > CC: Anoob Soman <anoob.soman@citrix.com> > Signed-off-by: Amit Shah <aams@amazon.com> > --- > drivers/xen/events/events_base.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c > index b6b8b29..96aa575 100644 > --- a/drivers/xen/events/events_base.c > +++ b/drivers/xen/events/events_base.c > @@ -758,6 +758,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, > error_irq: > for (; i >= 0; i--) > __unbind_from_irq(irq + i); > + xen_free_irq(irq); Hm, xen_free_irq calls irq_free_desc, which is irq_free_descs(irq, 1), I think you will have to introduce a new free function: xen_free_irqs(unsigned irq, unsigned int nr) That calls irq_free_descs(irq, nr) Thanks, Roger. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xen: events: free irqs in error condition 2018-02-26 18:14 ` Roger Pau Monné @ 2018-02-26 18:57 ` Shah, Amit 2018-02-27 8:14 ` Roger Pau Monné 0 siblings, 1 reply; 8+ messages in thread From: Shah, Amit @ 2018-02-26 18:57 UTC (permalink / raw) To: roger.pau@citrix.com Cc: boris.ostrovsky@oracle.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, kys@microsoft.com, Valentin, Eduardo, jgross@suse.com, stable@vger.kernel.org, shuo.a.liu@intel.com, anoob.soman@citrix.com, xen-devel@lists.xenproject.org On Mo, 2018-02-26 at 18:14 +0000, Roger Pau Monné wrote: > On Mon, Feb 26, 2018 at 05:36:35PM +0000, Amit Shah wrote: > > > > In case of errors in irq setup for MSI, free up the allocated irqs. > > > > Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") > > Reported-by: Hooman Mirhadi <mirhadih@amazon.com> > > CC: <stable@vger.kernel.org> > > CC: Roger Pau Monné <roger.pau@citrix.com> > > CC: David Vrabel <david.vrabel@citrix.com> > > CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> > > CC: Eduardo Valentin <eduval@amazon.com> > > CC: Juergen Gross <jgross@suse.com> > > CC: Thomas Gleixner <tglx@linutronix.de> > > CC: "K. Y. Srinivasan" <kys@microsoft.com> > > CC: Liu Shuo <shuo.a.liu@intel.com> > > CC: Anoob Soman <anoob.soman@citrix.com> > > Signed-off-by: Amit Shah <aams@amazon.com> > > --- > > drivers/xen/events/events_base.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/xen/events/events_base.c > > b/drivers/xen/events/events_base.c > > index b6b8b29..96aa575 100644 > > --- a/drivers/xen/events/events_base.c > > +++ b/drivers/xen/events/events_base.c > > @@ -758,6 +758,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev > > *dev, struct msi_desc *msidesc, > > error_irq: > > for (; i >= 0; i--) > > __unbind_from_irq(irq + i); > > + xen_free_irq(irq); > Hm, xen_free_irq calls irq_free_desc, which is irq_free_descs(irq, > 1), Er... right. > I think you will have to introduce a new free function: > > xen_free_irqs(unsigned irq, unsigned int nr) > > That calls irq_free_descs(irq, nr) Actually, xen_free_irq() is already done in __unbind_from_irq(), so this patch is actually wrong and not needed. Amit Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xen: events: free irqs in error condition 2018-02-26 18:57 ` Shah, Amit @ 2018-02-27 8:14 ` Roger Pau Monné 2018-02-27 15:46 ` Shah, Amit 0 siblings, 1 reply; 8+ messages in thread From: Roger Pau Monné @ 2018-02-27 8:14 UTC (permalink / raw) To: Shah, Amit Cc: boris.ostrovsky@oracle.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, kys@microsoft.com, Valentin, Eduardo, jgross@suse.com, stable@vger.kernel.org, shuo.a.liu@intel.com, anoob.soman@citrix.com, xen-devel@lists.xenproject.org On Mon, Feb 26, 2018 at 06:57:03PM +0000, Shah, Amit wrote: > > On Mo, 2018-02-26 at 18:14 +0000, Roger Pau Monné wrote: > > On Mon, Feb 26, 2018 at 05:36:35PM +0000, Amit Shah wrote: > > > > > > In case of errors in irq setup for MSI, free up the allocated irqs. > > > > > > Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message groups") > > > Reported-by: Hooman Mirhadi <mirhadih@amazon.com> > > > CC: <stable@vger.kernel.org> > > > CC: Roger Pau Monné <roger.pau@citrix.com> > > > CC: David Vrabel <david.vrabel@citrix.com> > > > CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> > > > CC: Eduardo Valentin <eduval@amazon.com> > > > CC: Juergen Gross <jgross@suse.com> > > > CC: Thomas Gleixner <tglx@linutronix.de> > > > CC: "K. Y. Srinivasan" <kys@microsoft.com> > > > CC: Liu Shuo <shuo.a.liu@intel.com> > > > CC: Anoob Soman <anoob.soman@citrix.com> > > > Signed-off-by: Amit Shah <aams@amazon.com> > > > --- > > > drivers/xen/events/events_base.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/xen/events/events_base.c > > > b/drivers/xen/events/events_base.c > > > index b6b8b29..96aa575 100644 > > > --- a/drivers/xen/events/events_base.c > > > +++ b/drivers/xen/events/events_base.c > > > @@ -758,6 +758,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev > > > *dev, struct msi_desc *msidesc, > > > error_irq: > > > for (; i >= 0; i--) > > > __unbind_from_irq(irq + i); > > > + xen_free_irq(irq); > > Hm, xen_free_irq calls irq_free_desc, which is irq_free_descs(irq, > > 1), > > Er... right. > > > I think you will have to introduce a new free function: > > > > xen_free_irqs(unsigned irq, unsigned int nr) > > > > That calls irq_free_descs(irq, nr) > > Actually, xen_free_irq() is already done in __unbind_from_irq(), so > this patch is actually wrong and not needed. You still need to free unbound IRQs, AFAICT you could fix the issue with a single patch, like: while (nvec--) { if (nvec >= i) xen_free_irq(irq + i); else __unbind_from_irq(irq + i); } Roger. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xen: events: free irqs in error condition 2018-02-27 8:14 ` Roger Pau Monné @ 2018-02-27 15:46 ` Shah, Amit 0 siblings, 0 replies; 8+ messages in thread From: Shah, Amit @ 2018-02-27 15:46 UTC (permalink / raw) To: roger.pau@citrix.com Cc: boris.ostrovsky@oracle.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, kys@microsoft.com, jgross@suse.com, stable@vger.kernel.org, shuo.a.liu@intel.com, anoob.soman@citrix.com, Valentin, Eduardo, xen-devel@lists.xenproject.org On Di, 2018-02-27 at 08:14 +0000, Roger Pau Monné wrote: > On Mon, Feb 26, 2018 at 06:57:03PM +0000, Shah, Amit wrote: > > > > > > On Mo, 2018-02-26 at 18:14 +0000, Roger Pau Monné wrote: > > > > > > On Mon, Feb 26, 2018 at 05:36:35PM +0000, Amit Shah wrote: > > > > > > > > > > > > In case of errors in irq setup for MSI, free up the allocated > > > > irqs. > > > > > > > > Fixes: 4892c9b4ada9f9 ("xen: add support for MSI message > > > > groups") > > > > Reported-by: Hooman Mirhadi <mirhadih@amazon.com> > > > > CC: <stable@vger.kernel.org> > > > > CC: Roger Pau Monné <roger.pau@citrix.com> > > > > CC: David Vrabel <david.vrabel@citrix.com> > > > > CC: Boris Ostrovsky <boris.ostrovsky@oracle.com> > > > > CC: Eduardo Valentin <eduval@amazon.com> > > > > CC: Juergen Gross <jgross@suse.com> > > > > CC: Thomas Gleixner <tglx@linutronix.de> > > > > CC: "K. Y. Srinivasan" <kys@microsoft.com> > > > > CC: Liu Shuo <shuo.a.liu@intel.com> > > > > CC: Anoob Soman <anoob.soman@citrix.com> > > > > Signed-off-by: Amit Shah <aams@amazon.com> > > > > --- > > > > drivers/xen/events/events_base.c | 1 + > > > > 1 file changed, 1 insertion(+) > > > > > > > > diff --git a/drivers/xen/events/events_base.c > > > > b/drivers/xen/events/events_base.c > > > > index b6b8b29..96aa575 100644 > > > > --- a/drivers/xen/events/events_base.c > > > > +++ b/drivers/xen/events/events_base.c > > > > @@ -758,6 +758,7 @@ int xen_bind_pirq_msi_to_irq(struct pci_dev > > > > *dev, struct msi_desc *msidesc, > > > > error_irq: > > > > for (; i >= 0; i--) > > > > __unbind_from_irq(irq + i); > > > > + xen_free_irq(irq); > > > Hm, xen_free_irq calls irq_free_desc, which is > > > irq_free_descs(irq, > > > 1), > > Er... right. > > > > > > > > I think you will have to introduce a new free function: > > > > > > xen_free_irqs(unsigned irq, unsigned int nr) > > > > > > That calls irq_free_descs(irq, nr) > > Actually, xen_free_irq() is already done in __unbind_from_irq(), so > > this patch is actually wrong and not needed. > You still need to free unbound IRQs, AFAICT you could fix the issue > with a single patch, like: > > while (nvec--) { > if (nvec >= i) > xen_free_irq(irq + i); > else > __unbind_from_irq(irq + i); > } Agreed. However, since these are two different things, I'd still like to separate out into two patches, and two paths so it's easier to see what's being done. Sending v2 in a bit. Amit Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-02-27 15:46 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2018-02-26 17:36 [PATCH 0/2] xen: fix bugs in error conditions Amit Shah 2018-02-26 17:36 ` [PATCH 1/2] xen: fix out-of-bounds irq unbind for MSI message groups Amit Shah 2018-02-26 20:02 ` Boris Ostrovsky 2018-02-26 17:36 ` [PATCH 2/2] xen: events: free irqs in error condition Amit Shah 2018-02-26 18:14 ` Roger Pau Monné 2018-02-26 18:57 ` Shah, Amit 2018-02-27 8:14 ` Roger Pau Monné 2018-02-27 15:46 ` Shah, Amit
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).