Kernel Vulnerabilities in the Samsung S4

本文详细介绍了在三星S4 (GT-I9500) 设备中发现的多个内核漏洞,包括内存泄露和内存破坏问题。这些漏洞可能被利用来获取敏感信息或提升权限。文章还提供了一个潜在的补丁。

Multiple kernel vulnerabilities in the Samsung S4 (GT-I9500)

1 - Bugs Description

One year ago, we found some security issues in the Samsung S4 (GT-I9500) version I9500XXUEMK8. After several emails with the Samsung security team, these issues are still unpatched on the JB and KK family. This blog post details these issues and provides a potential patch. The affected driver is the samsung_extdisp and CVEs assigned are:

  • 1 Kernel memory disclosure (CVE-2015-1800)
  • 4 Kernel memory corruption (CVE-2015-1801)

1.1 - Kernel Memory Disclosure

1.1.1 - CVE-2015-1800: Video driver samsung_extdisp (1 bug)

The s3cfb_extdsp_ioctl() function, located in the drivers/video/samsung_extdisp/s3cfb_extdsp_ops.c file, contains a stack kernel memory disclosure. The structure s3cfb_extdsp_time_stamp is allocated on the stack frame. This structure contains these following attributes:

struct s3cfb_extdsp_time_stamp {
    int                 y_fd;
    int                 uv_fd;
    struct timeval      time_marker;
};

In the same function, inside the ioctl's switch case, we can find the S3CFB_EXTDSP_GET_FB_PHY_ADDR request.

case S3CFB_EXTDSP_GET_FB_PHY_ADDR:
    time_stamp2.y_fd = -1;
    time_stamp2.uv_fd = -1;
    /* ... */
    if (copy_to_user((struct s3cfb_extdsp_time_stamp __user*)arg,
                      &time_stamp2,
                      sizeof(time_stamp2))) {
        dev_err(fbdev->dev, "copy_to error\n");
        return -EFAULT;
    }

This action initializes the y_fd and uv_fd attributes but not the timeval structure. When the copy_to_user function occurs, we have a kernel stack memory disclosure of sizeof(struct timeval) bytes. This kind of vulnerability is mainly used to leak some sensitive information or break kernel ASLR if it's enabled on the device.

1.2 - Kernel Memory Corruption

1.2.1 - CVE-2015-1801: Video driver samsung_extdisp (4 bugs)

The s3cfb_extdsp_ioctl() function, located in the drivers/video/samsung_extdisp/s3cfb_extdsp_ops.c file, contains several kernel memory corruptions. An attacker can control the destination pointer (argp of the memcpy function). Here below the four ioctl's vulnerable actions cases:

case FBIOGET_FSCREENINFO:
    ret = memcpy(argp, &fb->fix, sizeof(fb->fix)) ? 0 : -EFAULT;
    break;

case FBIOGET_VSCREENINFO:
    ret = memcpy(argp, &fb->var, sizeof(fb->var)) ? 0 : -EFAULT;
    break;

case S3CFB_EXTDSP_GET_LCD_WIDTH:
    ret = memcpy(argp, &lcd->width, sizeof(int)) ? 0 : -EFAULT;
    if (ret) {
        dev_err(fbdev->dev, "failed to S3CFB_EXTDSP_GET_LCD_WIDTH\n");
        break;
    }
    break;

case S3CFB_EXTDSP_GET_LCD_HEIGHT:
    ret = memcpy(argp, &lcd->height, sizeof(int)) ? 0 : -EFAULT;
    if (ret) {
        dev_err(fbdev->dev, "failed to S3CFB_EXTDSP_GET_LCD_HEIGHT\n");
        break;
    }
    break;

The memcpy() doesn't check if the destination pointer is located in the user or kernel space. If an attacker sets the argp pointer to a kernel address, he could overwrite some function pointers or values and elevate its privileges or cause a denial of service. In this scenario he would have to use theaccess_ok() function or simply use the copy_to_user() function.

2 - Patch

If your device is under the LL family, you're safe. Otherwise, if you are under the JB or KK family, we recommend to apply this following patch which should fix these issues.

diff --git a/drivers/video/samsung_extdisp/s3cfb_extdsp_ops.c b/drivers/video/samsung_extdisp/s3cfb_extdsp_ops.c
index ee0a7dd..a1848fc 100644
--- a/drivers/video/samsung_extdisp/s3cfb_extdsp_ops.c
+++ b/drivers/video/samsung_extdisp/s3cfb_extdsp_ops.c
@@ -619,8 +619,8 @@ int s3cfb_extdsp_ioctl(struct fb_info *fb, unsigned int cmd, unsigned long arg)
        struct fb_fix_screeninfo *fix = &fb->fix;
        struct s3cfb_extdsp_window *win = fb->par;
        struct s3c_fb_pd_win *lcd = fbdev->lcd;
-       struct s3cfb_extdsp_time_stamp time_stamp;
-       struct s3cfb_extdsp_time_stamp time_stamp2;
+       struct s3cfb_extdsp_time_stamp time_stamp = {0};
+       struct s3cfb_extdsp_time_stamp time_stamp2 = {0};
        void *argp = (void *)arg;
        int ret = 0;
        dma_addr_t start_addr = 0;
