From patchwork Tue Aug 21 09:59:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 10571321 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AAA7E139B for ; Tue, 21 Aug 2018 10:00:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AE6829D5C for ; Tue, 21 Aug 2018 10:00:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 985BD29DE5; Tue, 21 Aug 2018 10:00:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 18B7D29D5C for ; Tue, 21 Aug 2018 10:00:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726798AbeHUNTp (ORCPT ); Tue, 21 Aug 2018 09:19:45 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34133 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbeHUNTp (ORCPT ); Tue, 21 Aug 2018 09:19:45 -0400 Received: by mail-lj1-f194.google.com with SMTP id f8-v6so13850854ljk.1; Tue, 21 Aug 2018 03:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=z/Jz+Y1mP+IuEAo9VZmu0MfVOu2WRcNx9ZQ7uwlCXaU=; b=hbH9aAiA5iQXszHIY7Qw8LuxJtN0ahiXsnkRq4kIx0pVk+9Kduej6ZdlVYYvxVnR2R 13mTFbUdUiyTLC1Stoon5wVnRATwzsgsM61Ej3bTJW+cvAAUUInuvisfot370YlEkuZv cGyKKoURPxbtwaQFE/7MTOcDgKNaLi/8i2iiHiRDacpF1v8qLT+to+IaD5SqU/txLdlT OuI3Ykk/l1rRt3lTIUQwp7icDKncfML8GT8Zd+QhoLRkzOa+wscjsmFjzTcF9N5xzORh gr7cfVXBI5JisOkC/0//k0JnA0g2vJY7eMWHGDcwa9TO1XoS816kVUjP3Dx21jNP0QYz gFUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=z/Jz+Y1mP+IuEAo9VZmu0MfVOu2WRcNx9ZQ7uwlCXaU=; b=jhgOVCEUiyKAEIMxc9FCEGaJdIEPdWYkW9x5vKqulyrTcTneQlUEd0TZjgHkBxTxXj JLi/SOaObzKptsgYFcVmjiXai354qwzVy4xTqXNKVVjrCWX6bAXWSTeCdCXeQRown2wa LV56/YS4dn/AGJbJdlHRhhBFRwQap2Enx80XXXurwy4w78mmuUN8JIxc+rjcfiGI0gAA sqyl7Dlb5geyGAzzjb+yQru6hH5qLELfo5BNr3nbZZDBgYV1TWC1QW+1mLB4drL5b89V L2P8d8bIlrgH7jwn36KXDj6SCA5rRcdCYen1FgFau8y9qOl8tjf4BM+EzYwdLwMsIxtx E0Ww== X-Gm-Message-State: AOUpUlFUwU1n+H/slOkN3GwkZE7/VqXDYbcYuyYsiCd4aMbuG20XoGAA 4/OjhmGlMATLCSKX/HqKFg4= X-Google-Smtp-Source: AA+uWPySdLkl36eXoJ5fmwXhlDKk0GvYYyExu19P49MfcUgWjKYUdZPqK4NtnjmnDhvvWPlCgWYtTg== X-Received: by 2002:a2e:5687:: with SMTP id k7-v6mr35457106lje.105.1534845612974; Tue, 21 Aug 2018 03:00:12 -0700 (PDT) Received: from xi.terra (c-74bee655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.190.116]) by smtp.gmail.com with ESMTPSA id w200-v6sm1193843lff.71.2018.08.21.03.00.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Aug 2018 03:00:12 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.91) (envelope-from ) id 1fs3SN-00059C-Fx; Tue, 21 Aug 2018 12:00:11 +0200 From: Johan Hovold To: Johan Hovold Cc: Dan Carpenter , Greg Kroah-Hartman , linux-usb@vger.kernel.org, stable Subject: [PATCH 1/2] USB: serial: io_ti: fix array underflow in completion handler Date: Tue, 21 Aug 2018 11:59:52 +0200 Message-Id: <20180821095953.19728-1-johan@kernel.org> X-Mailer: git-send-email 2.18.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As reported by Dan Carpenter, a malicious USB device could set port_number to -3 and we would underflow the port array in the interrupt completion handler. As these devices only have one or two ports, fix this by making sure we only consider the seventh bit when determining the port number (and ignore bits 0xb0 which are typically set to 0x30). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable Reported-by: Dan Carpenter Signed-off-by: Johan Hovold --- drivers/usb/serial/io_ti.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/serial/io_ti.h b/drivers/usb/serial/io_ti.h index e53c68261017..9bbcee37524e 100644 --- a/drivers/usb/serial/io_ti.h +++ b/drivers/usb/serial/io_ti.h @@ -173,7 +173,7 @@ struct ump_interrupt { } __attribute__((packed)); -#define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 4) - 3) +#define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 6) & 0x01) #define TIUMP_GET_FUNC_FROM_CODE(c) ((c) & 0x0f) #define TIUMP_INTERRUPT_CODE_LSR 0x03 #define TIUMP_INTERRUPT_CODE_MSR 0x04