From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 78FD646B5 for ; Mon, 26 Jan 2026 12:36:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769430992; cv=none; b=DYForvsdNFI91/HG60gH0vD2wOkZUKxUen+3eGVdRgobhZPsEtE4IAd6Te9aX+YcgVghRd3Zqac5IXvGYYKG9PkwfqBCtGgGAAtHR6+hUmK9na1oXb6jLln9LAnMyiCrJoAQXlIDogfv5neFP+jL+KJ6MqbpPbf48mv6eolZUfk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769430992; c=relaxed/simple; bh=zAkMz6oveNazEakokAmG8bLQ/Fx2b7AQ/ahjevW/c5U=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=k6ImFfAK2j8YIabZktP9sIcfjD9xci8oWZXS2nIyYzlRM3ez/3zj5lpNDyyqV65H1IZK/C6IXx/+RpZeR9PvZS4P+75fQ1xOsoBALklpiGsDFqzlUw7SrGE0hHfoQMsiihM619ayr3xMz/37q+4mc+1eMn4PKLFXkChsPWY3PvU= 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=wXxXFoqX; arc=none smtp.client-ip=209.85.210.50 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="wXxXFoqX" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-7cfcb46ffc9so3423110a34.0 for ; Mon, 26 Jan 2026 04:36:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1769430989; x=1770035789; 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=zPB/SYfzf+cP9VaT3HQWyX2iAkItRsWtTDmJ8NpaX+Q=; b=wXxXFoqXa88kp9m4rK4puvTohm7Zn/fyEyaFROM65rZyCD7wA8jsOZgq5iB6z/kVXK OIIBHDaNoRcg24C8zJW9Eag91eNSCRyIn88wN4D104MXJ4FN0d757RYdhjizWuKLiZQa MFUAKmKDTf3V2XMPsT4KKfCfO1e6Ug8bcoN2lTU+8QSIcPK6rmLdAeCk38Etruj9n6FY niRCs6h5kTUR/IqWDn/i65xuc5wlhgnhTp9n2Jv0fwERG++gF/941HieqDkVKN2ds7KW 2BdAgpqZRiKkKv9K/odFIE4VRuyq9P3bZ6FLS6iAT8fReaUYIP+8RhJxwCL+aSsxbRnh 90lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769430989; x=1770035789; 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=zPB/SYfzf+cP9VaT3HQWyX2iAkItRsWtTDmJ8NpaX+Q=; b=fbl7i24bvEoA3VixpuMb1XxKarrlWoUwpDtzbTbjn/hAXL17F6W42Baak9Dn+39Rcl MosYvYSveTHOw+Ep8e1UaPEQ2cKJh8oc9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0c:b0:662:e0e5:efef with SMTP id 006d021491bc7-662e0e5f10cmr2256376eaf.11.1769430989076; Mon, 26 Jan 2026 04:36:29 -0800 (PST) Received: from [192.168.1.150] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-408af888da1sm7307066fac.6.2026.01.26.04.36.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Jan 2026 04:36:28 -0800 (PST) Message-ID: <79ae8fdf-460d-439a-977b-6876c808bb75@kernel.dk> Date: Mon, 26 Jan 2026 05:36:27 -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] io_uring: gate personality per opcode to fix TOCTOU check in io_msg_ring_prep To: clingfei Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260125075302.621785-1-1599101385@qq.com> Content-Language: en-US From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/25/26 6:57 PM, clingfei wrote: > Jens Axboe ?2026?1?25??? 22:16??? >> >> On 1/25/26 12:53 AM, clingfei wrote: >>> From: Cheng Lingfei >>> >>> Add allow_personality io_issue_def and reject personality use in >>> io_init_req for opcodes that do not permit it. This fixes a TOCTOU >>> window in the prior implementation: userspace could race-update >>> sqe->personality and bypass the __io_msg_ring_prep personality check. >> >> Please do detail what the bug is here, this looks like some kind of >> AI hallucination. The check in msg_ring prep exists just to reject >> commands with it set, for future expansion. The only thing that >> matters is the ordering and use in io_init_req(), which is fine. >> >> -- >> Jens Axboe >> > Sorry, I forgot to reply to all in the previous email. > > The io_init_req checks sqe->personality; if personality is not zero, > req->creds is initialized based on personality. The msg_ring prep also checks > sqe->personality and rejects non-zero personality values. However, sqe is > shared between the kernel and userspace. This means a user can submit a > msg_ring SQE with a non-zero personality. After passing the check in > io_init_req, the user process can concurrently modify personality to > set it to 0, > thus enabling it to pass the check in msg_ring prep and invalidating > its rejection > of non-zero `personality` values. I'm not disputing you can't change ->personality between io_init_req() and __io_msg_ring_prep(), that's obviously possible. I'm saying that it doesn't matter one bit at all, as the check in __io_msg_ring_prep() is just there for future proofing. If the application knowingly changes the SQE post submit to defeat an -EINVAL return, then yes it'll defeat the future proofing. But so what? If you look at other prep handlers, the -EINVAL checks never made any attempts at protecting against this scenario, as it's only there for future proofing. IOW, you could just remove this check in __io_msg_ring_prep() and it'd be fine. Or just leave it alone, because it really doesn't serve a purpose. > This is not an AI hallucination, and it can be demonstrated by a > userspace PoC. It does read like one, however... Including this reply. -- Jens Axboe