@@ -761,11 +761,11 @@ int s3cfb_extdsp_ioctl(struct fb_info *fb, unsigned int cmd, unsigned long arg)
                        break;

                case FBIOGET_FSCREENINFO:
-                       ret = memcpy(argp, &fb->fix, sizeof(fb->fix)) ? 0 : -EFAULT;
+                       ret = copy_to_user(argp, &fb->fix, sizeof(fb->fix)) ? -EFAULT : 0;
                        break;

                case FBIOGET_VSCREENINFO:
-                       ret = memcpy(argp, &fb->var, sizeof(fb->var)) ? 0 : -EFAULT;
+                       ret = copy_to_user(argp, &fb->var, sizeof(fb->var)) ? -EFAULT : 0;
                        break;

                case FBIOPUT_VSCREENINFO:
@@ -787,7 +787,7 @@ int s3cfb_extdsp_ioctl(struct fb_info *fb, unsigned int cmd, unsigned long arg)
                        break;

                case S3CFB_EXTDSP_GET_LCD_WIDTH:
-                       ret = memcpy(argp, &lcd->width, sizeof(int)) ? 0 : -EFAULT;
+                       ret = copy_to_user(argp, &lcd->width, sizeof(int)) ? -EFAULT : 0;
                        if (ret) {
                                dev_err(fbdev->dev, "failed to S3CFB_EXTDSP_GET_LCD_WIDTH\n");
                                break;
@@ -796,7 +796,7 @@ int s3cfb_extdsp_ioctl(struct fb_info *fb, unsigned int cmd, unsigned long arg)
                        break;

                case S3CFB_EXTDSP_GET_LCD_HEIGHT:
-                       ret = memcpy(argp, &lcd->height, sizeof(int)) ? 0 : -EFAULT;
+                       ret = copy_to_user(argp, &lcd->height, sizeof(int)) ? -EFAULT : 0;
                        if (ret) {
                                dev_err(fbdev->dev, "failed to S3CFB_EXTDSP_GET_LCD_HEIGHT\n");
                                break;

3 - Timeline

A brief note about that work and the timeline. When we discovered these bugs (actually manually auditing some code), we were working on a totally different job. We did not look deeper at that time because we were focused on our main job and we were really not sure these were not "simple" bugs. Once our job was over, we had a quick look at these bugs. It seemed to us it was actually a bit more than "simple" bugs and wrote a report to Samsung. We did not try to exploit them as it was hardware dependent and did not had the proper device to play with. We felt such bugs were quite common in the code so we tried to get in touch with Samsung. They just acknowledged the issues, then went silent until this blog post popped. Samsung just confirmed us that the JB and KK families will not be patched and that the vulnerabilities are only patched on the LL family.

  • Feb 03 2014 - Vulnerabilities found
  • Aug 08 2014 - Report sent to the Samsung Security Team
  • Nov 24 2014 - Samsung confirmed the security issues
  • Feb 11 2015 - Private CVE request sent to the Mitre team but no response
  • Feb 18 2015 - Second private CVE request sent to the Mitre team but no response
  • Mar 16 2015 - CVE request sent to Kurt Seifried
  • Mar 17 2015 - CVE assigned: CVE-2015-1800 (1 bug) and CVE-2015-1801 (4 bugs)
  • Sep 11 2015 - Last attempt to obtain a patch from the Samsung Security Team
  • Sep 21 2015 - Still not patched by Samsung on the JB and KK families: going full disclosure

  • Sep 22 2015 - Samsung confirmed us these vulnerabilities are patched only on the LL family
原文地址: http://blog.quarkslab.com/kernel-vulnerabilities-in-the-samsung-s4.html

分布式微服务企业级系统是一个基于Spring、SpringMVC、MyBatis和Dubbo等技术的分布式敏捷开发系统架构。该系统采用微服务架构和模块化设计,提供整套公共微服务模块,包括集中权限管理(支持单点登录)、内容管理、支付中心、用户管理(支持第三方登录)、微信平台、存储系统、配置中心、日志分析、任务和通知等功能。系统支持服务治理、监控和追踪,确保高可用性和可扩展性,适用于中小型企业的J2EE企业级开发解决方案。 该系统使用Java作为主要编程语言,结合Spring框架实现依赖注入和事务管理,SpringMVC处理Web请求,MyBatis进行数据持久化操作,Dubbo实现分布式服务调用。架构模式包括微服务架构、分布式系统架构和模块化架构,设计模式应用了单例模式、工厂模式和观察者模式,以提高代码复用性和系统稳定性。 应用场景广泛,可用于企业信息化管理、电子商务平台、社交应用开发等领域,帮助开发者快速构建高效、安全的分布式系统。本资源包含完整的源码和详细论文,适合计算机科学或软件工程专业的毕业设计参考,提供实践案例和技术文档,助力学生和开发者深入理解微服务架构和分布式系统实现。 【版权说明】源码来源于网络,遵循原项目开源协议。付费内容为本人原创论文,包含技术分析和实现思路。仅供学习交流使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值