Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1337690imm; Tue, 2 Oct 2018 06:45:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV61fZFg3PfJHn1n9RV+nW1Mbmx5hdvh5JhuolTj5ocDJWiIQJiFjM9Wj1rR/e3hCAAxsXacW X-Received: by 2002:a17:902:650f:: with SMTP id b15-v6mr16648236plk.2.1538487907050; Tue, 02 Oct 2018 06:45:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538487907; cv=none; d=google.com; s=arc-20160816; b=F937EigiryBiubwND7qzeiOa/S7ENeovBm4v0yADBaPS1Owon2DvpIT865hwG9qEfG VSV2HFZOp3PZlKmB/1u8gdxjS+YBpNPGLf/Ozv+gH4JXiSoRt6X4DugXBMD7MrQwVDrl MjAKM3nksbBrDs22kDb0uwRFdi1F6TZ2JpwvPqmDLfysyHncqGJss3N3rnc4zYyt/rYG 3tqY/h1ty3YGBDBxd4jRSQPfCvd4Mr6ZDMyWa/5ZkfJ+na4ojl7F9CPWAAPQZg4upqqP JZOBX6Nt5X4UDYNlWwEWPUClhqVJDeLeH7hf4uwtjrUjPk/o2rhKGGW51g8GQqY/OE3w H+Pw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=C6l1jfLPXB7aISw1jGsR2LLpLJlkPStPVr4WRpxTSzE=; b=uesUJpxERv++b9Ufc2WsuB44pCFgop6tV3m63WrP70rx/2SXq2cko+UD+V9Jnxe6Mb ut7wJvfhPZ0lGdtv5KLhwzsta5PZ24tT1JN80VcRGVkeicTlqQUJrJiXUPXttyWIkRsY +j7iBX8qn4HBVGg/S60ys1dOHJm8Hvn54k/DPAp9Z31jSHr9wN/ldCZphLi8gnCzsrGk XzJR429oLI8Ih8Jocr31c+C7PUmkVQv3dpnHTt7SzAfD6c5MohfYgBT5UagrZK/lzwsF z0x0B5rCsJxwWWbuCChPXIAOaRDDQKpsaIU2B9dFIdp7bC+r/zAR7Jp4e6JFZEtl2NTg O/SQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d127-v6si17424272pfa.189.2018.10.02.06.44.52; Tue, 02 Oct 2018 06:45:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732873AbeJBUTQ (ORCPT + 99 others); Tue, 2 Oct 2018 16:19:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35870 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732848AbeJBUTQ (ORCPT ); Tue, 2 Oct 2018 16:19:16 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id CF93EC2B; Tue, 2 Oct 2018 13:35:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julia Lawall , Sasha Levin Subject: [PATCH 4.9 25/94] usb: wusbcore: security: cast sizeof to int for comparison Date: Tue, 2 Oct 2018 06:24:39 -0700 Message-Id: <20181002132502.263311089@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132500.494838053@linuxfoundation.org> References: <20181002132500.494838053@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Julia Lawall [ Upstream commit d3ac5598c5010a8999978ebbcca3b1c6188ca36b ] Comparing an int to a size, which is unsigned, causes the int to become unsigned, giving the wrong result. usb_get_descriptor can return a negative error code. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @@ int x; expression e,e1; identifier f; @@ *x = f(...); ... when != x = e1 when != if (x < 0 || ...) { ... return ...; } *x < sizeof(e) // Signed-off-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/usb/wusbcore/security.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/wusbcore/security.c +++ b/drivers/usb/wusbcore/security.c @@ -230,7 +230,7 @@ int wusb_dev_sec_add(struct wusbhc *wusb result = usb_get_descriptor(usb_dev, USB_DT_SECURITY, 0, secd, sizeof(*secd)); - if (result < sizeof(*secd)) { + if (result < (int)sizeof(*secd)) { dev_err(dev, "Can't read security descriptor or " "not enough data: %d\n", result); goto out;