Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3326571pxf; Mon, 15 Mar 2021 07:12:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYc/kthNakzHFHe3+exTaTg2KCcRe2pwSQEKJq5i6+uz6THWmGwruXZfwI5W6Km2S4vURJ X-Received: by 2002:a17:906:f953:: with SMTP id ld19mr23011143ejb.164.1615817523983; Mon, 15 Mar 2021 07:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817523; cv=none; d=google.com; s=arc-20160816; b=C8HvHlGARYoFg04Qeh5W+wx0uJiLHbcU9l4LVcpo92b3Oh41Yc2fGV5i9KZZQJPdl3 ozd55/xwkoZTj6Ja435v/aajYp4lVqaefgRTAgU+yohbALl+DXGySLbg+QKflrCK/tR3 TwMR2CLtIut3vjQDSPoVRasIzjZBKLUUNricBSZJuheDPvppNz7RZsYY+xKPBei8cvru oWsqI8p5O0RvdC/wIsHKOLnKkAx4dvO5Etx73MwwlMndlhfQus7DXEbIaIQjHFErUR+o mYZvQGyMKxtjezlTSD6eH17shjBMvbymmRHKy7GEsTYuIqgzVVolZI2y47rN/fhLxhad GblA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ra1g1gztjpUjiDb9hbA+Ne1VKhDNniiVfhST3+pjAKg=; b=v34erqDvW5xz2/cwOAW5B9rrbcJv8Npzxn4hnGSqNZy976wdPLX05COy0AIRfa18oM 07D9jIOPzmgD4Fw0Bsp3SP3cDEhdxNYGh0hom4P50HnNoVYUrvjOJCWUmGCGTzSibLhi jpmFS9DYGTTdp13PZFbuSAPIjKK6yAC6BqPRAe8705uXkxz9I6BoS5ZCxjnvOYo1fF4f CCseqSHA/sQEsQHkDF5UPQAcztug9JJPwmxrMCquY4CId+FJe0upt6gshA+X+y7OQuun ooKXKym4K15VYztv6iYyTYFhWegwaIc7x0IT+FhI8NQcRn/yJ/9JCWjXNPL+8J8QgSh/ 3qlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hhpKaT20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j12si11142797edp.565.2021.03.15.07.11.40; Mon, 15 Mar 2021 07:12:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hhpKaT20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbhCOOH5 (ORCPT + 99 others); Mon, 15 Mar 2021 10:07:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:35446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231129AbhCON6H (ORCPT ); Mon, 15 Mar 2021 09:58:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AE4364F4C; Mon, 15 Mar 2021 13:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816687; bh=pU6Mkp8qnpbPzD9S941lEoEagB3Zwvj40vVw/Xn+Kzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhpKaT20NHOUz5MXkfmM7Fr/cUTlkokA8mpjTiuuMzFNczBuP4KAL1knfAhL2hSdi AkS5/Rb+X0RZxGfcOTnzOylZWMvjfb/qucf8X8asUmutVb3SO+4spL3EbJw8NHCrZ1 orc3LRsOx85bUyj9cOs0hYvdZRqqwkx+9WO2PuCc= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Ripard , syzbot+620cf21140fc7e772a5d@syzkaller.appspotmail.com, Daniel Vetter , Maarten Lankhorst Subject: [PATCH 5.4 047/168] drm/compat: Clear bounce structures Date: Mon, 15 Mar 2021 14:54:39 +0100 Message-Id: <20210315135551.908735925@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Daniel Vetter commit de066e116306baf3a6a62691ac63cfc0b1dabddb upstream. Some of them have gaps, or fields we don't clear. Native ioctl code does full copies plus zero-extends on size mismatch, so nothing can leak. But compat is more hand-rolled so need to be careful. None of these matter for performance, so just memset. Also I didn't fix up the CONFIG_DRM_LEGACY or CONFIG_DRM_AGP ioctl, those are security holes anyway. Acked-by: Maxime Ripard Reported-by: syzbot+620cf21140fc7e772a5d@syzkaller.appspotmail.com # vblank ioctl Cc: syzbot+620cf21140fc7e772a5d@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20210222100643.400935-1-daniel.vetter@ffwll.ch (cherry picked from commit e926c474ebee404441c838d18224cd6f246a71b7) Signed-off-by: Maarten Lankhorst Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_ioc32.c | 11 +++++++++++ 1 file changed, 11 insertions(+) --- a/drivers/gpu/drm/drm_ioc32.c +++ b/drivers/gpu/drm/drm_ioc32.c @@ -99,6 +99,8 @@ static int compat_drm_version(struct fil if (copy_from_user(&v32, (void __user *)arg, sizeof(v32))) return -EFAULT; + memset(&v, 0, sizeof(v)); + v = (struct drm_version) { .name_len = v32.name_len, .name = compat_ptr(v32.name), @@ -137,6 +139,9 @@ static int compat_drm_getunique(struct f if (copy_from_user(&uq32, (void __user *)arg, sizeof(uq32))) return -EFAULT; + + memset(&uq, 0, sizeof(uq)); + uq = (struct drm_unique){ .unique_len = uq32.unique_len, .unique = compat_ptr(uq32.unique), @@ -265,6 +270,8 @@ static int compat_drm_getclient(struct f if (copy_from_user(&c32, argp, sizeof(c32))) return -EFAULT; + memset(&client, 0, sizeof(client)); + client.idx = c32.idx; err = drm_ioctl_kernel(file, drm_getclient, &client, 0); @@ -850,6 +857,8 @@ static int compat_drm_wait_vblank(struct if (copy_from_user(&req32, argp, sizeof(req32))) return -EFAULT; + memset(&req, 0, sizeof(req)); + req.request.type = req32.request.type; req.request.sequence = req32.request.sequence; req.request.signal = req32.request.signal; @@ -887,6 +896,8 @@ static int compat_drm_mode_addfb2(struct struct drm_mode_fb_cmd2 req64; int err; + memset(&req64, 0, sizeof(req64)); + if (copy_from_user(&req64, argp, offsetof(drm_mode_fb_cmd232_t, modifier))) return -EFAULT;