linux-evl 7.2 compilation without SMP
Subsystems (4)
It is not possible to compile linux-evl 7.2 without SMP due to bad port of include/linux/spinlock_api_up.h code and kernel/irq/pipeline.c pipeline_percpu_data being inside define for SMP, while being used without it. Included are patches to fix compilation.
---
include/linux/spinlock_api_up.h +6 -6
@@ -62,22 +62,22 @@ do { local_irq_restore(flags); __UNLOCK(lock, ##__VA_ARGS__); } while (0)#define __HARD_LOCK (lock) \ - do { ___LOCK_##__VA_ARGS__(lock); } while (0) + do { ___LOCK_(lock); } while (0)#define __HARD_LOCK_IRQ (lock) \ - do { hard_local_irq_disable(); __HARD_LOCK(lock, ##__VA_ARGS__); } while (0) + do { hard_local_irq_disable(); __HARD_LOCK(lock); } while (0)#define __HARD_LOCK_IRQSAVE (lock, flags) \ - do { flags = hard_local_irq_save(); __HARD_LOCK(lock, ##__VA_ARGS__); } while (0) + do { flags = hard_local_irq_save(); __HARD_LOCK(lock); } while (0)#define __HARD_UNLOCK (lock) \ - do { ___UNLOCK_##__VA_ARGS__(lock); } while (0) + do { ___UNLOCK_(lock); } while (0)#define __HARD_UNLOCK_IRQ (lock) \ - do { hard_local_irq_enable(); __HARD_UNLOCK(lock, ##__VA_ARGS__); } while (0) + do { hard_local_irq_enable(); __HARD_UNLOCK(lock); } while (0)#define __HARD_UNLOCK_IRQRESTORE (lock, flags) \ - do { hard_local_irq_restore(flags); __HARD_UNLOCK(lock, ##__VA_ARGS__); } while (0) + do { hard_local_irq_restore(flags); __HARD_UNLOCK(lock); } while (0)#define _raw_spin_lock (lock) __LOCK(lock)#define _raw_spin_lock_nested (lock, subclass) __LOCK(lock)
kernel/irq/pipeline.c +3 -3
@@ -75,6 +75,9 @@unsigned long flat[IRQ_FLAT_MAPSZ ]; }; +struct pipeline_percpu_data { }; +static DEFINE_PER_CPU(struct pipeline_percpu_data, pipeline_percpu_data); +#ifdef CONFIG_SMP static struct irq_event_map bootup_irq_map__initdata ;
@@ -92,9 +95,6 @@ }, }; -struct pipeline_percpu_data { }; -static DEFINE_PER_CPU(struct pipeline_percpu_data, pipeline_percpu_data); -static irqreturn_t smp_call_function_ipi_handler (int irq,void *dev_id) {smp_flush_oob_call_function_queue ();
Quoted 53 lines · Martínek Petr
It is not possible to compile linux-evl 7.2 without SMP due to bad port of
include/linux/spinlock_api_up.hcode andkernel/irq/pipeline.cpipeline_percpu_databeing inside define for SMP, while being used without it. Included are patches to fix compilation.Signed-off-by Petr Martínek <[email protected]>---
diff -Naura/include/linux/spinlock_api_up.hb/include/linux/spinlock_api_up.hinclude/linux/spinlock_api_up.h +6
-6@@ -62,22 +62,22 @@ do { local_irq_restore(flags); __UNLOCK(lock, ##__VA_ARGS__); } while (0)#define __HARD_LOCK (lock) \ - do { ___LOCK_##__VA_ARGS__(lock); } while (0) + do { ___LOCK_(lock); } while (0)#define __HARD_LOCK_IRQ (lock) \ - do { hard_local_irq_disable(); __HARD_LOCK(lock, ##__VA_ARGS__); } while (0) + do { hard_local_irq_disable(); __HARD_LOCK(lock); } while (0)#define __HARD_LOCK_IRQSAVE (lock, flags) \ - do { flags = hard_local_irq_save(); __HARD_LOCK(lock, ##__VA_ARGS__); } while (0) + do { flags = hard_local_irq_save(); __HARD_LOCK(lock); } while (0)#define __HARD_UNLOCK (lock) \ - do { ___UNLOCK_##__VA_ARGS__(lock); } while (0) + do { ___UNLOCK_(lock); } while (0)#define __HARD_UNLOCK_IRQ (lock) \ - do { hard_local_irq_enable(); __HARD_UNLOCK(lock, ##__VA_ARGS__); } while (0) + do { hard_local_irq_enable(); __HARD_UNLOCK(lock); } while (0)#define __HARD_UNLOCK_IRQRESTORE (lock, flags) \ - do { hard_local_irq_restore(flags); __HARD_UNLOCK(lock, ##__VA_ARGS__); } while (0) + do { hard_local_irq_restore(flags); __HARD_UNLOCK(lock); } while (0)#define _raw_spin_lock (lock) __LOCK(lock)#define _raw_spin_lock_nested (lock, subclass) __LOCK(lock)diff -Naur
a/kernel/irq/pipeline.cb/kernel/irq/pipeline.ckernel/irq/pipeline.c +3
-0@@ -75,6 +75,9 @@unsigned long flat[IRQ_FLAT_MAPSZ ]; }; +struct pipeline_percpu_data { }; +static DEFINE_PER_CPU(struct pipeline_percpu_data, pipeline_percpu_data); +#ifdef CONFIG_SMP static struct irq_event_map bootup_irq_map__initdata ;
kernel/irq/pipeline.c line 100
Quoted 9 lines
kernel/irq/pipeline.c +0
-3@@ -92,9 +95,6 @@ }, }; -struct pipeline_percpu_data { }; -static DEFINE_PER_CPU(struct pipeline_percpu_data, pipeline_percpu_data); -static irqreturn_t smp_call_function_ipi_handler (int irq,void *dev_id) {smp_flush_oob_call_function_queue ();
This one slipped through the cracks. Merged, thanks.
Signature · 1 line
Philippe.
linux-evl 7.2 OOB GPIO NULL dereference in lineevent_create
In reply to Martínek PetrIn lineevent_create le->oob_state is used after retain_and_null_ptr(le) which set le to NULL. Included patch adds oob_state variable to fix this.
---
drivers/gpio/gpiolib-cdev.c +5 -2
@@ -2222,6 +2222,7 @@ {struct gpioevent_request eventreq; struct lineevent_state *le __free(lineevent_free) = NULL; +struct lineevent_oob_state * oob_state;struct gpio_desc *desc;u32 offset;u32 lflags;
@@ -2340,10 +2341,12 @@ O_RDONLY | O_CLOEXEC));if (fdf.err)return fdf.err; + + oob_state = &le->oob_state;retain_and_null_ptr (le);if (oob_handling_requested (lflags)) { - ret =evl_open_file (&le->oob_state.efile,fd_prepare_file (fdf)); + ret =evl_open_file (&oob_state->efile,fd_prepare_file (fdf));if (ret)return ret; }
@@ -2351,7 +2354,7 @@ eventreq.fd =fd_prepare_fd (fdf);if (copy_to_user (ip, &eventreq,sizeof (eventreq))) {if (oob_handling_requested (lflags)) -evl_release_file (&le->oob_state.efile); +evl_release_file (&oob_state->efile);return -EFAULT ; }
Philippe Gerum
AppliedRe: linux-evl 7.2 OOB GPIO NULL dereference in lineevent_create
Quoted 32 lines · Martínek Petr
In
lineevent_createle->oob_stateis used afterretain_and_null_ptr(le)which set le to NULL. Included patch addsoob_statevariable to fix this.Signed-off-by Petr Martínek <[email protected]>---
diff -Naura/drivers/gpio/gpiolib-cdev.cb/drivers/gpio/gpiolib-cdev.cdrivers/gpio/gpiolib-cdev.c +4
-1@@ -2222,6 +2222,7 @@ {struct gpioevent_request eventreq; struct lineevent_state *le __free(lineevent_free) = NULL; +struct lineevent_oob_state * oob_state;struct gpio_desc *desc;u32 offset;u32 lflags;@@ -2340,10 +2341,12 @@ O_RDONLY | O_CLOEXEC));if (fdf.err)return fdf.err; + + oob_state = &le->oob_state;retain_and_null_ptr (le);if (oob_handling_requested (lflags)) { - ret =evl_open_file (&le->oob_state.efile,fd_prepare_file (fdf)); + ret =evl_open_file (&oob_state->efile,fd_prepare_file (fdf));if (ret)return ret; }
drivers/gpio/gpiolib-cdev.c line 2360
Quoted 8 lines
drivers/gpio/gpiolib-cdev.c +1
-1@@ -2351,7 +2354,7 @@ eventreq.fd =fd_prepare_fd (fdf);if (copy_to_user (ip, &eventreq,sizeof (eventreq))) {if (oob_handling_requested (lflags)) -evl_release_file (&le->oob_state.efile); +evl_release_file (&oob_state->efile);return -EFAULT ; }
Merged, thanks.
Signature · 1 line
Philippe.