From patchwork Thu Jul 15 18:40:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 477452 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp571841jao; Thu, 15 Jul 2021 12:05:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy4OsvxawoOrhBqEZG3r5RNmG8blZ0UMYHSzL9L/+B3MSvOoMmxAUbUIf2wT85tvNi6vmU X-Received: by 2002:a05:6602:1492:: with SMTP id a18mr4368630iow.200.1626375910797; Thu, 15 Jul 2021 12:05:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375910; cv=none; d=google.com; s=arc-20160816; b=d9ILe/4Jx6JKix6lq1Yzpp/p7Uf41GeMwqcNB2TMNiYQtLUqUTpUirzBjSa2hQqM6X Kx2C+BCFJ/BWlWhi5oBnm6I2yK0wDCBkvSBg4zwBtBKxZiv1uvD5h4XrK+UUAEgV5Udw g9hGBZFxv0fTDD0TPcm0ytvyv8BOauSnkZImErY1Kco+Ki3JELsk3AdoqkItTSI/gBWm agjKwHPTcvQynl7rjaSzURyAcFUIanzQU+4/2msm/lZzUUSUeRj8bXywJ6+n63zJM1xD 89O0wTBKinCLuHitVmdHaiCgiOr36qWqQvewKnGRalSzDvorcOwMrpzurwNwoygqt1bN +sNw== 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=YFUqZfWI7RxqCfN/M392CsH97zjfYe2EE4cfdf4iQfo=; b=IcVJB/ghxJFhHADEzeDIdfqxT0xlQ1EH8/R+CD+SgZM08lfMSGaAASoTvm8r/SNmEQ T7skwQLoCrxmh0/ydBtjh/BWZJXCencY9wiUUCh2mFK2Mpr/BtKxTbcehy1MukymUOHx 0XJ9IjMV9q8LNObYJ6Ev5QiryBuL1by4uOgHdrOvp99XaxDcIUObeNAvz4x5k34fpY0I XQCT+5G8yQMSBM4stF25xB2w7VGbsRXzLNjsJFY4YBqJTunE8w9HtypbjhD8N67QWRnY G8YynSy3Jb2PJGac/lG5mSBKi/uxqIzjoEGD8EqBsddbQ3ZYVg+5Gg5dpV5fEPOrwnQB NczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uqHHUam8; 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 d5si7135922ilr.23.2021.07.15.12.05.10; Thu, 15 Jul 2021 12:05:10 -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=uqHHUam8; 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 S241909AbhGOTH5 (ORCPT + 12 others); Thu, 15 Jul 2021 15:07:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:46538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241596AbhGOTG4 (ORCPT ); Thu, 15 Jul 2021 15:06:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9C5C161412; Thu, 15 Jul 2021 19:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375797; bh=feewwdOoKwoxjQtypCouCsjy4aJHDB7WzTa5g28dmaY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uqHHUam8YDlLcBKdXAiQJtwI7UHXSU51V+B892FOcT+avWfapD94DYCj1LZstun04 YZZSfK1fwKQThxgMlgL5HbvQR19h5gXkhmkT7OTa17sYKgbjY8qpd+ZtPoWLDuAZHF vXvbvQFCd94EatxZ0KEphuwuz7EesFHFz0KH+aYY= 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.12 239/242] media: v4l2-core: explicitly clear ioctl input data Date: Thu, 15 Jul 2021 20:40:01 +0200 Message-Id: <20210715182634.914664628@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 @@ -3166,8 +3166,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: