Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5207511ioo; Wed, 1 Jun 2022 00:04:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkhTuyQxk3bbTmtrxfr5c3myoWWJVY4kHAym27DIX8+VZKZRKcYwLoyBjGMj0q1AsKRDr8 X-Received: by 2002:a17:90b:1b01:b0:1e3:421c:90f with SMTP id nu1-20020a17090b1b0100b001e3421c090fmr6539444pjb.59.1654067043611; Wed, 01 Jun 2022 00:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654067043; cv=none; d=google.com; s=arc-20160816; b=HN1x1KPji54ovl0AZff7lctq9UOc1fiGETjluRnTackbPwRGK2FFaHWp6oIRMblQgQ f9zLKD5kQfJVMhM7kSxchswRAp2rpkWRFY4tlLeSMEDuHoMDQxMcIb5XWVi45leGnlkM PSYzmkCrve0Xm+ZSwNDIZSltHM3A2JWuHiwWZFhh7wLIJXWX6YB3I4dD9O7tkz/k45+a mtqC+4t6x3UzAiaBSYP7L6k/BYsE+wzh8yAFD2cTRmp+BdFcj3K6HT2UjZ0Nllq/ykuU 4qrzTrkW7oHgtPvB6fuPDktepCxl1uHWkX8hlZNlaROYbz5+bjQ41jsklItB4QuWAR4A W+fg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kiyhiBBDIgyDCIRQn86NQSAZpmeIy3fX0gg8yu0o3JM=; b=uM9yVV0tduXKcRvVYNJNZ2OsJHx2wLabYmgyPVMzC8sxlQQ3cRjCiOaG21E0vdiDcx ssEQ/CfmjmzclbMxeBiLWkaXoyCYywfhMxnIbIdwtqKcDTj57JHnseAvuROdCe/fFMfR oDm/dTAD7Vo1fXv6j2nsoFuDQMyjWnKb7JRVkGQTb3aWA1sdrloQ/7sJvPIi654FOQD+ XvzQT+ml2gL+kkrCewf7jxI2yiih6+SADuCuen2HGCseEMWHabg9wD+wPIihccM4VxMw lYObkOpE96uZYzJW8ZEKh+jZ51zJUEoeX2JheExbjCfhxxiotqhs/RcSCX18OGO4cwt7 Ap1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aFNNv2em; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p11-20020a17090a868b00b001dfcda58373si4918129pjn.104.2022.06.01.00.03.48; Wed, 01 Jun 2022 00:04:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aFNNv2em; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242422AbiE3OhB (ORCPT + 99 others); Mon, 30 May 2022 10:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242126AbiE3OSY (ORCPT ); Mon, 30 May 2022 10:18:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80339A339C; Mon, 30 May 2022 06:49:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D93C36102F; Mon, 30 May 2022 13:48:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36A8AC3411A; Mon, 30 May 2022 13:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653918506; bh=7jqS2tTlnNZbrQ98eK9OJ7pRMtBHKuwDuhlgk5Xc4Sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aFNNv2em0PARWRnwA7FUzBG2ekc4MGVAp4Hb4ciBpZfodSY0Q5w5jonZTlXXaMy/6 oMQkNxxcxKet1LaYBhDSrobgspdyWB6mOVBVHX5L1TVj5DqOcWzNofQwFu7JvAvoX3 cUpEAto+SWA9kaKtwHYQzE+bwrDGnoo8gKaOL78NuZI3cOf5LxNSpJgP5auiR0PR4w uct8PIiIUl88hQv7zg4Goq5NBdmqOdgDq7wCOCsDsN0luUKXtrM/isMQpPQR0UmSH1 Xun6292YOKVKxF11Hl9oDV014vw/1n8vaht2oX5Gd15GzITp5afYekDvm7DTh8lCPc iqPcaZbAD0Gow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dongliang Mu , syzkaller , Jiri Kosina , Sasha Levin , jikos@kernel.org, benjamin.tissoires@redhat.com, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 32/55] HID: bigben: fix slab-out-of-bounds Write in bigben_probe Date: Mon, 30 May 2022 09:46:38 -0400 Message-Id: <20220530134701.1935933-32-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220530134701.1935933-1-sashal@kernel.org> References: <20220530134701.1935933-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dongliang Mu [ Upstream commit fc4ef9d5724973193bfa5ebed181dba6de3a56db ] There is a slab-out-of-bounds Write bug in hid-bigbenff driver. The problem is the driver assumes the device must have an input but some malicious devices violate this assumption. Fix this by checking hid_device's input is non-empty before its usage. Reported-by: syzkaller Signed-off-by: Dongliang Mu Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-bigbenff.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hid/hid-bigbenff.c b/drivers/hid/hid-bigbenff.c index 74ad8bf98bfd..e8c5e3ac9fff 100644 --- a/drivers/hid/hid-bigbenff.c +++ b/drivers/hid/hid-bigbenff.c @@ -347,6 +347,12 @@ static int bigben_probe(struct hid_device *hid, bigben->report = list_entry(report_list->next, struct hid_report, list); + if (list_empty(&hid->inputs)) { + hid_err(hid, "no inputs found\n"); + error = -ENODEV; + goto error_hw_stop; + } + hidinput = list_first_entry(&hid->inputs, struct hid_input, list); set_bit(FF_RUMBLE, hidinput->input->ffbit); -- 2.35.1