Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1399383ybh; Thu, 23 Jul 2020 08:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoKn6ZGoQ9z9slAhqkNZNzcZIzytW3cnLG+VXH3F+jIUNBUqIEPJOOnxJa8nBlCNUFT26A X-Received: by 2002:aa7:d043:: with SMTP id n3mr4710447edo.102.1595516452292; Thu, 23 Jul 2020 08:00:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595516452; cv=none; d=google.com; s=arc-20160816; b=kUNdk9BrnXzT2ATNPJPQMvdHRbEan/+547ugBMaP3lObo5DOS20u+AlZCQCH9+vdeI scl1T0Z7oY78eKdvDhxx8EkkyyhDYQ3k1lJLFK40RaTe3Zb/MX+lv/mKR4j3ic988R1c Nb46RqLtzFCth1DWWMkx/H/aWpuibpmGuHqb7kWWQVYVrCF/419INN1SOQrFD4QYfYvr d1Vbl7bUeuKEC3pUMzsAZs801kmiLD1zkXCOQoLblGdG6zOqmp7mNWdqkKawzVIrNJus P8738iMgPPoqdxvX1leI9FFw/dJbnBs+rma4wSMRXhUMvCgUVo+7UE0NADsyxNwg8BU7 mTDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=QD+gsbMYRKDaNex8SR5DKLX3QE6D+DALwWb0wdzz4Xs=; b=dveULLS+Zk3BnMEfN6oJJAaxmUKrbmeVQVB++yK5c/8lkizq7nBA8or7AzjmlyiB33 Wz1LDVi7AlxtYnqSM6Uiu4vNmokMXWrEKQS6Pidy+nB1VKSVQqmFkKRTPSwkhCO1aN4v elwx3T3+lAtxXR3AO5vWbOKQpkT4F4hVP5cVrCzcbN+z2GSZj9gnO3TQ6/6rpQAcoM4R KnJUDTSQ+OHql/Fz56ZaPdkVE/0WSvGTgEg/jcdkmBLRq0haoHuM8Pyj8kWzzbq/3Q85 6Zi/6zIJIWsPWifZ/fjckIvSEejxO6cm1vltqvZJDjKQUYJutEpoI9mN7QWS7SYNa0Gt aTLw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gj24si2124575ejb.139.2020.07.23.08.00.28; Thu, 23 Jul 2020 08:00:52 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729482AbgGWO7o (ORCPT + 99 others); Thu, 23 Jul 2020 10:59:44 -0400 Received: from mga09.intel.com ([134.134.136.24]:50088 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729471AbgGWO7n (ORCPT ); Thu, 23 Jul 2020 10:59:43 -0400 IronPort-SDR: m6Har90y6gD0BdJ5DWG9AVm2eoE0NalWau6FjY5ahwzkInvnWY50zzBnn5fTiGDYLQo6r5mhM+ +M+X3uIKe4xg== X-IronPort-AV: E=McAfee;i="6000,8403,9690"; a="151839019" X-IronPort-AV: E=Sophos;i="5.75,386,1589266800"; d="scan'208";a="151839019" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jul 2020 07:59:43 -0700 IronPort-SDR: StcE0bSg8qHZFrbi+u65usLAWxIOiou07afJRHhIQaB3TbGAo1wa+NDQ2wW+ewNqEC34kFkjAb RSkkAiY1HSGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,386,1589266800"; d="scan'208";a="311051190" Received: from twinkler-lnx.jer.intel.com ([10.12.91.138]) by fmsmga004.fm.intel.com with ESMTP; 23 Jul 2020 07:59:41 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, Tomas Winkler , "Gustavo A . R . Silva" , Arnd Bergmann Subject: [char-misc-next 2/6] mei: ioctl: use sizeof of variable instead of struct type Date: Thu, 23 Jul 2020 17:59:23 +0300 Message-Id: <20200723145927.882743-3-tomas.winkler@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200723145927.882743-1-tomas.winkler@intel.com> References: <20200723145927.882743-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use sizeof(connect_data))) instead of sizeof(struct mei_connect_client_data) when copying data between user space and kernel. There is a possibility of bug when variable type has changed but corresponding struct passed to the sizeof has not. Cc: Gustavo A. R. Silva Signed-off-by: Tomas Winkler --- drivers/misc/mei/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c index f17297f2943d..05e6ad6d4d54 100644 --- a/drivers/misc/mei/main.c +++ b/drivers/misc/mei/main.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) 2003-2018, Intel Corporation. All rights reserved. + * Copyright (c) 2003-2020, Intel Corporation. All rights reserved. * Intel Management Engine Interface (Intel MEI) Linux driver */ @@ -476,7 +476,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) case IOCTL_MEI_CONNECT_CLIENT: dev_dbg(dev->dev, ": IOCTL_MEI_CONNECT_CLIENT.\n"); if (copy_from_user(&connect_data, (char __user *)data, - sizeof(struct mei_connect_client_data))) { + sizeof(connect_data))) { dev_dbg(dev->dev, "failed to copy data from userland\n"); rets = -EFAULT; goto out; @@ -488,7 +488,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data) /* if all is ok, copying the data back to user. */ if (copy_to_user((char __user *)data, &connect_data, - sizeof(struct mei_connect_client_data))) { + sizeof(connect_data))) { dev_dbg(dev->dev, "failed to copy data to userland\n"); rets = -EFAULT; goto out; -- 2.25.4