Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp478449pxj; Thu, 3 Jun 2021 11:16:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuU23xHhFFwVWtSCnDP0bx+pm0G9j0bIXUQ+tBqlkuA72rKmxBcpFU3LUpQqwS3LG0lMR5 X-Received: by 2002:a05:6402:1a:: with SMTP id d26mr760205edu.105.1622744208044; Thu, 03 Jun 2021 11:16:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622744208; cv=none; d=google.com; s=arc-20160816; b=iug6ka3al4TaP28SS8cM8vkNfQw0uJcStUBGSoGIHwIu85B/YJE6284dOzoc0tgwi6 zIWV+/K5ds5i0v85VjtbUi3G4pZgDPm9ujANGVdqvEojX5bIsYB/fysGG9STQaUW/t3M puj01654bbWHgEKkm90ZnEN1Xh8nbLkpW2n0thXoEOf7uf/KzInCd5sFGqhQckQiSV9z uu0YLse93uSv1VBHacYx1I4ij01VdRmO7Kdi6c4FBhmkxOLh2qix5TWnF4qXX+rHarbU PygQ+aMm7PNIa2GHshy4U7CgOfsP6dNVeKfjThIj8fzmK+VnOKFbeQZJQJkQBYmOp+EJ zJOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=LrMYcjq05VyJxkL18sDV7DXDJoHHmPTPpPGO0QVG5ws=; b=rBA1euL+t9KUKXsG/3CT4IICCLQMdhkfEG5Buk+CLSXxxYnpbEfdPqNnH4kxLXF0WP iq9HoUm0yBMTTTpYU8609u6IrlbbyAmQrGEl1ZtOPqsipGmm+Zjr9xQq5Q/wwP+ePB2i d9uRgRLkZfyNvVgZweU2bpm6VaZZd7ps0Uj9JHj25g9Ba+3My7A0KybqGcFhTiAZ3/+A 19ESc6aPiuWmxst4CsLZYrccxUPxTs8KB7XlAAvlIKlXIwQJKSZk8tGFYOlyVozow068 uy+HkObPsIjDgQFenp8za1prIDdJNCje3xlCVR4niTlaHmotx4MNcn+fF7hkqIfuLk5X hwFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=sleU7SFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id aq21si3256700ejc.451.2021.06.03.11.16.22; Thu, 03 Jun 2021 11:16:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=sleU7SFV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229704AbhFCSQj (ORCPT + 99 others); Thu, 3 Jun 2021 14:16:39 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:38701 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbhFCSQi (ORCPT ); Thu, 3 Jun 2021 14:16:38 -0400 Received: by mail-io1-f42.google.com with SMTP id b25so7308622iot.5 for ; Thu, 03 Jun 2021 11:14:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=LrMYcjq05VyJxkL18sDV7DXDJoHHmPTPpPGO0QVG5ws=; b=sleU7SFV30zMQkS002evJmEErV/7Q8rP5+rKIXSi5P5X1GVAv9dkWqnFKKC7c38xTs fU+msYzfQ4THH5kjw70SVcaiqj0GykE9UDNFUxsR+Oc2yA2zjpjV8HCeQ/oBTKg41n0t pCr8PwDjnAZZ3eHScEhe2KKCK6Ujmbx+1RcPzN2N8UzF7/uqbaXMzpDyiuH7X8ueg6dl 1iNSh1vGLo8pk68HX3Nu4xmJAhWlfLoChXUW46C/ld/0RBSCEx3sB6cNUX4wyFEOE27V xx/HFophmhK4/LPmdcV/WZfErMG+LtGGi2PbZGTC0AXWLQc5FsypAilyTGQSWEoykFSH Vr3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=LrMYcjq05VyJxkL18sDV7DXDJoHHmPTPpPGO0QVG5ws=; b=shI2RmvRA8l2VqN8tTF3U9WieIr0K/YF1LwyMy5mllWKq8cKdQ3kdJ+AZ4bESPbn+e ChWxjpPQ+K2A0RVEb8zedH0TAPDCl55zYLD5lBsGgTU3MifCnlTNNY7Dvt03iyXLkiZ0 1YQK+bsoV3ReNtBk9EMoxgegUdqnXkP8VLTcn4WiqyRP/Xnlu1kOENMG8tSgVuHimI5c QU4wr2eFJgYXZbdBN4EM/0z6w/Y2Qn+gGZWssxBBRWJV43pEWWqPQp3L48HsxD6bVIJ1 44P3H8J1A+770pQXb6we2IRFoL9eW9XPMm+reu04QeD100Gmqvb/Y2WT3bMPzaChOgWC w7lA== X-Gm-Message-State: AOAM530x5+2ycpDd+r/woFJlc2uh68HaWoVNNlqqbNr4fYxrNbfOnhSs QauJIwlEoxci0QA0hIdqdbWgHTyjvSlKyBvy X-Received: by 2002:a05:6638:1482:: with SMTP id j2mr260876jak.63.1622744033395; Thu, 03 Jun 2021 11:13:53 -0700 (PDT) Received: from [192.168.1.30] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id z2sm1901101ioe.26.2021.06.03.11.13.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Jun 2021 11:13:52 -0700 (PDT) Subject: Re: Memory uninitialized after "io_uring: keep table of pointers to ubufs" To: Andres Freund , Pavel Begunkov Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210529003350.m3bqhb3rnug7yby7@alap3.anarazel.de> <20210603180612.uchkn5qqa3j7rpgd@alap3.anarazel.de> From: Jens Axboe Message-ID: <89f8e80f-839b-34bc-612b-d0176050bc7d@kernel.dk> Date: Thu, 3 Jun 2021 12:13:52 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210603180612.uchkn5qqa3j7rpgd@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/3/21 12:06 PM, Andres Freund wrote: > Hi, > > On 2021-05-29 12:03:12 +0100, Pavel Begunkov wrote: >> On 5/29/21 1:33 AM, Andres Freund wrote: >>> Hi, >>> >>> I started to see buffer registration randomly failing with ENOMEM on >>> 5.13. Registering buffer or two often succeeds, but more than that >>> rarely. Running the same program as root succeeds - but the user has a high >>> rlimit. >>> >>> The issue is that io_sqe_buffer_register() doesn't initialize >>> imu. io_buffer_account_pin() does imu->acct_pages++, before calling >>> io_account_mem(ctx, imu->acct_pages); >>> >>> Which means that a random amount of memory is being accounted for. On the first >>> few allocations this sometimes fails to fail because the memory is zero, but >>> after a bit of reuse... >> >> Makes sense, thanks for digging in. I've just sent a patch, would >> be great if you can test it or send your own. > > Sorry for the slow response, I'm off this week. I did just get around to > test and unsurprisingly: The patch does fix the issue. OK good, thanks for confirming, I did ship it out earlier today so should be in the next -rc. -- Jens Axboe