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 X-Spam-Level: X-Spam-Status: No, score=-4.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75374C4708E for ; Sat, 29 May 2021 11:03:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46F7A611AB for ; Sat, 29 May 2021 11:03:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229709AbhE2LFA (ORCPT ); Sat, 29 May 2021 07:05:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbhE2LE7 (ORCPT ); Sat, 29 May 2021 07:04:59 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA6DC061574; Sat, 29 May 2021 04:03:22 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id q5so5753076wrs.4; Sat, 29 May 2021 04:03:22 -0700 (PDT) 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=8hrWgEWGLESgRyLhrq1kkN9qRLSKJH0aHYooCga+EvM=; b=FABmk0NO0U/9T42PPCAEXPKSV65ksYxTkJG3Y618vdYr/JSDavQKQ8Bd9olM2VsxYW WLduO+QnE+m1VjMkOkAzBzY2H+AUz547aja+sFzgHLRg/rFvT1gmuYWlVyi4QxIYAndh oR9TTXNTvEFJZrnvoEVNWofPiBA16ZUqErJUHQ7qmKLvtWw5q2UWgtrvgdDcqiyzby0q 4JBpvA5WiBSSuMUoCJeJ10F8IM/2lMpIc++SojcbvJc3Nqg63r1sBTJAGRyso+Tb7CKf qI/qR414wSOeIPBNLikC5oqZf55in1QWHOljtiRMwR3FLSeUgKHC1u+mErsAsJa2y1Pn NETA== 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=8hrWgEWGLESgRyLhrq1kkN9qRLSKJH0aHYooCga+EvM=; b=GVMvsHbmEJdM+Ssc2+d4zzLtR9thTe9BeKWvHMPAtOHHRx2aD9X0wmziQXC0+Ywg50 2cCbjYmcxLr+tem9/6GqlU3qrUXcn/CzARo5dffiawV6LGN3eIHshSBUVHNs9YVCwrLz BhjrGRhFtMzeBd19U5NaWB9IsqpSi1Bd7v2t0PWNhLqXfI5Aq5QH5tY8lTTQm/g3vui+ sxUfN8afsHHRiEmRSVlSGTZdx5kOxioFUG/3kV2MTln76YqjUJWZmnSvsCHtaaQWGNgY PgIMnZle0OmpFhOa1qyeJlzAw3sgfp8m2ZXDFi1X0QvNsAQNMcTWOHc14uK4FAuW1Bdq ET3w== X-Gm-Message-State: AOAM5309f/isdtzRB10/JQjZvC98BGVDJnfLeIgJNvFXk1jksTFhftFu AmX6OLjv0YRAiCf7Q+uBLY3yMDFSRaM= X-Google-Smtp-Source: ABdhPJwkwTgaw8M4PrxMoiO+bK0lAyQcv+nob2zc3EkNAmWsf4kVe5ls5LIOMNx99uGV64XvHfPY0Q== X-Received: by 2002:adf:fc11:: with SMTP id i17mr8514948wrr.374.1622286201214; Sat, 29 May 2021 04:03:21 -0700 (PDT) Received: from [192.168.8.197] ([148.252.129.19]) by smtp.gmail.com with ESMTPSA id x7sm272599wre.8.2021.05.29.04.03.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 29 May 2021 04:03:20 -0700 (PDT) Subject: Re: Memory uninitialized after "io_uring: keep table of pointers to ubufs" To: Andres Freund , Jens Axboe , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210529003350.m3bqhb3rnug7yby7@alap3.anarazel.de> From: Pavel Begunkov Message-ID: Date: Sat, 29 May 2021 12:03:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210529003350.m3bqhb3rnug7yby7@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 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. > It only doesn't fail as root because the rlimit doesn't apply. > > This is caused by > > commit 41edf1a5ec967bf4bddedb83c48e02dfea8315b4 > Author: Pavel Begunkov > Date: 2021-04-25 14:32:23 +0100 > > io_uring: keep table of pointers to ubufs > > Greetings, > > Andres Freund > -- Pavel Begunkov