From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FB90C433E7 for ; Tue, 1 Sep 2020 16:56:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C609206C0 for ; Tue, 1 Sep 2020 16:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598979362; bh=CuavRm0CKBzQlhflULSq+Uof+b5mUZFbdVDsHUwhgfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g42o33cb09aPhYs8iQnueZmEx/8ktRomS1uVCZfLg+o15W2eUmDF7gugTE1YCDzI9 8wHDLKD2YF5PG2lQqNa0vPNCEaKTDo+ZTOkWvDXoR0bmbIWgB/+cqeKyVeSO59sckX YYiJymHrfEMJnO5d3kuIDVYk6PtFa17nk4UY6iVw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729922AbgIAQzi (ORCPT ); Tue, 1 Sep 2020 12:55:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:47356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728695AbgIAPXz (ORCPT ); Tue, 1 Sep 2020 11:23:55 -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 46C3A20BED; Tue, 1 Sep 2020 15:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973834; bh=CuavRm0CKBzQlhflULSq+Uof+b5mUZFbdVDsHUwhgfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XChBdBYRBs4+VMu4fIpRDvSLB2nFYk6ccm7b15t2lAKXfx+7HVDochKKqZWFal1y9 ol7B+DJYXmg2Bzl0Ma4Gjr034g/4sN3kbhj1ZwnbR5k+El6A2WbcGd35wl87rlqlVf 09y463VSAOLgKWduDiQQ7vWf1ITzhZqVYsiH4pAA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.19 035/125] cec-api: prevent leaking memory through hole in structure Date: Tue, 1 Sep 2020 17:09:50 +0200 Message-Id: <20200901150936.284081905@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150934.576210879@linuxfoundation.org> References: <20200901150934.576210879@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: Hans Verkuil [ Upstream commit 6c42227c3467549ddc65efe99c869021d2f4a570 ] Fix this smatch warning: drivers/media/cec/core/cec-api.c:156 cec_adap_g_log_addrs() warn: check that 'log_addrs' doesn't leak information (struct has a hole after 'features') Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/cec/cec-api.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/cec/cec-api.c b/drivers/media/cec/cec-api.c index 4961573850d54..b2b3f779592fd 100644 --- a/drivers/media/cec/cec-api.c +++ b/drivers/media/cec/cec-api.c @@ -147,7 +147,13 @@ static long cec_adap_g_log_addrs(struct cec_adapter *adap, struct cec_log_addrs log_addrs; mutex_lock(&adap->lock); - log_addrs = adap->log_addrs; + /* + * We use memcpy here instead of assignment since there is a + * hole at the end of struct cec_log_addrs that an assignment + * might ignore. So when we do copy_to_user() we could leak + * one byte of memory. + */ + memcpy(&log_addrs, &adap->log_addrs, sizeof(log_addrs)); if (!adap->is_configured) memset(log_addrs.log_addr, CEC_LOG_ADDR_INVALID, sizeof(log_addrs.log_addr)); -- 2.25.1