Commit cc9c4f0b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-linus-6.8a-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip

Pull xen fixes from Juergen Gross:
 "Fixes and simple cleanups:

   - use a proper flexible array instead of a one-element array in order
     to avoid array-bounds sanitizer errors

   - add NULL pointer checks after allocating memory

   - use memdup_array_user() instead of open-coding it

   - fix a rare race condition in Xen event channel allocation code

   - make struct bus_type instances const

   - make kerneldoc inline comments match reality"

* tag 'for-linus-6.8a-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
  xen/events: close evtchn after mapping cleanup
  xen/gntalloc: Replace UAPI 1-element array
  xen: balloon: make balloon_subsys const
  xen: pcpu: make xen_pcpu_subsys const
  xen/privcmd: Use memdup_array_user() in alloc_ioreq()
  x86/xen: Add some null pointer checking to smp.c
  xen/xenbus: document will_handle argument for xenbus_watch_path()
parents 68fb3ca0 fa765c4b
...@@ -65,6 +65,8 @@ int xen_smp_intr_init(unsigned int cpu) ...@@ -65,6 +65,8 @@ int xen_smp_intr_init(unsigned int cpu)
char *resched_name, *callfunc_name, *debug_name; char *resched_name, *callfunc_name, *debug_name;
resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu); resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu);
if (!resched_name)
goto fail_mem;
per_cpu(xen_resched_irq, cpu).name = resched_name; per_cpu(xen_resched_irq, cpu).name = resched_name;
rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR, rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR,
cpu, cpu,
...@@ -77,6 +79,8 @@ int xen_smp_intr_init(unsigned int cpu) ...@@ -77,6 +79,8 @@ int xen_smp_intr_init(unsigned int cpu)
per_cpu(xen_resched_irq, cpu).irq = rc; per_cpu(xen_resched_irq, cpu).irq = rc;
callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu); callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu);
if (!callfunc_name)
goto fail_mem;
per_cpu(xen_callfunc_irq, cpu).name = callfunc_name; per_cpu(xen_callfunc_irq, cpu).name = callfunc_name;
rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR, rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR,
cpu, cpu,
...@@ -90,6 +94,9 @@ int xen_smp_intr_init(unsigned int cpu) ...@@ -90,6 +94,9 @@ int xen_smp_intr_init(unsigned int cpu)
if (!xen_fifo_events) { if (!xen_fifo_events) {
debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu); debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu);
if (!debug_name)
goto fail_mem;
per_cpu(xen_debug_irq, cpu).name = debug_name; per_cpu(xen_debug_irq, cpu).name = debug_name;
rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu,
xen_debug_interrupt, xen_debug_interrupt,
...@@ -101,6 +108,9 @@ int xen_smp_intr_init(unsigned int cpu) ...@@ -101,6 +108,9 @@ int xen_smp_intr_init(unsigned int cpu)
} }
callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu); callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu);
if (!callfunc_name)
goto fail_mem;
per_cpu(xen_callfuncsingle_irq, cpu).name = callfunc_name; per_cpu(xen_callfuncsingle_irq, cpu).name = callfunc_name;
rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR, rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR,
cpu, cpu,
...@@ -114,6 +124,8 @@ int xen_smp_intr_init(unsigned int cpu) ...@@ -114,6 +124,8 @@ int xen_smp_intr_init(unsigned int cpu)
return 0; return 0;
fail_mem:
rc = -ENOMEM;
fail: fail:
xen_smp_intr_free(cpu); xen_smp_intr_free(cpu);
return rc; return rc;
......
...@@ -923,8 +923,8 @@ static void shutdown_pirq(struct irq_data *data) ...@@ -923,8 +923,8 @@ static void shutdown_pirq(struct irq_data *data)
return; return;
do_mask(info, EVT_MASK_REASON_EXPLICIT); do_mask(info, EVT_MASK_REASON_EXPLICIT);
xen_evtchn_close(evtchn);
xen_irq_info_cleanup(info); xen_irq_info_cleanup(info);
xen_evtchn_close(evtchn);
} }
static void enable_pirq(struct irq_data *data) static void enable_pirq(struct irq_data *data)
...@@ -956,6 +956,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi); ...@@ -956,6 +956,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
static void __unbind_from_irq(struct irq_info *info, unsigned int irq) static void __unbind_from_irq(struct irq_info *info, unsigned int irq)
{ {
evtchn_port_t evtchn; evtchn_port_t evtchn;
bool close_evtchn = false;
if (!info) { if (!info) {
xen_irq_free_desc(irq); xen_irq_free_desc(irq);
...@@ -975,7 +976,7 @@ static void __unbind_from_irq(struct irq_info *info, unsigned int irq) ...@@ -975,7 +976,7 @@ static void __unbind_from_irq(struct irq_info *info, unsigned int irq)
struct xenbus_device *dev; struct xenbus_device *dev;
if (!info->is_static) if (!info->is_static)
xen_evtchn_close(evtchn); close_evtchn = true;
switch (info->type) { switch (info->type) {
case IRQT_VIRQ: case IRQT_VIRQ:
...@@ -995,6 +996,9 @@ static void __unbind_from_irq(struct irq_info *info, unsigned int irq) ...@@ -995,6 +996,9 @@ static void __unbind_from_irq(struct irq_info *info, unsigned int irq)
} }
xen_irq_info_cleanup(info); xen_irq_info_cleanup(info);
if (close_evtchn)
xen_evtchn_close(evtchn);
} }
xen_free_irq(info); xen_free_irq(info);
......
...@@ -317,7 +317,7 @@ static long gntalloc_ioctl_alloc(struct gntalloc_file_private_data *priv, ...@@ -317,7 +317,7 @@ static long gntalloc_ioctl_alloc(struct gntalloc_file_private_data *priv,
rc = -EFAULT; rc = -EFAULT;
goto out_free; goto out_free;
} }
if (copy_to_user(arg->gref_ids, gref_ids, if (copy_to_user(arg->gref_ids_flex, gref_ids,
sizeof(gref_ids[0]) * op.count)) { sizeof(gref_ids[0]) * op.count)) {
rc = -EFAULT; rc = -EFAULT;
goto out_free; goto out_free;
......
...@@ -65,7 +65,7 @@ struct pcpu { ...@@ -65,7 +65,7 @@ struct pcpu {
uint32_t flags; uint32_t flags;
}; };
static struct bus_type xen_pcpu_subsys = { static const struct bus_type xen_pcpu_subsys = {
.name = "xen_cpu", .name = "xen_cpu",
.dev_name = "xen_cpu", .dev_name = "xen_cpu",
}; };
......
...@@ -1223,18 +1223,13 @@ struct privcmd_kernel_ioreq *alloc_ioreq(struct privcmd_ioeventfd *ioeventfd) ...@@ -1223,18 +1223,13 @@ struct privcmd_kernel_ioreq *alloc_ioreq(struct privcmd_ioeventfd *ioeventfd)
kioreq->ioreq = (struct ioreq *)(page_to_virt(pages[0])); kioreq->ioreq = (struct ioreq *)(page_to_virt(pages[0]));
mmap_write_unlock(mm); mmap_write_unlock(mm);
size = sizeof(*ports) * kioreq->vcpus; ports = memdup_array_user(u64_to_user_ptr(ioeventfd->ports),
ports = kzalloc(size, GFP_KERNEL); kioreq->vcpus, sizeof(*ports));
if (!ports) { if (IS_ERR(ports)) {
ret = -ENOMEM; ret = PTR_ERR(ports);
goto error_kfree; goto error_kfree;
} }
if (copy_from_user(ports, u64_to_user_ptr(ioeventfd->ports), size)) {
ret = -EFAULT;
goto error_kfree_ports;
}
for (i = 0; i < kioreq->vcpus; i++) { for (i = 0; i < kioreq->vcpus; i++) {
kioreq->ports[i].vcpu = i; kioreq->ports[i].vcpu = i;
kioreq->ports[i].port = ports[i]; kioreq->ports[i].port = ports[i];
...@@ -1256,7 +1251,7 @@ struct privcmd_kernel_ioreq *alloc_ioreq(struct privcmd_ioeventfd *ioeventfd) ...@@ -1256,7 +1251,7 @@ struct privcmd_kernel_ioreq *alloc_ioreq(struct privcmd_ioeventfd *ioeventfd)
error_unbind: error_unbind:
while (--i >= 0) while (--i >= 0)
unbind_from_irqhandler(irq_from_evtchn(ports[i]), &kioreq->ports[i]); unbind_from_irqhandler(irq_from_evtchn(ports[i]), &kioreq->ports[i]);
error_kfree_ports:
kfree(ports); kfree(ports);
error_kfree: error_kfree:
kfree(kioreq); kfree(kioreq);
......
...@@ -237,7 +237,7 @@ static const struct attribute_group *balloon_groups[] = { ...@@ -237,7 +237,7 @@ static const struct attribute_group *balloon_groups[] = {
NULL NULL
}; };
static struct bus_type balloon_subsys = { static const struct bus_type balloon_subsys = {
.name = BALLOON_CLASS_NAME, .name = BALLOON_CLASS_NAME,
.dev_name = BALLOON_CLASS_NAME, .dev_name = BALLOON_CLASS_NAME,
}; };
......
...@@ -116,14 +116,15 @@ EXPORT_SYMBOL_GPL(xenbus_strstate); ...@@ -116,14 +116,15 @@ EXPORT_SYMBOL_GPL(xenbus_strstate);
* @dev: xenbus device * @dev: xenbus device
* @path: path to watch * @path: path to watch
* @watch: watch to register * @watch: watch to register
* @will_handle: events queuing determine callback
* @callback: callback to register * @callback: callback to register
* *
* Register a @watch on the given path, using the given xenbus_watch structure * Register a @watch on the given path, using the given xenbus_watch structure
* for storage, and the given @callback function as the callback. On success, * for storage, @will_handle function as the callback to determine if each
* the given @path will be saved as @watch->node, and remains the * event need to be queued, and the given @callback function as the callback.
* caller's to free. On error, @watch->node will * On success, the given @path will be saved as @watch->node, and remains the
* be NULL, the device will switch to %XenbusStateClosing, and the error will * caller's to free. On error, @watch->node will be NULL, the device will
* be saved in the store. * switch to %XenbusStateClosing, and the error will be saved in the store.
* *
* Returns: %0 on success or -errno on error * Returns: %0 on success or -errno on error
*/ */
...@@ -158,11 +159,13 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path); ...@@ -158,11 +159,13 @@ EXPORT_SYMBOL_GPL(xenbus_watch_path);
* xenbus_watch_pathfmt - register a watch on a sprintf-formatted path * xenbus_watch_pathfmt - register a watch on a sprintf-formatted path
* @dev: xenbus device * @dev: xenbus device
* @watch: watch to register * @watch: watch to register
* @will_handle: events queuing determine callback
* @callback: callback to register * @callback: callback to register
* @pathfmt: format of path to watch * @pathfmt: format of path to watch
* *
* Register a watch on the given @path, using the given xenbus_watch * Register a watch on the given @path, using the given xenbus_watch
* structure for storage, and the given @callback function as the * structure for storage, @will_handle function as the callback to determine if
* each event need to be queued, and the given @callback function as the
* callback. On success, the watched path (@path/@path2) will be saved * callback. On success, the watched path (@path/@path2) will be saved
* as @watch->node, and becomes the caller's to kfree(). * as @watch->node, and becomes the caller's to kfree().
* On error, watch->node will be NULL, so the caller has nothing to * On error, watch->node will be NULL, so the caller has nothing to
......
...@@ -31,7 +31,10 @@ struct ioctl_gntalloc_alloc_gref { ...@@ -31,7 +31,10 @@ struct ioctl_gntalloc_alloc_gref {
__u64 index; __u64 index;
/* The grant references of the newly created grant, one per page */ /* The grant references of the newly created grant, one per page */
/* Variable size, depending on count */ /* Variable size, depending on count */
union {
__u32 gref_ids[1]; __u32 gref_ids[1];
__DECLARE_FLEX_ARRAY(__u32, gref_ids_flex);
};
}; };
#define GNTALLOC_FLAG_WRITABLE 1 #define GNTALLOC_FLAG_WRITABLE 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment