From patchwork Mon Dec 2 08:56:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11268835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4EE11188B for ; Mon, 2 Dec 2019 08:57:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DD662245C for ; Mon, 2 Dec 2019 08:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575277020; bh=uxDPX9Wv9UMxaKJ4BPCyBDMxbLwdnEATm3Jevf284nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=sibc9GByq/w8+fkYZohE7jqNxzV4miEI0iJKKGte7aNaXOIOE7fDIlAxBNOIpcDuT BRcBCP6/VIYoSJ13tWOVNpy2vHi5xWvkt9rMH/5S2hibq3pLNnq4q/qUH2iTAu+CSf ECLFmWZ+eoFLGnuA0ZeMHr3KW5bU9xL4wwO8fJIU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727337AbfLBI42 (ORCPT ); Mon, 2 Dec 2019 03:56:28 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:38141 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726350AbfLBI42 (ORCPT ); Mon, 2 Dec 2019 03:56:28 -0500 Received: by mail-lf1-f68.google.com with SMTP id r14so11019859lfm.5; Mon, 02 Dec 2019 00:56:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZWtVf6zhlqG1yD0jYizMqYkj60ZxzCRmOI8BvxjssGc=; b=Knz1xZSe1iJVHq2TCSXu1yQ3poBER6h7f0gDJfdOYBz6HiofdWdcYCDCmOG9BDEOIx JCWAfzvjDGORqvL6k07wF8vNbW9btIvTe58vfMcR/myFOReGOysGdWkprWUTvkIGrzva R5PibozIcRAgDzgvcBdMwNUuilNJhiAyJAeofxEYnee3w4kC2jwOYO7hkUvrAiLnMgEL tKEvy6soJH52Thjn9lSgXyne0RNU/YB71h/hdNrbCcRjhQtsRqOp78SDHzE8UcXcx7xT Qf41pVzVwc5Y2SrUcIyAm9jDb80MOIIUDU3C6Z8U+X12A9LrmHIQD2Q6zmiVpPcv8ZvV MmeQ== X-Gm-Message-State: APjAAAUUtydqan1rLFEmAyZj2XzNb6t5+wd3ZqbSdglARI5dWNswI1Kx +z506u4904Z9ISevWXyFcdE3K67S X-Google-Smtp-Source: APXvYqzREhhsAsgIzm5+gICb1rmMGnTb0RIdOXajU5DczHtNjJXi1ShKoCA4u5fHEgNMs5CaTblt0w== X-Received: by 2002:a19:7611:: with SMTP id c17mr733011lff.86.1575276985398; Mon, 02 Dec 2019 00:56:25 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id c27sm4403154lfh.62.2019.12.02.00.56.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 00:56:24 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1ibhVL-0003K0-VP; Mon, 02 Dec 2019 09:56:27 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , syzbot+35b1c403a14f5c89eba7@syzkaller.appspotmail.com, stable , Hansjoerg Lipp , Tilman Schmidt Subject: [PATCH v2 1/3] staging: gigaset: fix general protection fault on probe Date: Mon, 2 Dec 2019 09:56:08 +0100 Message-Id: <20191202085610.12719-2-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202085610.12719-1-johan@kernel.org> References: <20191202085610.12719-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Fix a general protection fault when accessing the endpoint descriptors which could be triggered by a malicious device due to missing sanity checks on the number of endpoints. Reported-by: syzbot+35b1c403a14f5c89eba7@syzkaller.appspotmail.com Fixes: 07dc1f9f2f80 ("[PATCH] isdn4linux: Siemens Gigaset drivers - M105 USB DECT adapter") Cc: stable # 2.6.17 Cc: Hansjoerg Lipp Cc: Tilman Schmidt Signed-off-by: Johan Hovold --- drivers/staging/isdn/gigaset/usb-gigaset.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/isdn/gigaset/usb-gigaset.c b/drivers/staging/isdn/gigaset/usb-gigaset.c index 1b9b43659bdf..5e393e7dde45 100644 --- a/drivers/staging/isdn/gigaset/usb-gigaset.c +++ b/drivers/staging/isdn/gigaset/usb-gigaset.c @@ -685,6 +685,11 @@ static int gigaset_probe(struct usb_interface *interface, return -ENODEV; } + if (hostif->desc.bNumEndpoints < 2) { + dev_err(&interface->dev, "missing endpoints\n"); + return -ENODEV; + } + dev_info(&udev->dev, "%s: Device matched ... !\n", __func__); /* allocate memory for our device state and initialize it */ From patchwork Mon Dec 2 08:56:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11268823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E22B115AB for ; Mon, 2 Dec 2019 08:56:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C033A2245C for ; Mon, 2 Dec 2019 08:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575276994; bh=Us2LR83sqTpDDxH+Vob/8vFqXsuJSQfz1IXYJRDcCJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hrRMr2EcNhiI0EQUfzsQjy4gQqnr+NFlHy7TOAdV2tZZc9JgLt0D/tyuzp4W3mVg8 yv815VZK5Z1RcUke3UMFYY6IwsMbupaOwFnXR1jYUtVwkbnbtsrIV60mRBxKpXuTN1 k4tL3kcbeEiye4vnNDnnhfo93+6lJGNPdWXCvtqw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727415AbfLBI4d (ORCPT ); Mon, 2 Dec 2019 03:56:33 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41828 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727317AbfLBI42 (ORCPT ); Mon, 2 Dec 2019 03:56:28 -0500 Received: by mail-lj1-f194.google.com with SMTP id h23so2637139ljc.8; Mon, 02 Dec 2019 00:56:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rl1LB5EX7oIVC0mGuDqRbEVhDWig1nq2VNrs1gvJuaw=; b=kDfrdNrV69JnxKk5VeEvumOB732tK3kzSsItKiSnUbUJjEGHKZO3ArJNYnTMrkp2JT H0PptM9nHy1CnKT3dFiB6TRTByW9L0bREUEfhg0kPppvELM1sZACdrGVtBTcghz2bec8 qA3vaEX8ei9XsmJ54F6Ia5Wn0lSPLnBU+p9lzpU+4CYdqZGSucxmqixio1hZoJOs8snc l4xivmL9FeYm41SPHXpOUsY7OJw50vyRT9ndI/DbDIg74X3OlaFhZhLVNThuSpv4add6 4iSEzbZY2oSJC3HwWoT3CenAVAEYOkygaSX5VERr/D6EMUFQIdQUsd88LO6a7g3gIV/a GzAg== X-Gm-Message-State: APjAAAVD5QjlyDQRJVaOn7VnJrqMCkozowceARVmyrXLVEeQoVS4WEcr iWx9JVRqPSnZ2tzGOzWU4PQ= X-Google-Smtp-Source: APXvYqwRd3xGb/t3PETM2Lts/w4SDIabwmc7fZxPHq77jLNKOyGJUZSpLoQaby/lNY6m6qnLrIP48A== X-Received: by 2002:a2e:970e:: with SMTP id r14mr44042644lji.57.1575276985866; Mon, 02 Dec 2019 00:56:25 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id z26sm2582160lfq.69.2019.12.02.00.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 00:56:24 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1ibhVM-0003K5-1e; Mon, 02 Dec 2019 09:56:28 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , stable , Tilman Schmidt Subject: [PATCH v2 2/3] staging: gigaset: fix illegal free on probe errors Date: Mon, 2 Dec 2019 09:56:09 +0100 Message-Id: <20191202085610.12719-3-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202085610.12719-1-johan@kernel.org> References: <20191202085610.12719-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The driver failed to initialise its receive-buffer pointer, something which could lead to an illegal free on late probe errors. Fix this by making sure to clear all driver data at allocation. Fixes: 2032e2c2309d ("usb_gigaset: code cleanup") Cc: stable # 2.6.33 Cc: Tilman Schmidt Signed-off-by: Johan Hovold --- drivers/staging/isdn/gigaset/usb-gigaset.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/isdn/gigaset/usb-gigaset.c b/drivers/staging/isdn/gigaset/usb-gigaset.c index 5e393e7dde45..a84722d83bc6 100644 --- a/drivers/staging/isdn/gigaset/usb-gigaset.c +++ b/drivers/staging/isdn/gigaset/usb-gigaset.c @@ -571,8 +571,7 @@ static int gigaset_initcshw(struct cardstate *cs) { struct usb_cardstate *ucs; - cs->hw.usb = ucs = - kmalloc(sizeof(struct usb_cardstate), GFP_KERNEL); + cs->hw.usb = ucs = kzalloc(sizeof(struct usb_cardstate), GFP_KERNEL); if (!ucs) { pr_err("out of memory\n"); return -ENOMEM; @@ -584,9 +583,6 @@ static int gigaset_initcshw(struct cardstate *cs) ucs->bchars[3] = 0; ucs->bchars[4] = 0x11; ucs->bchars[5] = 0x13; - ucs->bulk_out_buffer = NULL; - ucs->bulk_out_urb = NULL; - ucs->read_urb = NULL; tasklet_init(&cs->write_tasklet, gigaset_modem_fill, (unsigned long) cs); From patchwork Mon Dec 2 08:56:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11268829 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2F40514B7 for ; Mon, 2 Dec 2019 08:56:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EA022464B for ; Mon, 2 Dec 2019 08:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575277016; bh=5dFQOz0N3ACRUey9qsTVySw22xS6NrIAWDQbGlVo8Fk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kxL/SE+RtFYg9BoJekF08uDVnonqoGaE/MnKuTgdOLfCUCdFLxmkmwJgLgZMU3SCL 9epo6cXR3R62Rl2whFsOod5ojsl2KkzkniHYZGFNATwKLULhG8j+c58FXeqxhciNfe Qm2yUphfIkU9iPriY3K+7sHGu59nafZIIxRAchQ0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727406AbfLBI4d (ORCPT ); Mon, 2 Dec 2019 03:56:33 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37644 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727318AbfLBI42 (ORCPT ); Mon, 2 Dec 2019 03:56:28 -0500 Received: by mail-lf1-f65.google.com with SMTP id b15so3049592lfc.4; Mon, 02 Dec 2019 00:56:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Vgj7PGsaCd+QK5EW8HOwKnXzkNAAF8dwOAUSS+ipPTs=; b=PNgHJcIW8jJKPg6G2bATiMVfrM72WsUyXXSeDtgQTOW+Ht8xe8avDe+QXC6/LQgJ4U 5Y6q+/1U0Bq5sVj0bArHQKT8/jTy3sRYlX5zzV0yEZODore/WUuzQRqbCu7hPdAs3ePj zaqsMG5U29burTfItEsnE/JjsMVT81KYdm7cQV4R9COKVNgR+e5/AcV3XDu3E7/ImE/S UhV6YGAhe3dXhEvRtPo+JmJMi1Kou39mwBdbM4Wi3jf9yq/v0pHIWJOZW3qHTYxlpfW4 HxbkDhfKP3aIxCpNP2Xzw693dc9eG4U1TgI2kg93/I6spK+uvnpRlSU/Y1B8BZ3ANijK nCug== X-Gm-Message-State: APjAAAVw/BRMne9qv+yjASDyqQy0RT3W1hZV1zGdbPY5j54CGZFd5hr/ T1vlGE67jP5WWzu5ST2AYVU= X-Google-Smtp-Source: APXvYqwjI7A2nNfjVQ/adXNCF5IUWlHXA/tLmM97n2/NNaRd1GaOCFHc8A1kKyESx/7NfA4ZkO2/Pw== X-Received: by 2002:ac2:5462:: with SMTP id e2mr33337163lfn.181.1575276986428; Mon, 02 Dec 2019 00:56:26 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id e7sm14595995lja.5.2019.12.02.00.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 00:56:25 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1ibhVM-0003KA-45; Mon, 02 Dec 2019 09:56:28 +0100 From: Johan Hovold To: Greg Kroah-Hartman Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold Subject: [PATCH v2 3/3] staging: gigaset: add endpoint-type sanity check Date: Mon, 2 Dec 2019 09:56:10 +0100 Message-Id: <20191202085610.12719-4-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202085610.12719-1-johan@kernel.org> References: <20191202085610.12719-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add missing endpoint-type sanity checks to probe. This specifically prevents a warning in USB core on URB submission when fuzzing USB descriptors. Signed-off-by: Johan Hovold --- drivers/staging/isdn/gigaset/usb-gigaset.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/isdn/gigaset/usb-gigaset.c b/drivers/staging/isdn/gigaset/usb-gigaset.c index a84722d83bc6..a20c0bfa68f3 100644 --- a/drivers/staging/isdn/gigaset/usb-gigaset.c +++ b/drivers/staging/isdn/gigaset/usb-gigaset.c @@ -705,6 +705,12 @@ static int gigaset_probe(struct usb_interface *interface, endpoint = &hostif->endpoint[0].desc; + if (!usb_endpoint_is_bulk_out(endpoint)) { + dev_err(&interface->dev, "missing bulk-out endpoint\n"); + retval = -ENODEV; + goto error; + } + buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); ucs->bulk_out_size = buffer_size; ucs->bulk_out_epnum = usb_endpoint_num(endpoint); @@ -724,6 +730,12 @@ static int gigaset_probe(struct usb_interface *interface, endpoint = &hostif->endpoint[1].desc; + if (!usb_endpoint_is_int_in(endpoint)) { + dev_err(&interface->dev, "missing int-in endpoint\n"); + retval = -ENODEV; + goto error; + } + ucs->busy = 0; ucs->read_urb = usb_alloc_urb(0, GFP_KERNEL);