Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3964409pxb; Mon, 4 Oct 2021 13:51:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuWuaA9mAitPYIDK9/h75YVw+RGcHltYb9Gs0KHZu4NMfzBiLWKIp5m9OxsHgiYQJtcY5f X-Received: by 2002:a50:dac3:: with SMTP id s3mr20917143edj.322.1633380717532; Mon, 04 Oct 2021 13:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633380717; cv=none; d=google.com; s=arc-20160816; b=eWAdyLWr1cbSnfvBXNSFr3X7ehvaPFnIjj9rZEEgsOR2V9dcUzyhvQIDeNfsK+0LGD SP5yRin5R4K1OlJCgQmThd+0wOjX3fmmEztTwGBExVpz+ZF/VzJh1TajV87NLaRG0jCx 3td9iRzXLdWyBLkUM2o2mCr7GgLR1q3Kx2wn9Whkk6MH61WzdTmnRH0ZrZSeBt4DQBrd ZNFyvwKN0VkGQHeWhLlkPW1ZQqpHeuVcd40uoXoucxz++pzgLPfdDPAkuD/OfLZDsPyq mrPLVLsGFLUVRPW5iTPA1sbJY2tsxKxtpVerMvBYmHtYRp4o96tVpr5q3pEa5V5EGt7C UoyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4e62Vj+FCd0iCkd9MQVIZ4pkM3sL0XQMHpaVdL3MnFE=; b=NWQFpCkPWVn6fgwOuM3nG1K4mKTzb+jiJ3RpwXCJfGitLzWPl9nadp2ewaXOGVZ+sD 9bQgeeLVJkEaCilcx0qlnxYwlg+huKeaPw3PK0L+CjIBMkhdHbugPUmS45IsYLYaeVcY aA19ha35pCIyQMPq+vD9NCzHXulsv2/j53ieLbkrD4k/kFcu5WM7rTglL3PS8QbcXnYJ B2hgc3rWj1r9v49AyHri0vAtCxgaZT63eRRtE4VeLfhGpKl8bpstKs2wV5L7Mx5mv6Dm oMOY8wDjgXcpTGJgWz5E3whB2vqBCZz00Y1x2oGsOqQUW8rNVNrzl92TomA5tZnZnngR I0sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tnqQXafs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mp40si27464586ejc.179.2021.10.04.13.51.34; Mon, 04 Oct 2021 13:51:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tnqQXafs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238480AbhJDNmQ (ORCPT + 99 others); Mon, 4 Oct 2021 09:42:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:53144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238431AbhJDNk0 (ORCPT ); Mon, 4 Oct 2021 09:40:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5EA461A58; Mon, 4 Oct 2021 13:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353519; bh=jcRBK8EomAPjn5aI+Arc7e/MeSBMdj8wu2+Bk1uCW4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tnqQXafshT+uFu0tf/16mpEd+ZvZw2a9fOb1K72jWXNM805wRqAQQbBZqFMQsqRtN dS92fz1LBjGii2tQ+cWBprUPINXWzEHAM2HpDUg2iqeauKUMEH4HCTxIjCOnSRjvUF +w5z88B8QWQt0UYK1/uG6+xI9WtDaOt3Gu0DNuJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrej Shadura , Jiri Kosina Subject: [PATCH 5.14 159/172] HID: u2fzero: ignore incomplete packets without data Date: Mon, 4 Oct 2021 14:53:29 +0200 Message-Id: <20211004125050.101297885@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrej Shadura commit 22d65765f211cc83186fd8b87521159f354c0da9 upstream. Since the actual_length calculation is performed unsigned, packets shorter than 7 bytes (e.g. packets without data or otherwise truncated) or non-received packets ("zero" bytes) can cause buffer overflow. Link: https://bugzilla.kernel.org/show_bug.cgi?id=214437 Fixes: 42337b9d4d958("HID: add driver for U2F Zero built-in LED and RNG") Signed-off-by: Andrej Shadura Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-u2fzero.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/hid/hid-u2fzero.c +++ b/drivers/hid/hid-u2fzero.c @@ -198,7 +198,9 @@ static int u2fzero_rng_read(struct hwrng } ret = u2fzero_recv(dev, &req, &resp); - if (ret < 0) + + /* ignore errors or packets without data */ + if (ret < offsetof(struct u2f_hid_msg, init.data)) return 0; /* only take the minimum amount of data it is safe to take */