Skip to content

[lts-9.2] tty: n_gsm: fix the UAF caused by race condition in gsm_cleanup_mux #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: ciqlts9_2
Choose a base branch
from

Conversation

dvdgomez
Copy link

@dvdgomez dvdgomez commented May 15, 2025

For more information see ticket referenced below

jira VULN-676
cve CVE-2023-6546

commit-author Yi Yang <[email protected]>
commit 3c4f8333b582487a2d1e02171f1465531cde53e3

In commit 9b9c8195f3f0 ("tty: n_gsm: fix UAF in gsm_cleanup_mux"), the UAF
problem is not completely fixed. There is a race condition in
gsm_cleanup_mux(), which caused this UAF.

The UAF problem is triggered by the following race:
task[5046]                     task[5054]
-----------------------        -----------------------
gsm_cleanup_mux();
dlci = gsm->dlci[0];
mutex_lock(&gsm->mutex);
                               gsm_cleanup_mux();
                               dlci = gsm->dlci[0]; //Didn't take the lock
gsm_dlci_release(gsm->dlci[i]);
gsm->dlci[i] = NULL;
mutex_unlock(&gsm->mutex);
                               mutex_lock(&gsm->mutex);
                               dlci->dead = true; //UAF

Fix it by assigning values after mutex_lock().

Link: https://syzkaller.appspot.com/text?tag=CrashReport&x=176188b5a80000
        Cc: stable <[email protected]>
Fixes: 9b9c8195f3f0 ("tty: n_gsm: fix UAF in gsm_cleanup_mux")
Fixes: aa371e96f05d ("tty: n_gsm: fix restart handling via CLD command")
        Signed-off-by: Yi Yang <[email protected]>
Co-developed-by: Qiumiao Zhang <[email protected]>
        Signed-off-by: Qiumiao Zhang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
        Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit 3c4f8333b582487a2d1e02171f1465531cde53e3)
        Signed-off-by: David Gomez <[email protected]>

Build Log

  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/intel/skylake/snd-soc-skl.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-acpi-intel-byt.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-acpi-intel-bdw.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/amd/snd-sof-amd-renoir.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/amd/snd-sof-amd-acp.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/amd/snd-sof-amd-renoir.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-acpi-intel-byt.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/amd/snd-sof-amd-acp.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-acpi-intel-bdw.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/snd-soc-core.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-atom.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-acpi-intel-bdw.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-acpi-intel-byt.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-hda-common.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-atom.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-apl.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-hda.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-atom.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-cnl.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-icl.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-apl.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-hda.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-mtl.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-cnl.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-apl.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-tgl.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-hda.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-icl.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-hda-common.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-tng.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-mtl.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-cnl.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-tgl.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-icl.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-mtl.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-intel-hda-common.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-tng.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-tgl.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-acpi.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-pci.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/intel/snd-sof-pci-intel-tng.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-probes.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-acpi.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-pci.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-utils.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/xtensa/snd-sof-xtensa-dsp.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-acpi.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soundcore.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-pci.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-probes.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-utils.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-probes.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/xtensa/snd-sof-xtensa-dsp.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soundcore.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof-utils.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/xtensa/snd-sof-xtensa-dsp.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/synth/emux/snd-emux-synth.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soundcore.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/synth/snd-util-mem.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/6fire/snd-usb-6fire.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/bcd2000/snd-bcd2000.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/synth/emux/snd-emux-synth.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/caiaq/snd-usb-caiaq.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/synth/snd-util-mem.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/bcd2000/snd-bcd2000.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/hiface/snd-usb-hiface.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/6fire/snd-usb-6fire.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/soc/sof/snd-sof.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/synth/snd-util-mem.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-line6.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/synth/emux/snd-emux-synth.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/caiaq/snd-usb-caiaq.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/6fire/snd-usb-6fire.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/hiface/snd-usb-hiface.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/caiaq/snd-usb-caiaq.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-line6.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/hiface/snd-usb-hiface.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-pod.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-line6.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-podhd.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/bcd2000/snd-bcd2000.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-toneport.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-pod.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-variax.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/misc/snd-ua101.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-podhd.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-toneport.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-pod.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/snd-usb-audio.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/snd-usbmidi-lib.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-toneport.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-variax.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-podhd.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/misc/snd-ua101.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/line6/snd-usb-variax.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/usx2y/snd-usb-us122l.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/misc/snd-ua101.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/snd-usbmidi-lib.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/snd-usb-audio.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/usx2y/snd-usb-usx2y.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/usx2y/snd-usb-us122l.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/snd-usbmidi-lib.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/virtio/virtio_snd.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/x86/snd-hdmi-lpe-audio.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/xen/snd_xen_front.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/usx2y/snd-usb-us122l.ko
  INSTALL /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/virt/lib/irqbypass.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/virtio/virtio_snd.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/usx2y/snd-usb-usx2y.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/x86/snd-hdmi-lpe-audio.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/snd-usb-audio.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/virtio/virtio_snd.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/virt/lib/irqbypass.ko
  STRIP   /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/xen/snd_xen_front.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/usb/usx2y/snd-usb-usx2y.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/x86/snd-hdmi-lpe-audio.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/virt/lib/irqbypass.ko
  SIGN    /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+/kernel/sound/xen/snd_xen_front.ko
  DEPMOD  /lib/modules/5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+
