Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp835764pxj; Fri, 28 May 2021 17:42:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKpLM5L11vd53UfhnCUCkfVRmXGqc7Jq0dqe1HV8W6qFDSljMf9JhALwr9ESLTUA+nZ9Os X-Received: by 2002:a92:d283:: with SMTP id p3mr3114904ilp.170.1622248923421; Fri, 28 May 2021 17:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622248923; cv=none; d=google.com; s=arc-20160816; b=u3afcfWxQdolG9+8nMxfnQBiw5pZcbrHulbDIgF9jXxwkDiTUiBQ4upxqqw6rjZ6HL WR0troSurwtUJu+ulGdUgIjnQErAiUms7k8NkE4j/emCuOqnsfWV5j3AYHCMc2rtpq0L nHkEVVQUUTG/Hi7p4Q83CzIMLPCkfewMBBiLQdib8zXCKXl1iZhOZVZz9VDT9HGAiHDV gqKohN8Go+/IHch+oD+eF9P115oj4pkNS3NwKpHyj7/HlaTyWHGK8rENCsUdD0mxNmot 7CZNOEsGwwIWEn9IBlHDpHaaEWn/aFwI8pyuN9KjFBFp43iuGspjSFeXdGbILltjP7EH xZfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature:dkim-signature; bh=W9m/5buG1zeb0H5rrcyHnA3tGrYgwT0J47EYZa9BVq0=; b=fn94pWfxI3DDQAOlgKO0hxeSwS0asm8QxnLcmlxa19tRzE1DFPnpa11clxjgEL9eUH j1m7UgcBVyFg+uHtANfedvbYUDsTr8wu7FncmyQofqA92+F1fmQbsJlhP3Ey3zb1F6BF ImNnVm5xHytc076nkWIQSi3nuWjZnXt4+acdE/v+nlfrC3tKH940nxid3uv5rSAyqHEr tRo7qfoueVlGV2osiUMF/V2Q/NLXDqRfZPvjTTFg0Cb0okB8Uc1qlRRa4Bu93JEH5B60 DLnI0TJYEDAakrLck0HjNyUu+uC3aFUvekk3iAJT9x4vLYn7LkEYON9LhnSA1UEqvsKB X/gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@anarazel.de header.s=fm1 header.b=I756SUq2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=nqtrOppG; 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 x8si6994659ill.30.2021.05.28.17.41.29; Fri, 28 May 2021 17:42:03 -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=@anarazel.de header.s=fm1 header.b=I756SUq2; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=nqtrOppG; 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 S229644AbhE2Af2 (ORCPT + 99 others); Fri, 28 May 2021 20:35:28 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:43931 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbhE2Af2 (ORCPT ); Fri, 28 May 2021 20:35:28 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8D0445C00C8; Fri, 28 May 2021 20:33:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 28 May 2021 20:33:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:subject:message-id:mime-version:content-type; s= fm1; bh=W9m/5buG1zeb0H5rrcyHnA3tGrYgwT0J47EYZa9BVq0=; b=I756SUq2 MfN3V15KgiGkJy9esayMw8b4oGdZfA/1dqdH8JNPXbCuPY/irYc6f2EvPsuidjMQ TIOGKgIsJO32U9KYn36WXqtzjwt20T3/zG9pgUPClTKNr1Qf5uOjmqH0kZyg4oRk DOY66BVXPVAWd3fFRyGK4O3ReokxDdEBcmPG79iv6odjhzsSq9MTgKr2+6m1wDd1 EM81K49fgY1ewFWajK6SMNgQYCzaxebfSNSF9WzKrTDDpVoruTeK9HVf1tb3a7LL p0E9t0V25qEajI9WUZ76jBwKsbXzFk9HvPKI8ClKDYvmQLtC2NV/UAlSZSfV0KJA sJqG0ZRUgSlwDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=W9m/5buG1zeb0H5rrcyHnA3tGrYgw T0J47EYZa9BVq0=; b=nqtrOppG/iyFB1W3JLLX2Anl1YXGj3hF4mXWY3GxQZ738 lBQ4DZV7fc1Z3+kEP5N4dupvNihQryabN1SEfrFn3HTN8VuXHh3+Rk8EyOjX0XX0 +INTrPRKSUb7Me1tZtlv7P+uDQnXJMyZGVmoOZh5R/UGY17RHqmF5HZHALgT6KgY Wn6ayuOzUgrAy15dKQ73c1I7aXE4kyajJx/U5i0zUu1J1AgfAelk4cc40FhX1ex6 c1wdJfszMjvLrc45Y9I1qSCwtJGZVNFZgqi+UidwiCgGTe74apLTbay8PRrOjHyR bA5L0kY7ntm9r7oUmbLkn1XP7ebihKvObk/eo8A8Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdekkedgfeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggusehttdertddttddvnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeeivdeileegueeutdefudfhfeethefhvedvleejtefguefgtdeltddutedvheek ffenucfkphepuddtjedrudegvddrfeefrddutdefnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: from intern.anarazel.de (107-142-33-103.lightspeed.sntcca.sbcglobal.net [107.142.33.103]) by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 28 May 2021 20:33:52 -0400 (EDT) Date: Fri, 28 May 2021 17:33:50 -0700 From: Andres Freund To: Pavel Begunkov , Jens Axboe , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Memory uninitialized after "io_uring: keep table of pointers to ubufs" Message-ID: <20210529003350.m3bqhb3rnug7yby7@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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... 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