Blame SOURCES/CVE-2023-0266.patch

cc0e73
From 6cfa68ca747bc4fe8978bcf92c3d894e95c05022 Mon Sep 17 00:00:00 2001
cc0e73
From: Ryan Sullivan <rysulliv@redhat.com>
cc0e73
Date: Fri, 17 Feb 2023 10:33:05 -0500
cc0e73
Subject: [KPATCH CVE-2023-0266] kpatch fixes for CVE-2023-0266
cc0e73
cc0e73
Kernels:
cc0e73
4.18.0-425.3.1.el8
cc0e73
4.18.0-425.10.1.el8_7
cc0e73
cc0e73
cc0e73
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-8/-/merge_requests/87
cc0e73
Approved-by: Yannick Cote (@ycote1)
cc0e73
Approved-by: Joe Lawrence (@joe.lawrence)
cc0e73
Changes since last build:
cc0e73
[x86_64]:
cc0e73
control.o: changed function: snd_ctl_elem_read
cc0e73
control.o: changed function: snd_ctl_ioctl
cc0e73
sysctl.o: changed function: __do_proc_dointvec
cc0e73
sysctl.o: changed function: __do_proc_douintvec
cc0e73
sysctl.o: changed function: __do_proc_doulongvec_minmax
cc0e73
sysctl.o: changed function: proc_get_long.constprop.14
cc0e73
cc0e73
[ppc64le]:
cc0e73
control.o: changed function: snd_ctl_elem_read
cc0e73
control.o: changed function: snd_ctl_ioctl
cc0e73
sysctl.o: changed function: __do_proc_dointvec
cc0e73
sysctl.o: changed function: __do_proc_doulongvec_minmax
cc0e73
sysctl.o: changed function: proc_dopipe_max_size
cc0e73
sysctl.o: changed function: proc_douintvec
cc0e73
sysctl.o: changed function: proc_douintvec_minmax
cc0e73
sysctl.o: changed function: proc_get_long.constprop.14
cc0e73
cc0e73
---------------------------
cc0e73
cc0e73
Modifications: none
cc0e73
cc0e73
commit 28e15c1ec38154a006589fb8eb40fcab1eea97ce
cc0e73
Author: Jaroslav Kysela <jkysela@redhat.com>
cc0e73
Date:   Thu Feb 9 09:10:34 2023 +0100
cc0e73
cc0e73
    ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF
cc0e73
cc0e73
    Takes rwsem lock inside snd_ctl_elem_read instead of snd_ctl_elem_read_user