[TIMER]{MODULES}: 15s
Making Install
sh ./arch/x86/boot/install.sh \
	5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+ arch/x86/boot/bzImage \
	System.map "/boot"
[TIMER]{INSTALL}: 55s
Checking kABI
Checking kABI
kABI check passed
Setting Default Kernel to /boot/vmlinuz-5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+ and Index to 0
The default is /boot/loader/entries/4dff56aa51eb410080f2fadbace916a6-5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+.conf with index 0 and kernel /boot/vmlinuz-5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+
The default is /boot/loader/entries/4dff56aa51eb410080f2fadbace916a6-5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+.conf with index 0 and kernel /boot/vmlinuz-5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea+
Generating grub configuration file ...
Adding boot menu entry for UEFI Firmware Settings ...
done
Hopefully Grub2.0 took everything ... rebooting after time metrices
[TIMER]{MRPROPER}: 21s
[TIMER]{BUILD}: 3236s
[TIMER]{MODULES}: 15s
[TIMER]{INSTALL}: 55s
[TIMER]{TOTAL} 3340s

Testing

5.14.0-284.30.1.el9_2.92ciq_lts.5.2.x86_64.log
5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea.log

# Before Fix
$ grep ^ok 5.14.0-284.30.1.el9_2.92ciq_lts.5.2.x86_64.log | wc -l
247
# After Fix
$ grep ^ok 5.14.0-dgomez-ciqlts9_2_VULN-676-f9fa8ba6f4ea.log | wc -l
246

dvdgomez added 5 commits May 15, 2025 11:30
jira VULN-676
cve-pre CVE-2023-6546
commit-author Zhenguo Zhao <[email protected]>
commit 5b87686

As requester,because n_gsm has no uevent report for application,the
application can't know dlci connect or disconnect.

The application will control every dlcl dev by uevent,when application
receive gsmtty0 dev remove uevent,it will close mux function,and change to
normal mode.

Example:

Before modify:

gsmld receive DLC0 DISC,no event report to application
gsmld receive DLC1 SABM,no event report to application
gsmld receive DLC1 DISC,no event report to application

After modify:

Receive DLC0 DISC,report "/devices/virtual/tty/gsmtty0" remove uevent

Receive DLC1 SABM,report "/devices/virtual/tty/gsmtty1" add uevent
Receive DLC1 DISC,report "/devices/virtual/tty/gsmtty1" remove uevent

	Signed-off-by: Zhenguo Zhao <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
	Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit 5b87686)
	Signed-off-by: David Gomez <[email protected]>
jira VULN-676
cve-pre CVE-2023-6546
commit-author Daniel Starke <[email protected]>
commit aa371e9

