Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1348497imm; Tue, 2 Oct 2018 06:55:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV636n8LHCe/sWx+t9afKbdnxGKeE5zieqiPaK0edQXgOY/bUi8EVhQdWMLZnxsFFRtfWSDbh X-Received: by 2002:a17:902:a716:: with SMTP id w22-v6mr16997266plq.334.1538488518658; Tue, 02 Oct 2018 06:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538488518; cv=none; d=google.com; s=arc-20160816; b=Rx9B4ycxd+nwZ2wfBwdA0QaHKp6RWrkigUO8sx43dX/PkkQqakph6njCGHrUKJQmtB XvU+Du8OuWglU7P/kagRX4GEDGtNWxYerIdt3agEKe5hAKr1wchnxqSPPP6oXb60EGlT 4sExwq1Eh1+2zDj71wgI0b+kyWch4LK64+JbG5aJmebC+0D5+wL8QrSGvl7nzUQ7HrpO Nj8ytNiB5VfzVp71/rWSvF5FnHi9e0wWkIUdBKV0LapW/0WJdwnmqCsB+HXFIlYxYfST NVlPPbvGVjdObjG/qahLehIizJbazatiMVC2j7TlqOuOvFSRaw1x9qlR30W9lgUj5Bem JYew== 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=jXYeAIygiBPcd88i8WGSTXSmIv8v347nEaB07MhXSwM=; b=TNxDmu7UKImU8WB21n7B95YBKH5uivbN2xqTp1uB44W2mWrtR/Y2pTMRp5no2/xRX5 6B1rYM7Xp/qg3NN/TsiXHiczdOrKRBE9ro9gSSKdSNWhSskMZ4dh3XKowH3j4dKFoYvr mCGu5d1nsz9lZwLx32WOlHTeP7Q4N6BSa11J6QkfUHy3+3um2GE40NvkkR5rKji9SUtO Tt6NbQBTfhDaBe8uSmnTyxV48hq4idbGV0ve/HxEa8gAMLOiEgM3hRK+SwNX1Wvp43Pg eKWGiDkqiNZhwNZ4aeEMtHg8JvfkruEoA4pcWz6KE1h8oX9QFpDDko9diJhxhTWCCxyn aSHw== 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 w9-v6si15511778pll.138.2018.10.02.06.55.03; Tue, 02 Oct 2018 06:55:18 -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 S1731380AbeJBUPs (ORCPT + 99 others); Tue, 2 Oct 2018 16:15:48 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34498 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730304AbeJBUPr (ORCPT ); Tue, 2 Oct 2018 16:15:47 -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 E471E5AA; Tue, 2 Oct 2018 13:32:24 +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.14 036/137] usb: wusbcore: security: cast sizeof to int for comparison Date: Tue, 2 Oct 2018 06:23:57 -0700 Message-Id: <20181002132501.012944419@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132458.446916963@linuxfoundation.org> References: <20181002132458.446916963@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.14-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;