cc0e73
    like it was done for write in commit 1fa4445f9adf1 ("ALSA: control - introduce
cc0e73
    snd_ctl_notify_one() helper"). Doing this way we are also fixing the following
cc0e73
    locking issue happening in the compat path which can be easily triggered and
cc0e73
    turned into an use-after-free.
cc0e73
cc0e73
    64-bits:
cc0e73
    snd_ctl_ioctl
cc0e73
      snd_ctl_elem_read_user
cc0e73
        [takes controls_rwsem]
cc0e73
        snd_ctl_elem_read [lock properly held, all good]
cc0e73
        [drops controls_rwsem]
cc0e73
cc0e73
    32-bits:
cc0e73
    snd_ctl_ioctl_compat
cc0e73
      snd_ctl_elem_write_read_compat
cc0e73
        ctl_elem_write_read
cc0e73
          snd_ctl_elem_read [missing lock, not good]
cc0e73
cc0e73
    CVE-2023-0266 was assigned for this issue.
cc0e73
cc0e73
        Cc: stable@kernel.org # 5.13+
cc0e73
        Signed-off-by: Clement Lecigne <clecigne@google.com>
cc0e73
        Reviewed-by: Jaroslav Kysela <perex@perex.cz>
cc0e73
        Link: https://lore.kernel.org/r/20230113120745.25464-1-tiwai@suse.de
cc0e73
        Signed-off-by: Takashi Iwai <tiwai@suse.de>
cc0e73
cc0e73
    Author: Clement Lecigne <clecigne@google.com>
cc0e73
    Date: Fri Jan 13 13:07:45 2023 +0100
cc0e73
cc0e73
    CVE: CVE-2023-0266
cc0e73
cc0e73
    Signed-off-by: Jaroslav Kysela <jkysela@redhat.com>
cc0e73
    (cherry picked from commit 56b88b50565cd8b946a2d00b0c83927b7ebb055e)
cc0e73
    Bugzilla: https://bugzilla.redhat.com/2163400
cc0e73
cc0e73
Signed-off-by: Ryan Sullivan <rysulliv@redhat.com>
cc0e73
---
cc0e73
 sound/core/control.c | 24 +++++++++++++++---------
cc0e73
 1 file changed, 15 insertions(+), 9 deletions(-)
cc0e73
cc0e73
diff --git a/sound/core/control.c b/sound/core/control.c
cc0e73
index 92fa122941a7..00c86f4d9063 100644
cc0e73
--- a/sound/core/control.c
cc0e73
+++ b/sound/core/control.c
cc0e73
@@ -1066,14 +1066,19 @@ static int snd_ctl_elem_read(struct snd_card *card,
cc0e73
 	const u32 pattern = 0xdeadbeef;
cc0e73
 	int ret;
cc0e73
 
cc0e73
+	down_read(&card->controls_rwsem);
cc0e73
 	kctl = snd_ctl_find_id(card, &control->id);
cc0e73
-	if (kctl == NULL)
cc0e73
-		return -ENOENT;
cc0e73
+	if (kctl == NULL) {
cc0e73
+		ret = -ENOENT;
cc0e73
+		goto unlock;
cc0e73
+	}
cc0e73
 
cc0e73
 	index_offset = snd_ctl_get_ioff(kctl, &control->id);
cc0e73
 	vd = &kctl->vd[index_offset];
cc0e73
-	if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) || kctl->get == NULL)
cc0e73
-		return -EPERM;
cc0e73
+	if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_READ) || kctl->get == NULL) {
cc0e73
+		ret = -EPERM;
cc0e73
+		goto unlock;
cc0e73
+	}
cc0e73
 
cc0e73
 	snd_ctl_build_ioff(&control->id, kctl, index_offset);
cc0e73
 
cc0e73
@@ -1083,7 +1088,7 @@ static int snd_ctl_elem_read(struct snd_card *card,
cc0e73
 	info.id = control->id;
cc0e73
 	ret = __snd_ctl_elem_info(card, kctl, &info, NULL);
cc0e73
 	if (ret < 0)
cc0e73
-		return ret;
cc0e73
+		goto unlock;
cc0e73
 #endif
cc0e73
 
cc0e73
 	if (!snd_ctl_skip_validation(&info))
cc0e73
@@ -1093,7 +1098,7 @@ static int snd_ctl_elem_read(struct snd_card *card,
cc0e73
 		ret = kctl->get(kctl, control);
cc0e73
 	snd_power_unref(card);
cc0e73
 	if (ret < 0)
cc0e73
-		return ret;
cc0e73
+		goto unlock;
cc0e73
 	if (!snd_ctl_skip_validation(&info) &&
cc0e73
 	    sanity_check_elem_value(card, control, &info, pattern) < 0) {
cc0e73
 		dev_err(card->dev,
cc0e73
@@ -1101,8 +1106,11 @@ static int snd_ctl_elem_read(struct snd_card *card,
cc0e73
 			control->id.iface, control->id.device,
cc0e73
 			control->id.subdevice, control->id.name,
cc0e73
 			control->id.index);
cc0e73
-		return -EINVAL;
cc0e73
+		ret = -EINVAL;
cc0e73
+		goto unlock;
cc0e73
 	}
cc0e73
+unlock:
cc0e73
+	up_read(&card->controls_rwsem);
cc0e73
 	return ret;
cc0e73
 }
cc0e73
 
cc0e73
@@ -1116,9 +1124,7 @@ static int snd_ctl_elem_read_user(struct snd_card *card,
cc0e73
 	if (IS_ERR(control))
cc0e73
 		return PTR_ERR(control);
cc0e73
 
cc0e73
-	down_read(&card->controls_rwsem);
cc0e73
 	result = snd_ctl_elem_read(card, control);
cc0e73
-	up_read(&card->controls_rwsem);
cc0e73
 	if (result < 0)
cc0e73
 		goto error;
cc0e73
 
cc0e73
-- 
cc0e73
2.39.2
cc0e73
cc0e73