From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AF51296BA5 for ; Mon, 19 Jan 2026 23:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.67 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768866018; cv=none; b=XepAA+F3kCKpjLCPWdD9St9mQws5gnvfvsfsMKqIKNTnH0UVcah6nUHIiNSXEhqJX50bjSwFRCkjnLBFiC2Z+h+hdnVjAg5kR/c5JzSvhRkPSl8hLmRbvy2wH4+nUrI0NkbFS11blRJZvUCu3Go9Of+gjMV0MWhDZZ1/lzZu2m4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768866018; c=relaxed/simple; bh=xDk5I/bWBUtkAS07p0QFIcj4/yKHcCi5CfQsdmD194o=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=aRLhKMFlo+tCu9/vWxcH5cbZzHNrdokOpFeeGqZRgyHmNuweQDC358nBUKsbKVcVJ4MNwHh7mlogIAiVPN+k5nC9ypfEI9OEPQsvvLjna0vPXEpyCACkHCY4kalDKJh08s0tWLGGoWcFD5MTOZVdxwJUATEIjLZNzDlDiMSyCqQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=mwDuvD8B; arc=none smtp.client-ip=209.85.210.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="mwDuvD8B" Received: by mail-ot1-f67.google.com with SMTP id 46e09a7af769-7cfd95f77a3so3127381a34.0 for ; Mon, 19 Jan 2026 15:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1768866015; x=1769470815; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=8auGIz9rpLAlTb9LV7N2WX+TwTyGKi6f9JrK1603mZg=; b=mwDuvD8BBLYIwfK7aRd7cBtlp956dutLFsat4KVz4keZHNONOawIJI0MG04fRhkuwy +2hV7oyCUmS/bYoICz3FyVhKQuj7RqQBTJfUzLVWZ6kVcRVlr2mkGMX2Hz5MoN/ExsSX 6ljApE8ZFhsYVxFGOexbrKSEzUxjcbWLojHpbyaPuqIt0ciqRieYY5WjPHmPvphIx6+3 E6ojyqE362rjJjROOhs4OmKnayzc/uf5bP12s2hDjJIwW9m3fjvQa/KAn6zs3cKgHQTZ uWnQoaCtZ1NVcF0q7o6H1UIrptrYSs1B1zC+43UYGC2L1IMlrfjOzA7HVzawOL/EFp7F d6aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768866015; x=1769470815; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8auGIz9rpLAlTb9LV7N2WX+TwTyGKi6f9JrK1603mZg=; b=qjDakzjblpoHV3wXX83CwBv1u3R8HDFu+3v3W2vymRDtzaVmzE7vFlnis+PlkYUPSP lSlNaUp3Pt3LL0B1+Kr1X6IR2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with SMTP id 46e09a7af769-7cfe01c652emr6188480a34.32.1768866015139; Mon, 19 Jan 2026 15:40:15 -0800 (PST) Received: from [192.168.1.150] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cfdf28ef44sm7571251a34.18.2026.01.19.15.40.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Jan 2026 15:40:14 -0800 (PST) Message-ID: <2919f3c5-2510-4e97-ab7f-c9eef1c76a69@kernel.dk> Date: Mon, 19 Jan 2026 16:40:13 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] io_uring/rsrc: fix RLIMIT_MEMLOCK bypass by removing cross-buffer accounting To: Yuhao Jiang Cc: Pavel Begunkov , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260119071039.2113739-1-danisjiang@gmail.com> Content-Language: en-US From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 1/19/26 4:34 PM, Yuhao Jiang wrote: > On Mon, Jan 19, 2026 at 11:03 AM Jens Axboe wrote: >> >> On 1/19/26 12:10 AM, Yuhao Jiang wrote: >>> The trade-off is that memory accounting may be overestimated when >>> multiple buffers share compound pages, but this is safe and prevents >>> the security issue. >> >> I'd be worried that this would break existing setups. We obviously need >> to get the unmap accounting correct, but in terms of practicality, any >> user of registered buffers will have had to bump distro limits manually >> anyway, and in that case it's usually just set very high. Otherwise >> there's very little you can do with it. >> >> How about something else entirely - just track the accounted pages on >> the side. If we ref those, then we can ensure that if a huge page is >> accounted, it's only unaccounted when all existing "users" of it have >> gone away. That means if you drop parts of it, it'll remain accounted. >> >> Something totally untested like the below... Yes it's not a trivial >> amount of code, but it is actually fairly trivial code. > > Thanks, this approach makes sense. I'll send a v3 based on this. Great, thanks! I think the key is tracking this on the side, and then a ref to tell when it's safe to unaccount it. The rest is just implementation details. -- Jens Axboe