n_gsm is based on the 3GPP 07.010 and its newer version is the 3GPP 27.010.
See https://portal.3gpp.org/desktopmodules/Specifications/SpecificationDetails.aspx?specificationId=1516
The changes from 07.010 to 27.010 are non-functional. Therefore, I refer to
the newer 27.010 here. Chapter 5.8.2 states that both sides will revert to
the non-multiplexed mode via a close-down message (CLD). The usual program
flow is as following:
- start multiplex mode by sending AT+CMUX to the mobile
- establish the control channel (DLCI 0)
- establish user channels (DLCI >0)
- terminate user channels
- send close-down message (CLD)
- revert to AT protocol (i.e. leave multiplexed mode)

The AT protocol is out of scope of the n_gsm driver. However,
gsm_disconnect() sends CLD if gsm_config() detects that the requested
parameters require the mux protocol to restart. The next immediate action
is to start the mux protocol by opening DLCI 0 again. Any responder side
which handles CLD commands correctly forces us to fail at this point
because AT+CMUX needs to be sent to the mobile to start the mux again.
Therefore, remove the CLD command in this phase and keep both sides in
multiplexed mode.
Remove the gsm_disconnect() function as it become unnecessary and merge the
remaining parts into gsm_cleanup_mux() to handle the termination order and
locking correctly.

Fixes: 71e0779 ("tty: n_gsm: do not send/receive in ldisc close path")
	Cc: [email protected]
	Signed-off-by: Daniel Starke <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
	Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit aa371e9)
	Signed-off-by: David Gomez <[email protected]>
jira VULN-676
cve-pre CVE-2023-6546
commit-author Daniel Starke <[email protected]>
commit deefc58

The current DLCI release order starts with the control channel followed by
the user channels. Reverse this order to keep the control channel open
until all user channels have been released.

Fixes: e1eaea4 ("tty: n_gsm line discipline")
	Cc: [email protected]
	Signed-off-by: Daniel Starke <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
	Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit deefc58)
	Signed-off-by: David Gomez <[email protected]>
jira VULN-676
cve-pre CVE-2023-6546
commit-author Chaoyuan Peng <[email protected]>
commit 9b9c819

In gsm_cleanup_mux() the 'gsm->dlci' pointer was not cleaned properly,
leaving it a dangling pointer after gsm_dlci_release.
This leads to use-after-free where 'gsm->dlci[0]' are freed and accessed
by the subsequent gsm_cleanup_mux().

Such is the case in the following call trace:

 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 gsm_cleanup_mux+0x76a/0x850 drivers/tty/n_gsm.c:2397
 gsm_config drivers/tty/n_gsm.c:2653 [inline]
 gsmld_ioctl+0xaae/0x15b0 drivers/tty/n_gsm.c:2986
 tty_ioctl+0x8ff/0xc50 drivers/tty/tty_io.c:2816
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
 </TASK>

Allocated by task 3501:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 gsm_dlci_alloc+0x53/0x3a0 drivers/tty/n_gsm.c:1932
 gsm_activate_mux+0x1c/0x330 drivers/tty/n_gsm.c:2438
 gsm_config drivers/tty/n_gsm.c:2677 [inline]
 gsmld_ioctl+0xd46/0x15b0 drivers/tty/n_gsm.c:2986
 tty_ioctl+0x8ff/0xc50 drivers/tty/tty_io.c:2816
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 3501:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 dlci_put drivers/tty/n_gsm.c:1988 [inline]
 gsm_dlci_release drivers/tty/n_gsm.c:2021 [inline]
 gsm_cleanup_mux+0x574/0x850 drivers/tty/n_gsm.c:2415
 gsm_config drivers/tty/n_gsm.c:2653 [inline]
 gsmld_ioctl+0xaae/0x15b0 drivers/tty/n_gsm.c:2986
 tty_ioctl+0x8ff/0xc50 drivers/tty/tty_io.c:2816
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Fixes: aa371e9 ("tty: n_gsm: fix restart handling via CLD command")
	Signed-off-by: Chaoyuan Peng <[email protected]>
	Cc: stable <[email protected]>
	Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit 9b9c819)
	Signed-off-by: David Gomez <[email protected]>
jira VULN-676
cve CVE-2023-6546
commit-author Yi Yang <[email protected]>
commit 3c4f833

