Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2728163iob; Fri, 6 May 2022 09:08:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTxkLek0HadzvIlCwmhjxBsKnJFSzWAKem+ZOW+JPwFAwSyCVDOTGyr54zNHpAFF+Bien7 X-Received: by 2002:a17:906:cf84:b0:6f3:a3d8:365f with SMTP id um4-20020a170906cf8400b006f3a3d8365fmr3635169ejb.242.1651853324188; Fri, 06 May 2022 09:08:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651853324; cv=none; d=google.com; s=arc-20160816; b=XEYNzs42tutW3fE75nR3bOUK79t8TmL27TVBHMd6vCUL1qMElQamuw1TWHpi548egw DmxRmyVCjpR78yn0mOfrie+fdTX0zT1BQlOu+jA053qvedJx9AmW4+XB9V3FthpkrD0g lwogEkwHpnokCV7Dw0Q8KNnXnInRPHXkLbhfjnM9luPxthuuUlwVDS/nkpN9kazTomln fqCDbcW3Fcg3Fg0kKoSmjBKZUueU3ttAQx2gOG8MyRkkGt2nZhvTzSqpYB7H2RRlcL+n CQXhGyvcT9w+twIPzE3bueog2W7HmyCJcrdWCycSRsMLsv9dkQQz/qS+ueOpVVA/lWpE WN6g== 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 :message-id:date:subject:cc:to:from; bh=MqSaclm9K1et9RDW5LbivPFYu7WcFcSQD1iCILr4YHc=; b=kMU4WaDU7SrWxnNDz4vTOFnd5LS1BesHzX/dUA+zxT52/bKtF5/9ifod/7hZp9WgJq 11YxU5DSaQK1+Q691/n5bfa6Hd9LxKEN1LkLeXir8z8zkXeQ68cO+HgoQPTCoggSl/vX zYMsIJyIJYYPxTPBr8VeQMxZIK8upTGbJNJhJNSkM/G8uCxL0fUCCgtmXpbyUudPj4dy Pj26wuWuM2aJS+a15gwbjNcJSCLKxQrch5MYaYdgRvvKTQn1R/ggmnnqrNWgUyob1yBi cku8J/7glJ3je1g0IkSrK4bwNfxj/6zH/y518OkO95za8l87+t1lW+V7yd4Nvn6ulBaI 7kWQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id by8-20020a0564021b0800b00418c2b5bf37si3974802edb.537.2022.05.06.09.08.18; Fri, 06 May 2022 09:08:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389519AbiEFH2k (ORCPT + 99 others); Fri, 6 May 2022 03:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240161AbiEFH2j (ORCPT ); Fri, 6 May 2022 03:28:39 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0BDD674C8; Fri, 6 May 2022 00:24:56 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 2467ORJS001331-2467ORJV001331 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Fri, 6 May 2022 15:24:31 +0800 From: Dongliang Mu To: Jiri Kosina , Benjamin Tissoires Cc: Dongliang Mu , syzkaller , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] HID: bigben: fix slab-out-of-bounds Write in bigben_probe Date: Fri, 6 May 2022 15:24:25 +0800 Message-Id: <20220506072425.1121900-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, 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 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 --- v1->v2: modify return directly to goto error_hw_stop; 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.25.1