zoukankan      html  css  js  c++  java
  • CVE-2018-19824漏洞学习

    简介

    在Linux内核4.19.6之前,本地用户可以通过在Sound / USB /card.c.的usb_audio_probe中错误处理一个恶意USB声音设备(没有接口)来利用ALSA驱动程序中的一个UAF。如果USB声卡报告0个接口,将触发一个错误条件,函数usb_audio_probe错误输出。在错误路径中,存在一个在空闲后使用的漏洞,即首先释放卡的内存对象,然后减少活动芯片的数量。将减量移动到atomic_dec之上可以修复UAF。

    补丁分析

    补丁在这里:https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git/commit/?id=5f8cf712582617d523120df67d392059eaf2fc4b

    diff --git a/sound/usb/card.c b/sound/usb/card.c
    index 2bfe4e8..a105947 100644
    --- a/sound/usb/card.c
    +++ b/sound/usb/card.c
    @@ -682,9 +682,12 @@ static int usb_audio_probe(struct usb_interface *intf,
     
      __error:
         if (chip) {
    +        /* chip->active is inside the chip->card object,
    +         * decrement before memory is possibly returned.
    +         */
    +        atomic_dec(&chip->active);
             if (!chip->num_interfaces)
                 snd_card_free(chip->card);
    -        atomic_dec(&chip->active);
         }
         mutex_unlock(&register_mutex);
         return err;

    只是将atomic_dec(&chip->active)这个函数移动了一个位置。UAF出在snd_card_free之中。这个漏洞貌似还是比较容易理解,通常我们编写程序的时候都会注意到,退出路径中,先减少索引,如果索引为0则释放对象。但是这里却可以直接进入释放阶段,只要chip->num_interfaces为0。根据这个函数的注释,在音频设备中如果有过个控制接口这个函数会被调用多次。那这个意思就是应该看成USB总线上连接多个不同的设备

  • 相关阅读:
    DLL文件的原理
    OD使用教程7(上) 调试篇07|解密系列
    复制独立数组的方法
    [转载 js] js正则表达式
    中国雅虎ued成员
    复制独立数组的方法
    [转载 js] js正则表达式
    以前做的flash相册
    编程的幽默
    我最早的全flash站
  • 原文地址:https://www.cnblogs.com/likaiming/p/10890867.html
Copyright © 2011-2022 走看看