Blame SOURCES/CVE-2023-0266.patch

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