Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp478002ybg; Sun, 26 Jul 2020 10:33:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3ZGfJNXMMJcfUHMB6nbn9juy8Leh6lYW1NP0D/wlIr8a7Qp856lQ2Rk0rZ2Cra3Xgy/QI X-Received: by 2002:aa7:cb56:: with SMTP id w22mr8527658edt.96.1595784827263; Sun, 26 Jul 2020 10:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595784827; cv=none; d=google.com; s=arc-20160816; b=ot5ZEgaaNxtYoacmSIw/pu3HC99ckE4sfEfHoBKPLM1/nM3be/IfIT5dhbcAfHe2/e edF4Y68RpzqIfR7VSyraSTc5uKJlSMrYSDQkaO9u5lq4qHjwBzsHpYdeFKpy0YjRan7k qJ8eMCcGDMvy9450dKtXO4pKUGr1DV22PaX9bfX7GmoBvxPl/UJwzTZpXWM6RI64G2oh ipVi7kHGdjuonJP3QYOPTT246eOTSVLGxs4mUZkQCrZ2ZT90I6JV4YEshnK6X0F6IU7M cskbaGgO+hy85B3tTuj0mf4WwmboaHgTZ+1K4yO9JzYi9x3m64Kfund0NYPGRiKmp3m8 VtuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=HJgrfwr8ntWIjzCrFFi2No5i3yclxlTB0qLPCgKy4NQ=; b=ZuezVcRVoG/fB1wVLoPJ8ksKlALk7yGy1Ksu7g/rc2NJv77l5pCCpvbEZTyjv5yEKh FSfTVOxED2FE/wtPEm/sMuVZRElWqosuUBHRYPB0ErEjV2ojhBsOVNCcrW+OnIGcasKY vBtHPZCEjXXOy63lEpPJvuFT9/fS6knRW9nkZxTkJRhNZyK/viXbDb7brfjUqQGTgrTy xhnkIA+YNBiCuh/9bkdwwZZZ1xGxasW2e0T4qFvpxKfaC/vLIZVS62yE1tQEPY9w8cMX kQ7H1WL7nP4+pMe643+JWr8J6E/dJFOqHFrWVpXHRa64Z++SDITcYhb7Vlu5fJW2hU3y xQ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="J/V3fRTO"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w6si2632720ejf.470.2020.07.26.10.33.25; Sun, 26 Jul 2020 10:33:47 -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 (test mode) header.i=@ideasonboard.com header.s=mail header.b="J/V3fRTO"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726918AbgGZRaz (ORCPT + 99 others); Sun, 26 Jul 2020 13:30:55 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:47918 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbgGZRaz (ORCPT ); Sun, 26 Jul 2020 13:30:55 -0400 Received: from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6AFC9304; Sun, 26 Jul 2020 19:30:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1595784652; bh=UdBOdl3zi/qG8vkxOz0jQ4rKn6Xodg91lx+efNqwElY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J/V3fRTO7HzhURiH6YBF1+ryMV1bVsyzMJ/yr/LDzwQt8mkyIqOIOIkmkNBhiVu+w v8ngpJxW6rFXsCmpghPtyUeYGt6zUEsNzlQxefX38gYQOrSCR+gWcFe298cnmgIJKb Gcu1qf9iNVEjObczqVrP099+3n8lpZChOJdhsRm4= Date: Sun, 26 Jul 2020 20:30:44 +0300 From: Laurent Pinchart To: Peilin Ye Cc: Mauro Carvalho Chehab , Greg Kroah-Hartman , syzkaller-bugs@googlegroups.com, Hans Verkuil , Sakari Ailus , Arnd Bergmann , Vandana BN , Ezequiel Garcia , Niklas =?utf-8?Q?S=C3=B6derlund?= , linux-kernel-mentees@lists.linuxfoundation.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [Linux-kernel-mentees] [PATCH] media/v4l2-core: Fix kernel-infoleak in video_put_user() Message-ID: <20200726173044.GA14755@pendragon.ideasonboard.com> References: <20200726164439.48973-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200726164439.48973-1-yepeilin.cs@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Peilin, Thank you for the patch. On Sun, Jul 26, 2020 at 12:44:39PM -0400, Peilin Ye wrote: > video_put_user() is copying uninitialized stack memory to userspace. Fix > it by initializing `vb32` using memset(). What makes you think this will fix the issue ? When initializing a structure at declaration time, the fields that are not explicitly specified should be initialized to 0 by the compiler. See https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.cbclx01/strin.htm: If a structure variable is partially initialized, all the uninitialized structure members are implicitly initialized to zero no matter what the storage class of the structure variable is. See the following example: struct one { int a; int b; int c; }; void main() { struct one z1; // Members in z1 do not have default initial values. static struct one z2; // z2.a=0, z2.b=0, and z2.c=0. struct one z3 = {1}; // z3.a=1, z3.b=0, and z3.c=0. } > Reported-and-tested-by: syzbot+79d751604cb6f29fbf59@syzkaller.appspotmail.com > Link: https://syzkaller.appspot.com/bug?extid=79d751604cb6f29fbf59 > Signed-off-by: Peilin Ye > --- > drivers/media/v4l2-core/v4l2-ioctl.c | 32 +++++++++++++++------------- > 1 file changed, 17 insertions(+), 15 deletions(-) > > diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c > index a556880f225a..08909f58dc80 100644 > --- a/drivers/media/v4l2-core/v4l2-ioctl.c > +++ b/drivers/media/v4l2-core/v4l2-ioctl.c > @@ -3210,21 +3210,23 @@ static int video_put_user(void __user *arg, void *parg, unsigned int cmd) > 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; -- Regards, Laurent Pinchart