Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4801213ybv; Tue, 11 Feb 2020 03:46:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxOR9Qq59+hqaj3FIsWE+zVnYOrXl7vKdj2pMLTMqVw0rol8evLGnE65I3ZUaTP7wuS3/hE X-Received: by 2002:aca:af49:: with SMTP id y70mr2667230oie.162.1581421613688; Tue, 11 Feb 2020 03:46:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581421613; cv=none; d=google.com; s=arc-20160816; b=exfLveXy2572N+CV9/32jaFmAyXHaLdo01Mf4YeBd3IZeWuEgS45WW9OnDzpYBHVEx duuNNKLdb7Na2L28rpBZWdb6CdEoxLzFBkl/c0CQU9Inh/+dVRVCo/dX0O4zqLaXn13m tURV+48PPzajEGjvzL4F4h4j8odT5U7HwLaw2qV5SGWuI011wija5ro5Ck32NJ9liris zCq9ZANqa1nj6IdPtzR+V213uzymMFezq7SwYsHDU0Y0dq4Ojq+jRQWrmw8mzzNNt1Qc Ikjex7PExyYM9pL96mrOhXwSzSwrpobe+V+J+E3khgPUiU0kzzTlonwxHW6LfrhrVDBn Fliw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=1D2nt+GacM9CEt1jV/UYuxD3rZiAt9wG1MftPzXIiHo=; b=mUseyplskCMIbvNIbFBaLv+GDSRHJZXNDr8tb9Mh1w8NDZ4N3o4CzOp8Vo56eQY6Z5 xGE011zsN/lThzuUWOVPtq+tENzEB33S8pvZfuZZWuf4x5VCuhHfSZT4/xM08ii0XyZ8 pdlULRp/5ClJs+cQD6uvWZT0jpsOe9/JsYqpK36keDby1z102QIoIereRWPRbNKOy+uF k0Q1ZfY9LI2Hj+tQ8CNEI8dI5777I6RBDy8za2wXk5TrcD6h7WacpxeWS7yoescytyJF kjV0nr1YrJX2tsL43rJgPU/wm3msaAUvrUjPr2kVakJzzF7RA13LhTwTpXbG8LBmd50s T0KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uh4pYGFe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si1904746otp.5.2020.02.11.03.46.41; Tue, 11 Feb 2020 03:46:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Uh4pYGFe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728516AbgBKLFH (ORCPT + 99 others); Tue, 11 Feb 2020 06:05:07 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36700 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727561AbgBKLFG (ORCPT ); Tue, 11 Feb 2020 06:05:06 -0500 Received: by mail-lj1-f193.google.com with SMTP id r19so11090764ljg.3; Tue, 11 Feb 2020 03:05:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=1D2nt+GacM9CEt1jV/UYuxD3rZiAt9wG1MftPzXIiHo=; b=Uh4pYGFerV/M/TVkNahm3cZf2CENx0DaXz9sX1H6t4dfvaUp9WBCut2qkMGPw5Ip8n 8URwmZHlOBmABk51D42K0mskOPkiJLBxuhxbViwgKU5PiRhPLQi2sK3Krz8uHGnjK1Sc /0g7Vj+2tv0yymy83NryPYlCGtUg/NIib5TmAskU4LTP+pCVEB1tT3KHhUQ3T5D5+1oC jgyIUmIYnCN0n+wyD3atryG1Wt6qDwbfezfFKEg3XLQJh4KHDnFccVZjip/yZmtAm3YK aBDz1Ya0CyBe286o9yV8sd4Z67kJr49XFMnKRWZ78bw1BBT6CQuD9jieIG9A3THJxDVK lAFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1D2nt+GacM9CEt1jV/UYuxD3rZiAt9wG1MftPzXIiHo=; b=SclQC6wq3n2SDe+E6rAIdj8NTPD5vcXk2KRlP6PuK2AtukYPTFGZ7cOv2/gzmBycvQ dpSuZONbzPkx+VjpOnyuAzmZoLLZXBZnkfY3fg0+cHOgGGe56Arn9fzbx55hc34L+3hG o83ggWV//dOQRkw1Vh5OCUgymxw2Oz2E3QNHEIc5yQ/lCv5CtdLurCm9MMaDVrvIq4BS iyKGJZbrsi7JR8ULP3ec+n/aKt7nmOgW3NAEinwnp50iSY9rTr2yx+Hn17MZEMH6RqIi fHF7QngxOYcQekj1yia3FAGaBCHRg9y1FSoYEjUNI8phzokfrTY+hkghnbRgyz4KlnRE bJpg== X-Gm-Message-State: APjAAAUGs/NkTiXJQ+wapWXTe1myoNUxnrQeIAgRhsle8U5C+vl65+EO h+3sVwWRrkx5MfN4PYYFXvCrdCXcO/E= X-Received: by 2002:a2e:9a93:: with SMTP id p19mr3956144lji.177.1581419104119; Tue, 11 Feb 2020 03:05:04 -0800 (PST) Received: from [172.31.190.83] ([86.57.146.226]) by smtp.gmail.com with ESMTPSA id l22sm1907701lje.40.2020.02.11.03.05.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Feb 2020 03:05:03 -0800 (PST) Subject: Re: [PATCH] io_uring: fix iovec leaks To: David Laight , Jens Axboe , "io-uring@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <03aa734fcea29805635689cc2f1aa648f23b5cd3.1581102250.git.asml.silence@gmail.com> <1255e56851a54c8c805695f1160bec9f@AcuMS.aculab.com> From: Pavel Begunkov Message-ID: <045f6c04-a6d8-146c-75f3-2c0d65e482d6@gmail.com> Date: Tue, 11 Feb 2020 14:05:02 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <1255e56851a54c8c805695f1160bec9f@AcuMS.aculab.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/11/2020 1:07 PM, David Laight wrote: > From: Pavel Begunkov >> Sent: 07 February 2020 19:05 >> Allocated iovec is freed only in io_{read,write,send,recv)(), and just >> leaves it if an error occured. There are plenty of such cases: >> - cancellation of non-head requests >> - fail grabbing files in __io_queue_sqe() >> - set REQ_F_NOWAIT and returning in __io_queue_sqe() >> - etc. >> >> Add REQ_F_NEED_CLEANUP, which will force such requests with custom >> allocated resourses go through cleanup handlers on put. > > This looks horribly fragile. Well, not as horrible as it may appear -- set the flag, whenever you want the corresponding destructor to be called, and clear it when is not needed anymore. I'd love to have something better, maybe even something more intrusive for-next, but that shouldn't hurt the hot path. Any ideas? > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > -- Pavel Begunkov