~canonical-kernel/ubuntu/+source/linux-oem/+git/jammy:oem-6.1-next--s2024.02.05-1

Last commit made on 2024-02-29
Get this branch:
git clone -b oem-6.1-next--s2024.02.05-1 https://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-oem/+git/jammy
Members of Canonical Kernel can upload to this branch. Log in for directions.

Branch merges

Branch information

Name:
oem-6.1-next--s2024.02.05-1
Repository:
lp:~canonical-kernel/ubuntu/+source/linux-oem/+git/jammy

Recent commits

b0e22b5... by Duoming Zhou

net: usb: lan78xx: reorder cleanup operations to avoid UAF bugs

The timer dev->stat_monitor can schedule the delayed work dev->wq and
the delayed work dev->wq can also arm the dev->stat_monitor timer.

When the device is detaching, the net_device will be deallocated. but
the net_device private data could still be dereferenced in delayed work
or timer handler. As a result, the UAF bugs will happen.

One racy situation is shown below:

      (Thread 1) | (Thread 2)
lan78xx_stat_monitor() |
 ... | lan78xx_disconnect()
 lan78xx_defer_kevent() | ...
  ... | cancel_delayed_work_sync(&dev->wq);
  schedule_delayed_work() | ...
  (wait some time) | free_netdev(net); //free net_device
  lan78xx_delayedwork() |
  //use net_device private data |
  dev-> //use |

Although we use cancel_delayed_work_sync() to cancel the delayed work
in lan78xx_disconnect(), it could still be scheduled in timer handler
lan78xx_stat_monitor().

Another racy situation is shown below:

      (Thread 1) | (Thread 2)
lan78xx_delayedwork |
 mod_timer() | lan78xx_disconnect()
                                | cancel_delayed_work_sync()
 (wait some time) | if (timer_pending(&dev->stat_monitor))
                              | del_timer_sync(&dev->stat_monitor);
 lan78xx_stat_monitor() | ...
  lan78xx_defer_kevent() | free_netdev(net); //free
   //use net_device private data|
   dev-> //use |

Although we use del_timer_sync() to delete the timer, the function
timer_pending() returns 0 when the timer is activated. As a result,
the del_timer_sync() will not be executed and the timer could be
re-armed.

In order to mitigate this bug, We use timer_shutdown_sync() to shutdown
the timer and then use cancel_delayed_work_sync() to cancel the delayed
work. As a result, the net_device could be deallocated safely.

What's more, the dev->flags is set to EVENT_DEV_DISCONNECT in
lan78xx_disconnect(). But it could still be set to EVENT_STAT_UPDATE
in lan78xx_stat_monitor(). So this patch put the set_bit() behind
timer_shutdown_sync().

Fixes: 77dfff5bb7e2 ("lan78xx: Fix race condition in disconnect handling")
Signed-off-by: Duoming Zhou <email address hidden>
Signed-off-by: David S. Miller <email address hidden>
(cherry picked from commit 1e7417c188d0a83fb385ba2dbe35fd2563f2b6f3)
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

a7b1652... by tglx

timers: Provide timer_shutdown[_sync]()

Tearing down timers which have circular dependencies to other
functionality, e.g. workqueues, where the timer can schedule work and work
can arm timers, is not trivial.

In those cases it is desired to shutdown the timer in a way which prevents
rearming of the timer. The mechanism to do so is to set timer->function to
NULL and use this as an indicator for the timer arming functions to ignore
the (re)arm request.

Expose new interfaces for this: timer_shutdown_sync() and timer_shutdown().

timer_shutdown_sync() has the same functionality as timer_delete_sync()
plus the NULL-ification of the timer function.

timer_shutdown() has the same functionality as timer_delete() plus the
NULL-ification of the timer function.

In both cases the rearming of the timer is prevented by silently discarding
rearm attempts due to timer->function being NULL.

Co-developed-by: Steven Rostedt <email address hidden>
Signed-off-by: Steven Rostedt <email address hidden>
Signed-off-by: Thomas Gleixner <email address hidden>
Tested-by: Guenter Roeck <email address hidden>
Reviewed-by: Jacob Keller <email address hidden>
Reviewed-by: Anna-Maria Behnsen <email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>

(cherry picked from commit f571faf6e443b6011ccb585d57866177af1f643c)
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

2e0835e... by tglx

timers: Add shutdown mechanism to the internal functions

Tearing down timers which have circular dependencies to other
functionality, e.g. workqueues, where the timer can schedule work and work
can arm timers, is not trivial.

In those cases it is desired to shutdown the timer in a way which prevents
rearming of the timer. The mechanism to do so is to set timer->function to
NULL and use this as an indicator for the timer arming functions to ignore
the (re)arm request.

Add a shutdown argument to the relevant internal functions which makes the
actual deactivation code set timer->function to NULL which in turn prevents
rearming of the timer.

Co-developed-by: Steven Rostedt <email address hidden>
Signed-off-by: Steven Rostedt <email address hidden>
Signed-off-by: Thomas Gleixner <email address hidden>
Tested-by: Guenter Roeck <email address hidden>
Reviewed-by: Jacob Keller <email address hidden>
Reviewed-by: Anna-Maria Behnsen <email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>

