Skip to content

Commit 30bcf5d

Browse files
committed
Merge: CVE-2024-42292: kobject_uevent: Fix OOB access within zap_modalias_env()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5047 JIRA: https://issues.redhat.com/browse/RHEL-55005 CVE: CVE-2024-42292 ``` kobject_uevent: Fix OOB access within zap_modalias_env() zap_modalias_env() wrongly calculates size of memory block to move, so will cause OOB memory access issue if variable MODALIAS is not the last one within its @env parameter, fixed by correcting size to memmove. Fixes: 9b3fa47 ("kobject: fix suppressing modalias in uevents delivered over netlink") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Reviewed-by: Lk Sii <lk_sii@163.com> Link: https://lore.kernel.org/r/1717074877-11352-1-git-send-email-quic_zijuhu@quicinc.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit dd6e989) ``` Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: Chris von Recklinghausen <crecklin@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents 9652732 + a103599 commit 30bcf5d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/kobject_uevent.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,23 @@ static void zap_modalias_env(struct kobj_uevent_env *env)
432432
len = strlen(env->envp[i]) + 1;
433433

434434
if (i != env->envp_idx - 1) {
435+
/* @env->envp[] contains pointers to @env->buf[]
436+
* with @env->buflen chars, and we are removing
437+
* variable MODALIAS here pointed by @env->envp[i]
438+
* with length @len as shown below:
439+
*
440+
* 0 @env->buf[] @env->buflen
441+
* ---------------------------------------------
442+
* ^ ^ ^ ^
443+
* | |-> @len <-| target block |
444+
* @env->envp[0] @env->envp[i] @env->envp[i + 1]
445+
*
446+
* so the "target block" indicated above is moved
447+
* backward by @len, and its right size is
448+
* @env->buflen - (@env->envp[i + 1] - @env->envp[0]).
449+
*/
435450
memmove(env->envp[i], env->envp[i + 1],
436-
env->buflen - len);
451+
env->buflen - (env->envp[i + 1] - env->envp[0]));
437452

438453
for (j = i; j < env->envp_idx - 1; j++)
439454
env->envp[j] = env->envp[j + 1] - len;

0 commit comments

Comments
 (0)