Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3396102rwa; Tue, 23 Aug 2022 04:12:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR5noqCAS+I/svgS6nlGMX0d0jVbC8aKJdk0gNA9+j9UVoqxSiDEefnHZojvd9XzmKigsubV X-Received: by 2002:a17:902:c945:b0:16d:d425:324a with SMTP id i5-20020a170902c94500b0016dd425324amr23384823pla.7.1661253132710; Tue, 23 Aug 2022 04:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253132; cv=none; d=google.com; s=arc-20160816; b=NzhQ264KQJAGxxxW9VFfB1CezorXooxgy5snoqfb+iCDhitnyuMraCIejpwSMNiyJq 79ISWm66GUb+dhwk5iC+5T6BY9/DShiE5RMLGayiXNy4rr5910TAbIGxBnMkDni0n8av htQzXuVzh2UP2uHDrp544bz1WAKTjX57Awb3KoWEED32baSv0QRU2fcu4zP7NCys3z93 YOqhvKDcqxTV/zXbZ4jv31N6k/9pzpk1GoId+3+TeIWlMW+8QR01Go38kjAxBu49roHj /Ecw/qr601cXBVCfvtndCCQU7UH0bZ6zxeQb9596Rk2bQWsYWgtxS4ocr5Z09uk9B+bx /00g== 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=7KAA0hwUrJDS0VLk4AeokC/IViE+bEeeorEwf9pYeyM=; b=KFVBiYh44lqzMbya7TH/puOABnyQE0WuDs2u7GVOVfGV+y0klMIkvAzkEbay29sBDi JXJ3PbDhv9mGtUNsniB3jWmRtxd5ikn1Sb2Ee8ePY71EtmEYLiV/Ebhs5zKhVJlMGqUx g+X3nDBSp5Qxvw0q620xG8CnM9mZPcLxGVMKxMTMdolgyAZu5qZHrZvzLZh+3Hk2/1j1 t3yHyv0KBvuMLtSbvphz21Pi1Ck2h5nJWq55Lc/JF7NtydnBLva3h4XA674vSuu1MWK2 QKwRLYNmgaElYHBqj8Oi1dQm1HVtt6SKOuWSCyoNIaE8Fq1gyl2rSgneEg9nE/g8UnUn ScIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2XgeoDqU; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cp8-20020a056a00348800b0052eb171b730si10783726pfb.250.2022.08.23.04.12.01; Tue, 23 Aug 2022 04:12:12 -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=@linuxfoundation.org header.s=korg header.b=2XgeoDqU; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350472AbiHWJaL (ORCPT + 99 others); Tue, 23 Aug 2022 05:30:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350011AbiHWJ1w (ORCPT ); Tue, 23 Aug 2022 05:27:52 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E85B77E82; Tue, 23 Aug 2022 01:37:23 -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 sin.source.kernel.org (Postfix) with ESMTPS id 52009CE1B49; Tue, 23 Aug 2022 08:35:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BD8EC433D6; Tue, 23 Aug 2022 08:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243757; bh=e+Sqdz09GdVHe1dlbhbcgQasCVxSYIYnh6jIqbIAANo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2XgeoDqUJveMEJTaJ0FeDmNaU6dIf0j1LZGFzlQsROO9CRR2rcFNQ2u0suRK8yu3H t7n7mvuQN6jdZpMMMubax4VGymgs3FYpDvNxzq6hWq0I3rNvIVISo+OZg7+wdU0XNs QQqTz6yngUwlgzzcKhUtaH8BzvTtQEQn6noEAtKE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Ning Qiang , Kees Cook , Benjamin Herrenschmidt , Michael Ellerman Subject: [PATCH 4.14 012/229] macintosh/adb: fix oob read in do_adb_query() function Date: Tue, 23 Aug 2022 10:22:53 +0200 Message-Id: <20220823080053.828036841@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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: Ning Qiang commit fd97e4ad6d3b0c9fce3bca8ea8e6969d9ce7423b upstream. In do_adb_query() function of drivers/macintosh/adb.c, req->data is copied form userland. The parameter "req->data[2]" is missing check, the array size of adb_handler[] is 16, so adb_handler[req->data[2]].original_address and adb_handler[req->data[2]].handler_id will lead to oob read. Cc: stable Signed-off-by: Ning Qiang Reviewed-by: Kees Cook Reviewed-by: Greg Kroah-Hartman Acked-by: Benjamin Herrenschmidt Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220713153734.2248-1-sohu0106@126.com Signed-off-by: Greg Kroah-Hartman --- drivers/macintosh/adb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c @@ -647,7 +647,7 @@ do_adb_query(struct adb_request *req) switch(req->data[1]) { case ADB_QUERY_GETDEVINFO: - if (req->nbytes < 3) + if (req->nbytes < 3 || req->data[2] >= 16) break; mutex_lock(&adb_handler_mutex); req->reply[0] = adb_handler[req->data[2]].original_address;