(cherry picked from commit 0cc04e80458a822300b93f82ed861a513edde194)
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

ab4eef2... by tglx

timers: Split [try_to_]del_timer[_sync]() to prepare for shutdown mode

Tearing down timers which have circular dependencies to other
functionality, e.g. workqueues, where the timer can schedule work and work
can arm timers, is not trivial.

In those cases it is desired to shutdown the timer in a way which prevents
rearming of the timer. The mechanism to do so is to set timer->function to
NULL and use this as an indicator for the timer arming functions to ignore
the (re)arm request.

Split the inner workings of try_do_del_timer_sync(), del_timer_sync() and
del_timer() into helper functions to prepare for implementing the shutdown
functionality.

No functional change.

Co-developed-by: Steven Rostedt <email address hidden>
Signed-off-by: Steven Rostedt <email address hidden>
Signed-off-by: Thomas Gleixner <email address hidden>
Tested-by: Guenter Roeck <email address hidden>
Reviewed-by: Jacob Keller <email address hidden>
Reviewed-by: Anna-Maria Behnsen <email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>

(cherry picked from commit 8553b5f2774a66b1f293b7d783934210afb8f23c)
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

64de4dc... by tglx

timers: Rename del_timer() to timer_delete()

The timer related functions do not have a strict timer_ prefixed namespace
which is really annoying.

Rename del_timer() to timer_delete() and provide del_timer()
as a wrapper. Document that del_timer() is not for new code.

Signed-off-by: Thomas Gleixner <email address hidden>
Tested-by: Guenter Roeck <email address hidden>
Reviewed-by: Steven Rostedt (Google) <email address hidden>
Reviewed-by: Jacob Keller <email address hidden>
Reviewed-by: Anna-Maria Behnsen <email address hidden>
Link: https://<email address hidden>

(backported from commit bb663f0f3c396c6d05f6c5eeeea96ced20ff112e)
[yuxuan.luo: ignored the conflict and added the new content]
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

41338fe... by tglx

timers: Rename del_timer_sync() to timer_delete_sync()

The timer related functions do not have a strict timer_ prefixed namespace
which is really annoying.

Rename del_timer_sync() to timer_delete_sync() and provide del_timer_sync()
as a wrapper. Document that del_timer_sync() is not for new code.

Signed-off-by: Thomas Gleixner <email address hidden>
Tested-by: Guenter Roeck <email address hidden>
Reviewed-by: Steven Rostedt (Google) <email address hidden>
Reviewed-by: Jacob Keller <email address hidden>
Reviewed-by: Anna-Maria Behnsen <email address hidden>
Link: https://<email address hidden>

(cherry picked from commit 9b13df3fb64ee95e2397585404e442afee2c7d4f)
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

eb85a31... by tglx

timers: Update kernel-doc for various functions

The kernel-doc of timer related functions is partially uncomprehensible
word salad. Rewrite it to make it useful.

Signed-off-by: Thomas Gleixner <email address hidden>
Tested-by: Guenter Roeck <email address hidden>
Reviewed-by: Jacob Keller <email address hidden>
Reviewed-by: Anna-Maria Behnsen <email address hidden>
Link: https://<email address hidden>

(cherry picked from commit 14f043f1340bf30bc60af127bff39f55889fef26)
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

3a51f2c... by tglx

timers: Use del_timer_sync() even on UP

del_timer_sync() is assumed to be pointless on uniprocessor systems and can
be mapped to del_timer() because in theory del_timer() can never be invoked
while the timer callback function is executed.

This is not entirely true because del_timer() can be invoked from interrupt
context and therefore hit in the middle of a running timer callback.

Contrary to that del_timer_sync() is not allowed to be invoked from
interrupt context unless the affected timer is marked with TIMER_IRQSAFE.
del_timer_sync() has proper checks in place to detect such a situation.

Give up on the UP optimization and make del_timer_sync() unconditionally
available.

Co-developed-by: Steven Rostedt <email address hidden>
Signed-off-by: Steven Rostedt <email address hidden>
Signed-off-by: Thomas Gleixner <email address hidden>
Tested-by: Guenter Roeck <email address hidden>
Reviewed-by: Jacob Keller <email address hidden>
Reviewed-by: Anna-Maria Behnsen <email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>
Link: https://<email address hidden>

(cherry picked from commit 168f6b6ffbeec0b9333f3582e4cf637300858db5)
CVE-2023-6039
Signed-off-by: Yuxuan Luo <email address hidden>
Signed-off-by: Timo Aaltonen <email address hidden>

2c2645c... by Timo Aaltonen

UBUNTU: Ubuntu-oem-6.1-6.1.0-1035.35

Signed-off-by: Timo Aaltonen <email address hidden>

9a0e43c... by Timo Aaltonen

UBUNTU: upstream stable to v6.1.78

BugLink: https://bugs.launchpad.net/bugs/2054541

Signed-off-by: Timo Aaltonen <email address hidden>