From patchwork Mon May 18 17:35:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 225583 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38852C433E1 for ; Mon, 18 May 2020 18:25:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10AB920657 for ; Mon, 18 May 2020 18:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589826350; bh=nqk65ExJOdZgrlp+sPs18FmX7l3Sc++Un1T815Rqp1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xGrWRW2M+Minl6WinxPzeeijaBTn/c2jxrBxXlEcDeDoVim5Cc0rjTSBVkvGWpVnZ B+aIDAbFTxkkt5hkisAlfrQn9UtJdr0w85LRA4hmF/FbaziWQpmqQgZiqdElN88ajt t7luFe36G1tyYZ/NBtWTDiPM9ZC6gkwii2jkvpy0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730059AbgERRqQ (ORCPT ); Mon, 18 May 2020 13:46:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:45654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730050AbgERRqM (ORCPT ); Mon, 18 May 2020 13:46:12 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7674220657; Mon, 18 May 2020 17:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589823971; bh=nqk65ExJOdZgrlp+sPs18FmX7l3Sc++Un1T815Rqp1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s9XsjPLSaYVZfZIEIw/MnwuRr2xEsi7gmsUPmxtPY/sEDTDHtJXtzyo2ZYY+lLQR7 N4EM6iqsBxpjkYLFoQSwH5SkeBWlLH10SCK2pcuv/1K7aVoqIbk6agNov+KHTpl6wZ E+j2Y5iLqFxehOGlitx5e9u7WwyHKy0jY3xp+4mE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Johan Hovold , syzbot+d29e9263e13ce0b9f4fd@syzkaller.appspotmail.com Subject: [PATCH 4.14 020/114] USB: serial: garmin_gps: add sanity checking for data length Date: Mon, 18 May 2020 19:35:52 +0200 Message-Id: <20200518173507.323289882@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173503.033975649@linuxfoundation.org> References: <20200518173503.033975649@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Oliver Neukum commit e9b3c610a05c1cdf8e959a6d89c38807ff758ee6 upstream. We must not process packets shorter than a packet ID Signed-off-by: Oliver Neukum Reported-and-tested-by: syzbot+d29e9263e13ce0b9f4fd@syzkaller.appspotmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/garmin_gps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/usb/serial/garmin_gps.c +++ b/drivers/usb/serial/garmin_gps.c @@ -1161,8 +1161,8 @@ static void garmin_read_process(struct g send it directly to the tty port */ if (garmin_data_p->flags & FLAGS_QUEUING) { pkt_add(garmin_data_p, data, data_length); - } else if (bulk_data || - getLayerId(data) == GARMIN_LAYERID_APPL) { + } else if (bulk_data || (data_length >= sizeof(u32) && + getLayerId(data) == GARMIN_LAYERID_APPL)) { spin_lock_irqsave(&garmin_data_p->lock, flags); garmin_data_p->flags |= APP_RESP_SEEN;