]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Mar 2024 13:59:29 +0000 (14:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Mar 2024 13:59:29 +0000 (14:59 +0100)
added patches:
comedi-comedi_test-prevent-timers-rescheduling-during-deletion.patch
scripts-kernel-doc-fix-syntax-error-due-to-undeclared-args-variable.patch

queue-5.10/comedi-comedi_test-prevent-timers-rescheduling-during-deletion.patch [new file with mode: 0644]
queue-5.10/scripts-kernel-doc-fix-syntax-error-due-to-undeclared-args-variable.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/comedi-comedi_test-prevent-timers-rescheduling-during-deletion.patch b/queue-5.10/comedi-comedi_test-prevent-timers-rescheduling-during-deletion.patch
new file mode 100644 (file)
index 0000000..163f064
--- /dev/null
@@ -0,0 +1,123 @@
+From f53641a6e849034a44bf80f50245a75d7a376025 Mon Sep 17 00:00:00 2001
+From: Ian Abbott <abbotti@mev.co.uk>
+Date: Wed, 14 Feb 2024 10:07:25 +0000
+Subject: comedi: comedi_test: Prevent timers rescheduling during deletion
+
+From: Ian Abbott <abbotti@mev.co.uk>
+
+commit f53641a6e849034a44bf80f50245a75d7a376025 upstream.
+
+The comedi_test devices have a couple of timers (ai_timer and ao_timer)
+that can be started to simulate hardware interrupts.  Their expiry
+functions normally reschedule the timer.  The driver code calls either
+del_timer_sync() or del_timer() to delete the timers from the queue, but
+does not currently prevent the timers from rescheduling themselves so
+synchronized deletion may be ineffective.
+
+Add a couple of boolean members (one for each timer: ai_timer_enable and
+ao_timer_enable) to the device private data structure to indicate
+whether the timers are allowed to reschedule themselves.  Set the member
+to true when adding the timer to the queue, and to false when deleting
+the timer from the queue in the waveform_ai_cancel() and
+waveform_ao_cancel() functions.
+
+The del_timer_sync() function is also called from the waveform_detach()
+function, but the timer enable members will already be set to false when
+that function is called, so no change is needed there.
+
+Fixes: 403fe7f34e33 ("staging: comedi: comedi_test: fix timer race conditions")
+Cc: stable@vger.kernel.org # 4.4+
+Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
+Link: https://lore.kernel.org/r/20240214100747.16203-1-abbotti@mev.co.uk
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/staging/comedi/drivers/comedi_test.c |   30 +++++++++++++++++++++++----
+ 1 file changed, 26 insertions(+), 4 deletions(-)
+
+--- a/drivers/staging/comedi/drivers/comedi_test.c
++++ b/drivers/staging/comedi/drivers/comedi_test.c
+@@ -87,6 +87,8 @@ struct waveform_private {
+       struct comedi_device *dev;      /* parent comedi device */
+       u64 ao_last_scan_time;          /* time of previous AO scan in usec */
+       unsigned int ao_scan_period;    /* AO scan period in usec */
++      bool ai_timer_enable:1;         /* should AI timer be running? */
++      bool ao_timer_enable:1;         /* should AO timer be running? */
+       unsigned short ao_loopbacks[N_CHANS];
+ };
+@@ -236,8 +238,12 @@ static void waveform_ai_timer(struct tim
+                       time_increment = devpriv->ai_convert_time - now;
+               else
+                       time_increment = 1;
+-              mod_timer(&devpriv->ai_timer,
+-                        jiffies + usecs_to_jiffies(time_increment));
++              spin_lock(&dev->spinlock);
++              if (devpriv->ai_timer_enable) {
++                      mod_timer(&devpriv->ai_timer,
++                                jiffies + usecs_to_jiffies(time_increment));
++              }
++              spin_unlock(&dev->spinlock);
+       }
+ overrun:
+@@ -393,9 +399,12 @@ static int waveform_ai_cmd(struct comedi
+        * Seem to need an extra jiffy here, otherwise timer expires slightly
+        * early!
+        */
++      spin_lock_bh(&dev->spinlock);
++      devpriv->ai_timer_enable = true;
+       devpriv->ai_timer.expires =
+               jiffies + usecs_to_jiffies(devpriv->ai_convert_period) + 1;
+       add_timer(&devpriv->ai_timer);
++      spin_unlock_bh(&dev->spinlock);
+       return 0;
+ }
+@@ -404,6 +413,9 @@ static int waveform_ai_cancel(struct com
+ {
+       struct waveform_private *devpriv = dev->private;
++      spin_lock_bh(&dev->spinlock);
++      devpriv->ai_timer_enable = false;
++      spin_unlock_bh(&dev->spinlock);
+       if (in_softirq()) {
+               /* Assume we were called from the timer routine itself. */
+               del_timer(&devpriv->ai_timer);
+@@ -495,8 +507,12 @@ static void waveform_ao_timer(struct tim
+               unsigned int time_inc = devpriv->ao_last_scan_time +
+                                       devpriv->ao_scan_period - now;
+-              mod_timer(&devpriv->ao_timer,
+-                        jiffies + usecs_to_jiffies(time_inc));
++              spin_lock(&dev->spinlock);
++              if (devpriv->ao_timer_enable) {
++                      mod_timer(&devpriv->ao_timer,
++                                jiffies + usecs_to_jiffies(time_inc));
++              }
++              spin_unlock(&dev->spinlock);
+       }
+ underrun:
+@@ -517,9 +533,12 @@ static int waveform_ao_inttrig_start(str
+       async->inttrig = NULL;
+       devpriv->ao_last_scan_time = ktime_to_us(ktime_get());
++      spin_lock_bh(&dev->spinlock);
++      devpriv->ao_timer_enable = true;
+       devpriv->ao_timer.expires =
+               jiffies + usecs_to_jiffies(devpriv->ao_scan_period);
+       add_timer(&devpriv->ao_timer);
++      spin_unlock_bh(&dev->spinlock);
+       return 1;
+ }
+@@ -604,6 +623,9 @@ static int waveform_ao_cancel(struct com
+       struct waveform_private *devpriv = dev->private;
+       s->async->inttrig = NULL;
++      spin_lock_bh(&dev->spinlock);
++      devpriv->ao_timer_enable = false;
++      spin_unlock_bh(&dev->spinlock);
+       if (in_softirq()) {
+               /* Assume we were called from the timer routine itself. */
+               del_timer(&devpriv->ao_timer);
diff --git a/queue-5.10/scripts-kernel-doc-fix-syntax-error-due-to-undeclared-args-variable.patch b/queue-5.10/scripts-kernel-doc-fix-syntax-error-due-to-undeclared-args-variable.patch
new file mode 100644 (file)
index 0000000..8adc639
--- /dev/null
@@ -0,0 +1,43 @@
+From ccddb9f4915f0dbf28fb72b6ff4c04977978ed3d Mon Sep 17 00:00:00 2001
+From: Salvatore Bonaccorso <carnil@debian.org>
+Date: Mon, 4 Mar 2024 22:24:12 +0100
+Subject: scripts: kernel-doc: Fix syntax error due to undeclared args variable
+
+From: Salvatore Bonaccorso <carnil@debian.org>
+
+The backport of commit 3080ea5553cc ("stddef: Introduce
+DECLARE_FLEX_ARRAY() helper") to 5.10.y (as a prerequisite of another
+fix) modified scripts/kernel-doc and introduced a syntax error:
+
+Global symbol "$args" requires explicit package name (did you forget to declare "my $args"?) at ./scripts/kernel-doc line 1236.
+Global symbol "$args" requires explicit package name (did you forget to declare "my $args"?) at ./scripts/kernel-doc line 1236.
+Execution of ./scripts/kernel-doc aborted due to compilation errors.
+
+Note: The issue could be fixed in the 5.10.y series as well by
+backporting e86bdb24375a ("scripts: kernel-doc: reduce repeated regex
+expressions into variables") but just replacing the undeclared args back
+to ([^,)]+) was the most straightforward approach. The issue is specific
+to the backport to the 5.10.y series. Thus there is as well no upstream
+commit for this change.
+
+Fixes: 443b16ee3d9c ("stddef: Introduce DECLARE_FLEX_ARRAY() helper") # 5.10.y
+Reported-by: Ben Hutchings <ben@decadent.org.uk>
+Link: https://lore.kernel.org/regressions/ZeHKjjPGoyv_b2Tg@eldamar.lan/T/#u
+Link: https://bugs.debian.org/1064035
+Signed-off-by: Salvatore Bonaccorso <carnil@debian.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/kernel-doc |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/scripts/kernel-doc
++++ b/scripts/kernel-doc
+@@ -1233,7 +1233,7 @@ sub dump_struct($$) {
+       # replace DECLARE_KFIFO_PTR
+       $members =~ s/DECLARE_KFIFO_PTR\s*\(([^,)]+),\s*([^,)]+)\)/$2 \*$1/gos;
+       # replace DECLARE_FLEX_ARRAY
+-      $members =~ s/(?:__)?DECLARE_FLEX_ARRAY\s*\($args,\s*$args\)/$1 $2\[\]/gos;
++      $members =~ s/(?:__)?DECLARE_FLEX_ARRAY\s*\(([^,)]+),\s*([^,)]+)\)/$1 $2\[\]/gos;
+       my $declaration = $members;
+       # Split nested struct/union elements as newer ones
index 331938bbdbf103a69c987c21f133970f2ca1fd63..23cf7691bf174b4381cab464a2f225f2e836eced 100644 (file)
@@ -113,3 +113,5 @@ dm-snapshot-fix-lockup-in-dm_exception_table_exit.patch
 vxge-remove-unnecessary-cast-in-kfree.patch
 x86-stackprotector-32-make-the-canary-into-a-regular.patch
 x86-pm-work-around-false-positive-kmemleak-report-in.patch
+scripts-kernel-doc-fix-syntax-error-due-to-undeclared-args-variable.patch
+comedi-comedi_test-prevent-timers-rescheduling-during-deletion.patch