Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp594900imm; Wed, 4 Jul 2018 02:36:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpePEFb0kie9S85qEZWcorg/SNpB3tP0ZBrntBBMsMRhDRUb77psY3JDwirnHU22fYVbdG6v X-Received: by 2002:a63:7b4d:: with SMTP id k13-v6mr1245109pgn.64.1530696985448; Wed, 04 Jul 2018 02:36:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530696985; cv=none; d=google.com; s=arc-20160816; b=P6UbXv+ReZ9CdT7AsVx3dnLSQGtMdcWkW3rvjFXgzhT3PsFRqAXM/afkM4GI0YDunl byAEkVAh4gKWshncxncgPDkfyzmHRK/fGEie1wGvrHkSqk11ZmPt7HYTRQaFMdP0xYg7 Vz7VSQ2aXzlvPK9IN4UmBwjU6rijmFfK2our/AJ9DQ/PFz/SSUrIhrOTj/i0t18Y0CXo wYXEN6VDSH4REJOltr4ay99PIwCWVejDq9d9Tc5wQYybXyveV7NWYGbyUYbV9nsu8HAo fXLfszOYbAYhv/fevw52oe/1UWXacPVrGoxq2uKak42CyYDkMgp/FLPMGXcHuQtrDMVM n/oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=V2PrX6yVXKuo/BloQrUYec1MrHFxoeFp5fq3qKwP6VI=; b=v8OtZ56YTBgRaxIq5NsxGyKBs/LSVHM+04eCkpd4gqs2ewge1ERxrYHR/hj/bxCS/6 Vj09rd9trDcaVYmAQkBN9mhhc5ofRHUDwleHWMW06J/sPlD35Pe+EpouT5+JihtF281P kJ+rjvbuTjd60ocvXNTn227NUpdmKgtG5aVcOtYY24jGqZ0DDQ1wcrlK4sZWDVof5oMQ S+v2qVNn2l6FBetzlpmOTVvXHbIJl21YDBzAbvi233AlVD3zMEVmVTufzEBn6AFzNcKD pHljVR4P0jzE2e2k5KpgUx25pVttdSt2uwv+ge+WxoPQmM/yJn9erpLKU0SJDVNd8IIc 10Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=DbzAOvNJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y187-v6si2857422pgd.459.2018.07.04.02.36.10; Wed, 04 Jul 2018 02:36:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=DbzAOvNJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932745AbeGDJfP (ORCPT + 99 others); Wed, 4 Jul 2018 05:35:15 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:49942 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932399AbeGDJfN (ORCPT ); Wed, 4 Jul 2018 05:35:13 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w649Xo8U032986; Wed, 4 Jul 2018 09:35:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=V2PrX6yVXKuo/BloQrUYec1MrHFxoeFp5fq3qKwP6VI=; b=DbzAOvNJnePkLnpsvr/+LXcPS2o/6o1+jH8gej3R1udlJmzYGYAoqVIQ/ZPqX/l+js7f F1lhOHXd9kTnpHv+gGGC86mjEpwDaq/kRwZJ6PT6SN7y1HBj3pa4yQygiyOL+wAmyL6b 9SVh3upR52KCsXYFdkU2PMGSgaymfORvNTxYj/Y9ETsItBbZLb1r3/2sw/CBcfcVJ7xt uSbQEkIwPPMuT9S7oQb6XAMoEXURQh/ScocpUhcWl09KG1t/dLTpu6L2zlMe+8AppID1 heju3gVPTCbNhQgaq60SPhvsRwgG5+D/QFr7f1xrVNUNsp59HpnZiGwbedXwzM/rn2nO Zw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2k0dnjj47k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Jul 2018 09:35:07 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w649Z7eu009835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Jul 2018 09:35:07 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w649Z6C9012804; Wed, 4 Jul 2018 09:35:07 GMT Received: from kili.mountain (/197.157.34.168) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Jul 2018 02:35:06 -0700 Date: Wed, 4 Jul 2018 12:34:49 +0300 From: Dan Carpenter To: Tomas Winkler , Alexander Usyskin Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] mei: bus: type promotion bug in mei_nfc_if_version() Message-ID: <20180704093449.vryluk7khaudstgp@kili.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8943 signatures=668704 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=977 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807040114 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We accidentally removed the check for negative returns without considering the issue of type promotion. The "if_version_length" variable is type size_t so if __mei_cl_recv() returns a negative then "bytes_recv" is type promoted to a high positive value and treated as success. Fixes: 582ab27a063a ("mei: bus: fix received data size check in NFC fixup") Signed-off-by: Dan Carpenter diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c index 0208c4b027c5..fa0236a5e59a 100644 --- a/drivers/misc/mei/bus-fixup.c +++ b/drivers/misc/mei/bus-fixup.c @@ -267,7 +267,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, ret = 0; bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length, 0); - if (bytes_recv < if_version_length) { + if (bytes_recv < 0 || bytes_recv < if_version_length) { dev_err(bus->dev, "Could not read IF version\n"); ret = -EIO; goto err;