Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1371389imm; Tue, 2 Oct 2018 07:13:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV61nKl4LFNuwGF1BEIwNHbYdxktrvt8kgQfLwCSgNWfrB2ngm7qkO+gM4k6+REfFOPyqguAC X-Received: by 2002:a17:902:4001:: with SMTP id b1-v6mr17030644pld.312.1538489639018; Tue, 02 Oct 2018 07:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538489638; cv=none; d=google.com; s=arc-20160816; b=IU9i3lQtKyfvdVHktOE9UqftprS6EoRyzxvNz5gG4eQ/tjgxizY9o8yEU20Jls9G0M vzmKqQn6hJ2vBsWTEZrGgK9a/y3arAXEH/13yRWZKJjtNGf0eQv29pupJItdNI6lrx1/ mkneNbuAUdvo7YnpPdeRmSf3QXm205DAAy4WjE4YL/NZeM4vvQQw8IZNfORW3JNe3qpI DbLW6iFFWvzogAwX5cYmIU9M+0ZTneEGv+8SuGaDZ3bc/NRTiajyzMjW6qBmWVrmyxr8 4YVBmt4oazp0PBMy32gdzAvHnFIOcEZK4pySt/XZRJoj4WO64qPk0JWocWRfUECYTq+o ydvQ== 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=w45nfoqID96hUwoAkwpyLPTcWaDX10VaqGNGQcc3/eM=; b=NN4yKJftBd9FYuP4nCIAuHy/uwnjXknJ4OCZKWKDiN4RXcrg2yDt5hZs+miojLRKpa hGqmtBJi4R8vqiqOXFCOeS6juASDZVtSxiovcH2glFduSr/rrLcFcTByR+q9K9sdzgmI kGeclAg0v98uxc4GvGuv7UEoH8JS9GpwZc+2/V2h5+JbhWDocAVEostwBOZZ6spF/Ldp d6OJG2YE6Uce3vq0Z9G9Ts4aOCxJ0njqtqnTNn9VynVFV9n7bxcSFW7WGEh1pUl+ZagK gmMo7uPiIRLB6WasYXF9tmzJUX6D7WKqaMRsNjF6bHh0c31VGcHhlYp0kV4gX7W7VRBw Nu6A== 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 62-v6si16655076plc.96.2018.10.02.07.13.43; Tue, 02 Oct 2018 07:13:58 -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 S1728401AbeJBUKi (ORCPT + 99 others); Tue, 2 Oct 2018 16:10:38 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60208 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728367AbeJBUKh (ORCPT ); Tue, 2 Oct 2018 16:10:37 -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 843ABA67; Tue, 2 Oct 2018 13:27:15 +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.18 050/228] usb: wusbcore: security: cast sizeof to int for comparison Date: Tue, 2 Oct 2018 06:22:27 -0700 Message-Id: <20181002132502.543704374@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132459.032960735@linuxfoundation.org> References: <20181002132459.032960735@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.18-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 @@ -217,7 +217,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;