Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2983495iob; Sun, 1 May 2022 03:36:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1qaCejScOJYs1EZm9YX6U0RNzti400DsjJARrWHtDQTELynTI4aRPBOIjXXiwolL9vHpv X-Received: by 2002:a63:2cd8:0:b0:3c1:a1d3:9acc with SMTP id s207-20020a632cd8000000b003c1a1d39accmr5753621pgs.134.1651401411306; Sun, 01 May 2022 03:36:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651401411; cv=none; d=google.com; s=arc-20160816; b=K2CSa+jeN4ccxc6ZMROXbbre9jSKBoVltFfb9Ef3rlL241U1whRHEkGxK2MhRj9g44 cHN5a+GzDbGXYYyKdI0XtY27hTeBYBhBo+q2390HRCoB9kc52gEl8dZmS4/o5WTOHbB2 1toxoqfU0HIA1F54VqSpc2HOKocwI4TQSpHgpYDKVUxG4njnvyhQcyI899Iq0Z4g6+ko YxJpiJ8IZQJgGAya/JnbundM7MblqIfGVf+tGI8Pivxe7E5KJOTCZUxUj+c3jODdDxTN iPN3sjQjIZqOtGuzk0oAStKjp0AN2uBA5W2b02ZAonSEQ8HOUUZJdrgZK57cEdQKRMMC P2sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/qAuxqoXysKENNiIlItnlrcQMTT0GxzNNHI80GK7T7M=; b=0RepDGO4u1/7+RCmq5Z6/32lUCCDr1B1VdYBc5bdaa+UgaI4G8YraAIBOvqfVOBEhf /vzTH1ujf0TxthIv/h6nTGVzYOE8BY5gAf+COB9IXUgdBUTljRur9IvikKt9riviXYi5 MOGeJV3XQAOQ+ZtKQS/Ek6BqFenqGpCuPMq6jS9y40N16PRImiiPV5f9VynJ62fS7L+3 qo1PUw2jzCHJYYY0wCq9QBeBJDbjxmrxqYeWl1b4nOvdpQHSlv28gLjfcTSqj4WVHra+ pKx+vNEq5i5E9HcMy+dnYBbc9oTtga1nFMeCS++KBgU1NOXs3X1xKt7WqTbKZioHr61E S3ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iUWQVjnB; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w71-20020a63824a000000b003828506c119si11059202pgd.125.2022.05.01.03.36.37; Sun, 01 May 2022 03:36:51 -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=@gmail.com header.s=20210112 header.b=iUWQVjnB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378561AbiD2Pk2 (ORCPT + 99 others); Fri, 29 Apr 2022 11:40:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343710AbiD2Pk1 (ORCPT ); Fri, 29 Apr 2022 11:40:27 -0400 Received: from mail-yw1-x1133.google.com (mail-yw1-x1133.google.com [IPv6:2607:f8b0:4864:20::1133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 438B1D5EB3; Fri, 29 Apr 2022 08:37:09 -0700 (PDT) Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-2ebf4b91212so89224067b3.8; Fri, 29 Apr 2022 08:37:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/qAuxqoXysKENNiIlItnlrcQMTT0GxzNNHI80GK7T7M=; b=iUWQVjnBqeSdZ3g8BrUg+9CAJm4xwvaWfVce3WbZzUm2jaVKxg6PNrMIUdpn2GU77a Tag3k25kmMQSJGFOOtg8PovwYoC1gopbSiGub2seyqZQzq5KukgWtJpEYrJBxdRr7eYf RvuWdZZV0M63NKMnBT4UF8AjpLN8yC38T35k5YtmrCMPGzmG/q3pbwvR8p074V5n5EEw ll9o65trUcwa4wJBO38p7Q4FUC6uaatPSU+Gg+CwNcpr49SBKWaahHuvYr66/pC3S8Mk 6mY9FphCt+ABjElkcW084lGSL2TbZWgRD8X4TLhfw4y9j2bZNN+YMsWadu3dAQkVYdoZ tcaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/qAuxqoXysKENNiIlItnlrcQMTT0GxzNNHI80GK7T7M=; b=FP8Ox4dUcBfcDjGKmcEpBaiMluYd1L406PCHBS1LLMOuDyW6otNX4ew4q1dJxDx/0D 3tcx2x33QG2Em9wWNI1sir/6eDh1dOAyTfUPzaMcfGMDxqADWApbpOTx1tPStHSH49h2 tBVz6T5PiBNi/6P0SYu+1cF4FT90IdIzlfrEOkrmukYiTFBGemGbJuyeNWFbkz1lPyTy jL4ixj6YZrljJgBl/zY5b8hLPjaVaO6j2ZqwRtpODpOWt7qCDvaLYAFiINdROmla51/J JoH+MLWXpMJrz7zeNAWSAqvWCD7TbEds+nUUqXJoF319wYFpKypxFkrwrJ71oRxoacqN kKSw== X-Gm-Message-State: AOAM530LdVSf9grD/Sfmf/wJ31HX3PfUNc1u7qdCSwBat0lulzl5fb0b pGLqSMO58UpXpamgkw5/SAWyMjPXxab+HScLWV0= X-Received: by 2002:a81:9213:0:b0:2f6:eaae:d22f with SMTP id j19-20020a819213000000b002f6eaaed22fmr36558385ywg.249.1651246628512; Fri, 29 Apr 2022 08:37:08 -0700 (PDT) MIME-Version: 1.0 References: <20220429004244.3557063-1-goldstein.w.n@gmail.com> <8f8d07c1-9276-df86-f1dc-3d272d4ab91d@kernel.dk> In-Reply-To: <8f8d07c1-9276-df86-f1dc-3d272d4ab91d@kernel.dk> From: Noah Goldstein Date: Fri, 29 Apr 2022 10:36:57 -0500 Message-ID: Subject: Re: [PATCH v1] io_uring: Fix memory leak if file setup fails. To: Jens Axboe Cc: Pavel Begunkov , "open list:IO_URING" , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Fri, Apr 29, 2022 at 7:47 AM Jens Axboe wrote: > > On 4/28/22 6:42 PM, Noah Goldstein wrote: > > If `get_unused_fd_flags` files fails (either in setting up `ctx` as > > `tctx->last` or `get_unused_fd_flags`) `ctx` will never be freed. > > There's a comment there telling you why, the fput will end up > releasing it just like it would when an application closes it. I see. Thought the 'it' refered to in the comment was the file, not ctx. > > > I very well may be missing something (or there may be a double > > free if the failure is after `get_unused_fd_flags`) but looks > > to me to be a memory leak. > > Have you tried synthetically reproducing the two failures you're > thinking of and tracing cleanup? > > -- > Jens Axboe >