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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18693C6FD19 for ; Thu, 16 Mar 2023 19:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbjCPTEl (ORCPT ); Thu, 16 Mar 2023 15:04:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229735AbjCPTEj (ORCPT ); Thu, 16 Mar 2023 15:04:39 -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 E48B59EDB; Thu, 16 Mar 2023 12:04:30 -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 0FE58CE1E57; Thu, 16 Mar 2023 19:04:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE9AEC433EF; Thu, 16 Mar 2023 19:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678993467; bh=4SDqdWNCGiFNqnb3Zj29x5lAsT1AarZiIiw0TYkTpiE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VfHiiY9GRX7fn94lYsR8Wqi9IjIzu/eIr4lubBYjatgNdSaFR3hQuwMxXNzZlAtrW 7UapnNMK4ufFq1Ib5ne0JOcoV4E8J7/1WzgB1TM4DpgXNSuaE7PdPnzFao0XKudL1O Zh9kK0OR+lqY9zNPQYrVL97yIMRI53Y238/12fF4= Date: Thu, 16 Mar 2023 20:04:24 +0100 From: Greg Kroah-Hartman To: Fedor Pchelkin Cc: Jens Axboe , stable@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: Re: [PATCH 5.10/5.15] io_uring: avoid null-ptr-deref in io_arm_poll_handler Message-ID: References: <20230316185616.271024-1-pchelkin@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230316185616.271024-1-pchelkin@ispras.ru> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 16, 2023 at 09:56:16PM +0300, Fedor Pchelkin wrote: > No upstream commit exists for this commit. > > The issue was introduced with backporting upstream commit c16bda37594f > ("io_uring/poll: allow some retries for poll triggering spuriously"). > > Memory allocation can possibly fail causing invalid pointer be > dereferenced just before comparing it to NULL value. > > Move the pointer check in proper place (upstream has the similar location > of the check). In case the request has REQ_F_POLLED flag up, apoll can't > be NULL so no need to check there. > > Found by Linux Verification Center (linuxtesting.org) with Syzkaller. > > Signed-off-by: Fedor Pchelkin > --- > io_uring/io_uring.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c > index 445afda927f4..fd799567fc23 100644 > --- a/io_uring/io_uring.c > +++ b/io_uring/io_uring.c > @@ -5792,10 +5792,10 @@ static int io_arm_poll_handler(struct io_kiocb *req) > } > } else { > apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC); > + if (unlikely(!apoll)) > + return IO_APOLL_ABORTED; How can you trigger a GFP_ATOMIC memory failure? If you do, worse things are about to happen to your system, right? thanks, greg k-h