From patchwork Mon Jun 14 10:34:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 459801 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp3161482jae; Mon, 14 Jun 2021 03:44:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCtNzPI77uKCZmCRi+STwumj8EjcyWLqnX7lMTg59yZKp+0J9N3AREvK/YKMx1MidXBfDv X-Received: by 2002:a17:906:3042:: with SMTP id d2mr15011595ejd.234.1623667492956; Mon, 14 Jun 2021 03:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623667492; cv=none; d=google.com; s=arc-20160816; b=THn0YHn/JRvRJfc1wZ3iPiWsXzPwNaHxLD7CeAzrXNMT5XI4fs5VhUKt7Hmb/Pntx7 GNEmyzUmPZesWaJn9gFxsudEljtIvViHGG0oU3WKGOTD4xDwRuech4YcK13HkMHXmCjR JNF8yRsi+xIH6RHDyBV2giK27/5ksgTzi74uBrRpcMNn/WgIAz8nvcyAWeWt8DpeyrwZ o2ZYZiD5pBjEFEi1XT/b55Vn9ZHgqOCkOyqNK/w3oxrpQLzn6mfvMwD1uUbXuA4GoEPz RSGa1VShrQQohHDllVsn07hnu1P+pZTStEqYkjpfdD/W3qlUNI051VTYb8WRvpeVE/wF X4rA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HogR23fCuj/v0wLFKEqbSEU1ydrj1pveUcEOYw25/PU=; b=O3oxBJrescdLzx/oZeYMIz7Qz/tKnHlYcz6c0OH5hQ4948tHLk6DpHJPwl7w7o/tKP 2hFhlYRHsb5BokHbleq/9JvcZnMSOXi83kIF0GCyX/0QQ0xfg2v+UShExFXOg7arKjIb c2pOXCFvY5GiUmVk0DMpj3ZYJ9IcUVIPsSDgMn1pso90bkBYTNGxs8Ng8FKCHuv3dCbY +5iswcTnBSnKDGBbmP9LKbXWxyO3uQV7NWjQH5+2Q/+gfirwovyTlA8uU8JEohO/Xzyk bXTs4sqA/Lyh7AOTT4gZScK0x0/51iQmHBYhUXN/VWJbv561XOmBb8ABwlSlcm9bYKGL UcZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UBJtcR1Z; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si10609433edc.458.2021.06.14.03.44.52; Mon, 14 Jun 2021 03:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-media-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=k20201202 header.b=UBJtcR1Z; spf=pass (google.com: domain of linux-media-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233510AbhFNKqX (ORCPT + 4 others); Mon, 14 Jun 2021 06:46:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:50472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234096AbhFNKoI (ORCPT ); Mon, 14 Jun 2021 06:44:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 546CE6143F; Mon, 14 Jun 2021 10:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623666974; bh=xaMr2dGdBv8aHkc7XxHh77JyHfxg49iiEuvmvsKKGSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UBJtcR1Z/NaZYdmI0trZt+V091wI9YrkETLuUm+IOUdJ+vIaFIHLcyHAdFs6jP4xJ YVD9lsTA9F4lrOkG9w+YbDfzOytyqoEY2DaIM55W5wZpoRHDxJGz3i5f9hTRvq5Ng9 u3gG2sY83zIhfT5oEBSCvYI6H1DUo2uvtGoEzX1ion1ODlK9U25xUYQJ6Dm61k7cxg rUEgn4aN9j6lv2hyJoNzfKkJC2m2BUcol0jCTOlQlKnaDlH3ELWe7IIcNUGXp4fVNt Cz0OXyJyEUXVLboCwiYXhWvQc60FlggDHbg+PqowQJx/cK9R331I53iDGoTyRYVxfx tpnIDE15uaRRQ== From: Arnd Bergmann To: Hans Verkuil , Mauro Carvalho Chehab Cc: Arnd Bergmann , "Lad, Prabhakar" , Eduardo Valentin , Sakari Ailus , Greg Kroah-Hartman , Vaibhav Gupta , Liu Shixin , Laurent Pinchart , Jacopo Mondi , Andy Shevchenko , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH v3 2/8] media: v4l2-core: explicitly clear ioctl input data Date: Mon, 14 Jun 2021 12:34:03 +0200 Message-Id: <20210614103409.3154127-3-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210614103409.3154127-1-arnd@kernel.org> References: <20210614103409.3154127-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Arnd Bergmann 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 --- drivers/media/v4l2-core/v4l2-ioctl.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.29.2 Reviewed-by: Laurent Pinchart diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c index 58df927aec7e..f19e56116e53 100644 --- 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 *arg, void *parg, 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); switch (cmd) { #if !defined(CONFIG_64BIT) && defined(CONFIG_COMPAT_32BIT_TIME) case VIDIOC_QUERYBUF_TIME32: