Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1356269pxk; Fri, 4 Sep 2020 07:29:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/Db7bP/4rwE5dbhc6ix5tl33bK+ItAU9xpMiEt2olJLmddZ+6ksZ1RsuQ/wR3SUYOuGAG X-Received: by 2002:a17:906:af92:: with SMTP id mj18mr7512422ejb.242.1599229766992; Fri, 04 Sep 2020 07:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599229766; cv=none; d=google.com; s=arc-20160816; b=BzJ2BkEv4FLeJppJolLiIwdVJFZETiph6f5pLRCd2O/DBvhTIY0K/9TkCmz9EWv9N8 KOg1xFBfFQ5gcm3ojWlGSjLYh8TWeoNLKmK6HLC394OwDLLKeuXy40jFfqL/1SSSrOQ7 F61s+xyOFYUKvwOt8ZJsnKD89cT9OoeXWYuk8U7vMObqsv0r6IVudaDySh99yw61J31W cdyej9LYIYDepceYuamirw+99AqP4DYp7POT0oF7R275neWkdE7UoApV6lFYJ0uXgsam dSvw4KhqrsP36+V+jKCSY6S/hqEFvyP+cpab+xy5jSY8J4Clv9Vo/cskG5CpP83tIsEb lnRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rCFed1MMrxJLUDqGZgei6LDaEMdHWYJI8iZ1rm2Xcq8=; b=QjeiQ2HDpS8oKpzfVpPRUqFOUo+e/2/uTEc63z4BAJ5zBuaZODsDTSvfVCTf1DJnmJ dik9NyoJ/8gELEYLL3lnReP0V39+vKtRzwAsQPUGPD8JeoEozwqiptbSBGtl02DJbFGX UOycAPzSJGyzOm8z94dMN0vFrKyvF9gsL2bgWU5+rDaOf3yQo6B7/KUIb6XVFnWXpES5 s5cRoNJr0mpj+fIxNhvMh+nW17VAPP8R80J2U9cn2+mo1IRptqG1zNlmavVP4AQ8nWZC /Oy4bWsdhkJrJ++XHodAbsQ2a+gzus3E33JFICkKwwFJ6+VsfNnzMfGDrY9CR3Vkgncw DbGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=COHiWJLE; 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=fail (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 r25si3984575edo.12.2020.09.04.07.29.03; Fri, 04 Sep 2020 07:29:26 -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=@kernel.org header.s=default header.b=COHiWJLE; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730800AbgIDO0p (ORCPT + 99 others); Fri, 4 Sep 2020 10:26:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:38084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730469AbgIDNeX (ORCPT ); Fri, 4 Sep 2020 09:34:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5FD712168B; Fri, 4 Sep 2020 13:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599226264; bh=BxUZNLAprx2ZNy1EjFaO8fkvg3UKlR/PaDsQLdY9Mgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=COHiWJLEOjm913yP+bctzKEUMeUtQeFOSw+1NqsW6wyKxfQX7rR+qgmsHP5WlC5ww ai/uMtUos4pPODS5Fesc9bK4iEafq991dvarvASup/YKpP5G8rUqQB9idB0F+iE8SJ YnLm2tltAYjvqW78gJpNz3gWtpR6NJ6DF0OTtx6I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Pinchart , Arnd Bergmann , Peilin Ye , Hans Verkuil , Mauro Carvalho Chehab , syzbot+79d751604cb6f29fbf59@syzkaller.appspotmail.com Subject: [PATCH 5.8 07/17] media: media/v4l2-core: Fix kernel-infoleak in video_put_user() Date: Fri, 4 Sep 2020 15:30:06 +0200 Message-Id: <20200904120258.352370251@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904120257.983551609@linuxfoundation.org> References: <20200904120257.983551609@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peilin Ye commit 4ffb879ea648c2b42da4ca992ed3db87e564af69 upstream. video_put_user() is copying uninitialized stack memory to userspace due to the compiler not initializing holes in the structures declared on the stack. Fix it by initializing `ev32` and `vb32` using memset(). Reported-and-tested-by: syzbot+79d751604cb6f29fbf59@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=79d751604cb6f29fbf59 Cc: stable@vger.kernel.org Fixes: 1a6c0b36dd19 ("media: v4l2-core: fix VIDIOC_DQEVENT for time64 ABI") Fixes: 577c89b0ce72 ("media: v4l2-core: fix v4l2_buffer handling for time64 ABI") Reviewed-by: Laurent Pinchart Reviewed-by: Arnd Bergmann Signed-off-by: Peilin Ye Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-ioctl.c | 50 ++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -3186,14 +3186,16 @@ static int video_put_user(void __user *a #ifdef CONFIG_COMPAT_32BIT_TIME case VIDIOC_DQEVENT_TIME32: { struct v4l2_event *ev = parg; - struct v4l2_event_time32 ev32 = { - .type = ev->type, - .pending = ev->pending, - .sequence = ev->sequence, - .timestamp.tv_sec = ev->timestamp.tv_sec, - .timestamp.tv_nsec = ev->timestamp.tv_nsec, - .id = ev->id, - }; + struct v4l2_event_time32 ev32; + + memset(&ev32, 0, sizeof(ev32)); + + ev32.type = ev->type; + ev32.pending = ev->pending; + ev32.sequence = ev->sequence; + ev32.timestamp.tv_sec = ev->timestamp.tv_sec; + ev32.timestamp.tv_nsec = ev->timestamp.tv_nsec; + ev32.id = ev->id; memcpy(&ev32.u, &ev->u, sizeof(ev->u)); memcpy(&ev32.reserved, &ev->reserved, sizeof(ev->reserved)); @@ -3207,21 +3209,23 @@ static int video_put_user(void __user *a case VIDIOC_DQBUF_TIME32: case VIDIOC_PREPARE_BUF_TIME32: { struct v4l2_buffer *vb = parg; - struct v4l2_buffer_time32 vb32 = { - .index = vb->index, - .type = vb->type, - .bytesused = vb->bytesused, - .flags = vb->flags, - .field = vb->field, - .timestamp.tv_sec = vb->timestamp.tv_sec, - .timestamp.tv_usec = vb->timestamp.tv_usec, - .timecode = vb->timecode, - .sequence = vb->sequence, - .memory = vb->memory, - .m.userptr = vb->m.userptr, - .length = vb->length, - .request_fd = vb->request_fd, - }; + struct v4l2_buffer_time32 vb32; + + memset(&vb32, 0, sizeof(vb32)); + + vb32.index = vb->index; + vb32.type = vb->type; + vb32.bytesused = vb->bytesused; + vb32.flags = vb->flags; + vb32.field = vb->field; + vb32.timestamp.tv_sec = vb->timestamp.tv_sec; + vb32.timestamp.tv_usec = vb->timestamp.tv_usec; + vb32.timecode = vb->timecode; + vb32.sequence = vb->sequence; + vb32.memory = vb->memory; + vb32.m.userptr = vb->m.userptr; + vb32.length = vb->length; + vb32.request_fd = vb->request_fd; if (copy_to_user(arg, &vb32, sizeof(vb32))) return -EFAULT;