Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1124794pxj; Sat, 29 May 2021 04:06:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI2kLDia/AKoZqJKVGiTN2kfs7dPCowG/TzoX0CadjndZROh/j/UrAyvsCfBFlenvNmrvh X-Received: by 2002:a17:906:46d1:: with SMTP id k17mr13353122ejs.77.1622286369103; Sat, 29 May 2021 04:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622286369; cv=none; d=google.com; s=arc-20160816; b=MKaG26XN64fWwNUMaXeriStWz6mbFofEfJAevxI5FMetK2Gdo1XzRMtcKyHjEpA/vZ kLPoobEd5jYtbczMdv9i53XQfR35Hc0K8qq2uG8aozeNyByMxOnUhdPxkyUAkBw4TVjl WdVyBkJB7WKWe+DfkqmYD4CwHEbvVkhkPdPxiJVebhQzpwOIkf82tzRLRtV7kDmLu+FO 0E80La+W6HB6qcrPqfmBpFJ8NXmqxGl0STRmfYysrz4SnOwAqknyTRX8Cb4qteNAb5as wvEEXaGe7sxd7q9f0atq/LM07ecjMBSiaOv1zg5xain95iGcleoimlvn1pATGIOpr50h 7xyA== 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 :to:subject:dkim-signature; bh=8hrWgEWGLESgRyLhrq1kkN9qRLSKJH0aHYooCga+EvM=; b=HBjaxk9cvMvChfl+otz8DJrLAsSb6Bbt5qLFlYS6/VnUXpAP/tDlLl0c8NEf1zqoHZ ZUQ0HVo1UX4EWwgMENptr3IK2l/b73VNvzpSEoo+HESxpMmLVZtfEncdVuaR8h1ltFQE 3cpWWS6A8VRccXd0mtB75zB4rEA+jP4RBB22oIndz9dem6kTI1Tc3TEXmyLBoNo/p2XF yAzXBCtAtVUeumf6mRVfXTGNQcnaBSfRNvNbaD3KQBEoItr3JDb3ctP9HGiwY8BEFuoA mEhc7S/bnsSk/qGKDh0rM1xEWE5Cm9CSyOb8u0Eo5pvt2S+4xZqsVf0XtatW8xGzq4My 20zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FABmk0NO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nc17si2846170ejc.133.2021.05.29.04.05.34; Sat, 29 May 2021 04:06:09 -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=@gmail.com header.s=20161025 header.b=FABmk0NO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229698AbhE2LE7 (ORCPT + 99 others); Sat, 29 May 2021 07:04:59 -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-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