USB: gadget: bRequestType is a bitfield, not a enum
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 18:46:21 +0000 (19:46 +0100)
committerPDO SCM Team <hudsoncm@motorola.com>
Tue, 8 Mar 2022 06:26:08 +0000 (00:26 -0600)
commitd5d1b24fea1693aed1dff9c7604f8b585b2fa8c9
treec556922d669ff36208be648d1b17cb4c79a4af3e
parent27bd94f81365b68f148e19caea843a60d13b20f3
USB: gadget: bRequestType is a bitfield, not a enum

[ Upstream commit f08adf5add9a071160c68bb2a61d697f39ab0758 ]

Szymon rightly pointed out that the previous check for the endpoint
direction in bRequestType was not looking at only the bit involved, but
rather the whole value.  Normally this is ok, but for some request
types, bits other than bit 8 could be set and the check for the endpoint
length could not stall correctly.

Fix that up by only checking the single bit.

Mot-CRs-fixed: (CR)
CVE-Fixed: CVE-2021-39685
Bug: 210292376

Change-Id: I7d924c81c41c003bf048ab995c52562df239e563
Fixes: 153a2d7e3350 ("USB: gadget: detect too-big endpoint 0 requests")
Cc: Felipe Balbi <balbi@kernel.org>
Reported-by: Szymon Heidrich <szymon.heidrich@gmail.com>
Link: https://lore.kernel.org/r/20211214184621.385828-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Gajjala Chakradhar <gajjalac@motorola.com>
Reviewed-on: https://gerrit.mot.com/2197707
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Xiangpo Zhao <zhaoxp3@motorola.com>
Submit-Approved: Jira Key
(cherry picked from commit 830a43080a0b05cd77863647699c4f97b3849ac8)
drivers/usb/gadget/composite.c
drivers/usb/gadget/legacy/dbgp.c
drivers/usb/gadget/legacy/inode.c