From patchwork Thu Jul 15 18:40:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 477457 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp583462jao; Thu, 15 Jul 2021 12:17:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRFkX2A090qBcbfBd1Uzj+MlfLkZT/zNTWuSJxN4xUn6mGjIAWiacfdL4CyjjaZ4CpDi+u X-Received: by 2002:a5e:9602:: with SMTP id a2mr4407265ioq.146.1626376666054; Thu, 15 Jul 2021 12:17:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376666; cv=none; d=google.com; s=arc-20160816; b=c4s+iQi+vOMY6Fcara6/UJ0xtSpDztvUV9tX/QNmR1LIDiQOXlK12qzXELGtl+dP0K RYdtQj+z33jysoJuRVmLHnNtLoVW8tXz4ug4H53OrDyc2u6PH7Z/s4X7ulzeSqeYdZ2P ywZ1knYc5ctfJta1l3sVHgMw8oF9hQSY57gisJc9wuUbojEZ8xenlLJyUylkSiINfz2+ mPRyj1jttsou2CwgR9H36Qm7G372IjEnLKOhOUIeAZ0Z5rK/gFR1vNpiH8sUPMd4GppT mwiLjsKIULfOYa40b22MI1qahEeCOVN3G7EJDS4I3YMLGWj9ibMCF6zgfllyDHLT8t45 t0rA== 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=vkwcjE0W/WsfJ8iAcydsIO+NMrjfv+Rn/cTBRDr4Puc=; b=eyApIGhT+2jn7B9aaa0Nmzl3has9OCphXxIZktW2ybwzEb1Yw9LjgOGpxrg3blPU1/ 29yZd+aBnjGg9WF3LTTVE28M3yLxJYDXMaCHRp2zJlg1/YO6XCXAUxRblvZPuxPuwoc/ SxDjWu53BRiacofp1kWSmPyBe/UefcyePTNBPK3PYGvmKtFbSIKE7YAS4n+uVXmOoSyn w+RvOUiM87CiYZkE01TJVlXDAf4fVXc/c745RqPNYnJ6EZnKg/aYrfoWQ+Uls186yAIK DMY/KTArUIzS06a/SMO+Dxa9W37PBapdZUw/ksxSGG2nE387Naam4IsL8JclnWnZyDDH xkCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xecu3Ww7; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 w5si8303152ilu.14.2021.07.15.12.17.45; Thu, 15 Jul 2021 12:17:46 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=xecu3Ww7; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S1343508AbhGOTUY (ORCPT + 12 others); Thu, 15 Jul 2021 15:20:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:58474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243412AbhGOTSm (ORCPT ); Thu, 15 Jul 2021 15:18:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A7B5161158; Thu, 15 Jul 2021 19:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376419; bh=2bHFb3E+HFcUoTnG9M5Bm+wjMeg1RvtsMh3EYOc2xIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xecu3Ww7YgFh/2OexSYdNiyJK0KvhfyjtG2ujAIfLXveWBDTnx5boPQlrJC2eB8Dq JN2DJy8YoCuVU9V7WlRfCsDmpMpmMGOC0s6ZJehCgCivl3zt7UXVJoO0fibspoX+wf dNkWpk/jOkgUlMY9FFbRejtX5X2YwcGkrEwFU5lo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Laurent Pinchart , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.13 264/266] media: v4l2-core: explicitly clear ioctl input data Date: Thu, 15 Jul 2021 20:40:19 +0200 Message-Id: <20210715182653.481266998@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann commit 7b53cca764f9b291b7907fcd39d9e66ad728ee0b upstream. As seen from a recent syzbot bug report, mistakes in the compat ioctl implementation can lead to uninitialized kernel stack data getting used as input for driver ioctl handlers. The reported bug is now fixed, but it's possible that other related bugs are still present or get added in the future. As the drivers need to check user input already, the possible impact is fairly low, but it might still cause an information leak. To be on the safe side, always clear the entire ioctl buffer before calling the conversion handler functions that are meant to initialize them. Signed-off-by: Arnd Bergmann Reviewed-by: Laurent Pinchart Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/media/v4l2-core/v4l2-ioctl.c +++ b/drivers/media/v4l2-core/v4l2-ioctl.c @@ -3124,8 +3124,10 @@ static int video_get_user(void __user *a if (copy_from_user(parg, (void __user *)arg, n)) err = -EFAULT; } else if (in_compat_syscall()) { + memset(parg, 0, n); err = v4l2_compat_get_user(arg, parg, cmd); } else { + memset(parg, 0, n); #if !defined(CONFIG_64BIT) && defined(CONFIG_COMPAT_32BIT_TIME) switch (cmd) { case VIDIOC_QUERYBUF_TIME32: