Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6266720rwb; Tue, 9 Aug 2022 12:04:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR6LP6Nab9HJIiI8xLzD8Ipfu8aI3/Q1WWrVCnezJVWestj9sxRfan0MKZc7IUs09jth3dm+ X-Received: by 2002:a63:2cd2:0:b0:41c:5901:67d8 with SMTP id s201-20020a632cd2000000b0041c590167d8mr8619136pgs.365.1660071864510; Tue, 09 Aug 2022 12:04:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660071864; cv=none; d=google.com; s=arc-20160816; b=TLJeD3k2qgRNn4o4vyLh3y0T5GXYYmGduI1uzB9/MzU9qjrYYh8qJ95zEIwGqRQZGi cZke0x+KOpWeSyOz4y+qpqYui7TdXH4y+3dsgRHuxjVwxxelLSh+9aPNO6p1RcD0n34T lYe+zjWynDEkKssPXYNVw6iCwNiXY/cYF3/1FK4CsUAXxYl6ZpD7/Q+a/WjIpwl0fQx+ js+DGal1UVrsS/+Wd5Gg6blOhpeU67UxjH/jyw78ehUoUQI3DBmE0rPrP0MJQBYwLupw d8k+rg3S1yr3pSSBcQgblvjvmOSDhNMpGdmbY9VnrbTUNh4IKjDLCW1A9SdeoFKbYpw8 A2/g== 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=Q4xfAicKS6pbRhlMepUddgcxzzHA1wXMvilmKneuD1eT+hkO+EaJXvaCxot+IBf7b1 gybC0u0+UkUThO60hkK8VVj1GvuVCQzGzYPB46kUg3dojKO0vHKpDy8od8dWoDj7d6e5 vMRv0T7adYXwhHRWKHjbcyTDNFXrKH3pSVMIv+Fks+z8vdHTypdXxRcA9K3Tt0KpT7t2 y0LWAhCpvywL2oIhZjjdINFwRMsAlMG4WdQDFxvQZCAFHC3tmvbVBOEwkeoxp7hpyl6V cTwQTvcGQuR8mUY+u3gY1CUF18utWUu7VWZ+eb6hLi+o1LSF2GWI9bTqWw5/q/ddFhM3 uxjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rh8ufGva; 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 on11-20020a17090b1d0b00b001ecfcc0a97dsi21669246pjb.71.2022.08.09.12.04.08; Tue, 09 Aug 2022 12:04:24 -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=Rh8ufGva; 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 S1345921AbiHISTe (ORCPT + 99 others); Tue, 9 Aug 2022 14:19:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346332AbiHISQj (ORCPT ); Tue, 9 Aug 2022 14:16:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 441982D1E1; Tue, 9 Aug 2022 11:06:18 -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 DC288B818B5; Tue, 9 Aug 2022 18:06:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EE1FC433D7; Tue, 9 Aug 2022 18:06:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660068364; bh=e+Sqdz09GdVHe1dlbhbcgQasCVxSYIYnh6jIqbIAANo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rh8ufGvae2w2BTqzFaU0Me0e+JworbJ71RMmGJ+XuwB3603BoeVCyHhg+CaQKfTQU REIkXU7T4gtCrIEXORQv0dvf+r3VvDcBcyaS8RCetWTbYhEPx4S92PajST9zmunKuu HrVxyqrwE7ZUPgdZ+5tsovbDx0yLo8HASY5eHwf4= 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.15 28/30] macintosh/adb: fix oob read in do_adb_query() function Date: Tue, 9 Aug 2022 20:00:53 +0200 Message-Id: <20220809175515.339085508@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220809175514.276643253@linuxfoundation.org> References: <20220809175514.276643253@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;