In commit 9b9c819 ("tty: n_gsm: fix UAF in gsm_cleanup_mux"), the UAF
problem is not completely fixed. There is a race condition in
gsm_cleanup_mux(), which caused this UAF.

The UAF problem is triggered by the following race:
task[5046]                     task[5054]
-----------------------        -----------------------
gsm_cleanup_mux();
dlci = gsm->dlci[0];
mutex_lock(&gsm->mutex);
                               gsm_cleanup_mux();
			       dlci = gsm->dlci[0]; //Didn't take the lock
gsm_dlci_release(gsm->dlci[i]);
gsm->dlci[i] = NULL;
mutex_unlock(&gsm->mutex);
                               mutex_lock(&gsm->mutex);
			       dlci->dead = true; //UAF

Fix it by assigning values after mutex_lock().

Link: https://syzkaller.appspot.com/text?tag=CrashReport&x=176188b5a80000
	Cc: stable <[email protected]>
Fixes: 9b9c819 ("tty: n_gsm: fix UAF in gsm_cleanup_mux")
Fixes: aa371e9 ("tty: n_gsm: fix restart handling via CLD command")
	Signed-off-by: Yi Yang <[email protected]>
Co-developed-by: Qiumiao Zhang <[email protected]>
	Signed-off-by: Qiumiao Zhang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
	Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit 3c4f833)
	Signed-off-by: David Gomez <[email protected]>
@dvdgomez dvdgomez self-assigned this May 15, 2025
@dvdgomez
Copy link
Author

dvdgomez commented May 16, 2025

More information for reviewers:

The original commit needed for this CVE: torvalds/linux@3c4f833

Looking at the commit it says it fixes two other commits:
torvalds/linux@aa371e9
torvalds/linux@9b9c819

Attempted to backport those commits but ran into issues which required more commits so the final commit chain in total looks like the below:

This is needed for the following commit
torvalds/linux@5b87686

This is needed by the commit that fixes the CVE that fixes this commit
torvalds/linux@aa371e9

This is need for the following commit
torvalds/linux@deefc58

This is needed by the commit that fixes the CVE that fixes this commit
torvalds/linux@9b9c819

This commit fixes the CVE which fixes 2 of the above commits
torvalds/linux@3c4f833

Copy link
Collaborator

@bmastbergen bmastbergen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the fix referenced in the CVE:
torvalds/linux@3c4f833

The above fixes this:
torvalds/linux@9b9c819

The above fixes this:
torvalds/linux@aa371e9

And that commit isn't in ciqlts9_2. Are we trying to fix something that isn't an issue in this branch?

@dvdgomez
Copy link
Author

So this is the fix referenced in the CVE: torvalds/linux@3c4f833

The above fixes this: torvalds/linux@9b9c819

The above fixes this: torvalds/linux@aa371e9

And that commit isn't in ciqlts9_2. Are we trying to fix something that isn't an issue in this branch?

Ah so actually it's possible that ciqlts9_2 is unaffected then by this CVE?

@bmastbergen
Copy link
Collaborator

So this is the fix referenced in the CVE: torvalds/linux@3c4f833
The above fixes this: torvalds/linux@9b9c819
The above fixes this: torvalds/linux@aa371e9
And that commit isn't in ciqlts9_2. Are we trying to fix something that isn't an issue in this branch?

Ah so actually it's possible that ciqlts9_2 is unaffected then by this CVE?

It looks that way to me. If you look at the RH data in the ticket it references 9.2 Extended Support kernels, but not the original 9.2 kernel which jives with what I see in the commit history of ciqlts9_2. Perhaps they did cherry pick aa371e9 in the 9.2 Extended Support kernels but not the OG 9.2 kernel.

@PlaidCat
Copy link
Collaborator

Its possible, we need to see if any of the upstream shas that you did cve-pre on are a part of another CVE ... this is manual googling work.
Plus if those shas have bigger patchsets have CVEs ... because we're not working in rhels's LINEAR CVE order they may have backported something else in there EUS that we don't have, thus not making us vulnerable.

This is going to be a time consuming set of CVEs because it looks like they say their vulnerable everywhere

Copy link
Collaborator

@PlaidCat PlaidCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holding a block on this as we're doing some investigation internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants