Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6265575rwb; Tue, 9 Aug 2022 12:03:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR4AJBN6PP8RuXOZKsAEjN6zwKuHyKmCRQZ/N4ksx7bUx104e+DrHV6TQjgQ8qwSBfj3R3qV X-Received: by 2002:a17:90a:982:b0:1ef:f525:9801 with SMTP id 2-20020a17090a098200b001eff5259801mr27797305pjo.191.1660071806302; Tue, 09 Aug 2022 12:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071806; cv=none; d=google.com; s=arc-20160816; b=fmEvvip3trE07PsnbmkJfoQl5WlxSr8JPuh+aChSWJdtN+WXSXWEpeOmPLssWMKcqp +x1+2UG1F8RwTgpfvtSFCrEjZ//gOkbt3n8YmBN0ZLS/yCCxrasfpWJr/+f87TB/3MLT jNosVzNxsgknidbtJboMEsouG90hE8OU0HvXWQ4n1LTwcmtJpKoLyEIwgGXyuf/v/eK2 zlyLPjdE7jEA3oawbZso78VWQu0IKQW5b53yTMfsgkbvWAgn7TfqTk093ZQUla0rXA0q QOo022SGp5nnA20ToNyx7v1+gfJrfqfurokSA+AvPWdUKC2srmXdjrPui9exacXS50Ya IGBQ== 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=DRhx6jiJJNru2hMzzW/4am/5cnOhW9vQzpDQdrqzCRokp9YuTLzYojDG6qBOndnTK7 SuQ3eSItfofTPb+YwAHi8WCO8JoRMjsinXVm/D8/8efUfex8L397zzWW0e/1gqE8hsW+ 2zUt+LmvBvkgyVvBIJuCXhw2I8CoUV0+qu0aAayRDNwQyzgT4Ai/YXxAoW9v8pmKVcD0 FtzKVuzbU6o2lmk7fkJ+HYS342zxNGmrwgjpBP1fPLZ7+kNpr1jB0NWq4BjtJMK44u4Z WMv4v6c8lvGrF84ryHsGGrJVhAwK4o0GiR143ioB/TLQqEhCUe8+VmV4cp1JCF5ZLggK m3Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xpe+rLEe; 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 x19-20020a63b213000000b004041c039264si1747407pge.663.2022.08.09.12.02.46; Tue, 09 Aug 2022 12:03:26 -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=Xpe+rLEe; 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 S1343701AbiHISNg (ORCPT + 99 others); Tue, 9 Aug 2022 14:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345743AbiHISLj (ORCPT ); Tue, 9 Aug 2022 14:11:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55BC527B0F; Tue, 9 Aug 2022 11:04:48 -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 ams.source.kernel.org (Postfix) with ESMTPS id B56F7B81719; Tue, 9 Aug 2022 18:04:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C552C433D6; Tue, 9 Aug 2022 18:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068286; bh=e+Sqdz09GdVHe1dlbhbcgQasCVxSYIYnh6jIqbIAANo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xpe+rLEeqeNvvRyaFoS2thI+15aEGMBSsLcG+OBdkUp0im93yMCrtMk8kJZmKVuxP j48+g6MoKd9gSzfV1cSO4KazZScDV77S6il/xPAZSP3jJs/d1nglrXXTg+rCdL00ug ErKKUCFPqyXTp/9fbkRzNJU4mjImSqQYZnMsMtZ8= 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 5.10 21/23] macintosh/adb: fix oob read in do_adb_query() function Date: Tue, 9 Aug 2022 20:00:39 +0200 Message-Id: <20220809175513.580399042@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175512.853274191@linuxfoundation.org> References: <20220809175512.853274191@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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: 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;