From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3DFCC43334 for ; Wed, 13 Jul 2022 03:47:50 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4LjNqm678hz3c72 for ; Wed, 13 Jul 2022 13:47:48 +1000 (AEST) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.crashing.org (client-ip=63.228.1.57; helo=gate.crashing.org; envelope-from=benh@kernel.crashing.org; receiver=) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lists.ozlabs.org (Postfix) with ESMTP id 4LjNqJ345Xz3bZB for ; Wed, 13 Jul 2022 13:47:23 +1000 (AEST) Received: from ip6-localhost (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 26D3k4LK022660; Tue, 12 Jul 2022 22:46:05 -0500 Message-ID: <68b18cf30dc3fb4d78a74edf390fcc5da6f61114.camel@kernel.crashing.org> Subject: Re: oob read in do_adb_query function From: Benjamin Herrenschmidt To: sohu0106 Date: Wed, 13 Jul 2022 13:46:04 +1000 In-Reply-To: <74db5889.1519.181f54412b2.Coremail.sohu0106@126.com> References: <74db5889.1519.181f54412b2.Coremail.sohu0106@126.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?Q?=E5=86=85=E6=A0=B8=E5=AE=89=E5=85=A8=E7=BB=84?= , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Wed, 2022-07-13 at 09:54 +0800, sohu0106 wrote: > > > In do_adb_query function of drivers/macintosh/adb.c, req->data is > copy 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. Thanks ! Can you send this with a proper Signed-off-by so we can apply directly ? Cheers, Ben. > > > diff --git a/adb.c b/adb.c_patch > index 73b3961..8a5604b 100644 > --- a/adb.c > +++ b/adb.c_patch > @@ -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-