From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796206580; b=uxQ98P1YcWpK9/HcZt7AmMXCwrYq7fFBrW3TtGr8xnvXvcqJBI/FDRqeId/wCoVVFNfd E1jESCeK4p86mCjW/nAN84wx+hNEEnxHFD2KSTsUwAm9WxlFU1eiTH95ewtthqQ5BtB+E tvh5p5I+gWHFPkkgUDsgCScrU72dSeeWglPFr6TNj2VejqaEFuer7CPSlglRhDTF2jHnN kPVntcpZuZqds/3Hl7aTnO0cMejmgR/gsbWtaHj/2nAvlFFslZC5j3mfaOxlIOpfZU9rd 6sB7k0JPchJWUppb1SuFaod4/fGoZAKxGesnYCiINm2RQd0c2JDNAA10TVlvhwHzNCw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796206580; h=Received:DKIM-Signature:From:To:Cc:Subject:In-Reply-To:References: Date:Message-ID:User-Agent:MIME-Version:Content-Type; bh=lqf70M+kyox6UvzPpJ0AqwGMVZ2vDiG1rNrkRKurWTY=; b=QnyY7iVqzgN10QCuNoY5NID2kH5AmY4by8V9pWCZi9+Mx0GX0TEuAv/cQi5YlMi44SlJ QEsYuPuHtpbb3FiRhJ6JpW4ipQ/CNKwm3w8jB0vQfcQkRfk7M7koqsD9hy4fdp646Hxgc KQoS9FNHx4BTFkE+WTnTElJr0SA5QSmW2zhTFxkIl8lDlQapzmSYTFY4puTi9kbPap/IL dNqa+KrWAtzEgnd9UEVmlI123zy4F655ByJ9vTQokxgGj5cUGdsYcVb57K2YM0Gp0nOwk 9J9s0zhbHgju7mCLEwVgKiQd6GRp3z76VLC9ybRmAPXqkHAOOfY+lQvSkJiAGpMLyVw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WUf5QV8a; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FEB6606A32C; Wed, 2 Dec 2026 10:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WUf5QV8a Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4815D1F00893; Wed, 2 Dec 2026 10:16:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796206580; bh=lqf70M+kyox6UvzPpJ0AqwGMVZ2vDiG1rNrkRKurWTY=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=WUf5QV8a9iFp/Bb0O5e5fGcI11aUCcoXB8QvCfSenfA7QTuN01gl23YsXrDPNVNwj sxOw0V7OWDmyGlcm16KiB+g5y3lvdn/nn5Bt6Y1RBA1VqKNqM5Q8X7PrtecghFnSmX Z1KxRhdQe7uTk3gkZzRYKlXt6oYLq1+suWPF0gaPupcrdqWleiE30LCQCNp8tq6g3Z ZbNXFnTBRBM4cpvn+0dSRxihIsfGXSiWjhl36cO2BrY4n8w2ldwCDk91IBS5qLYTUo kbi9qo55S2mq09SrEXI/Ji/XjUHzdxxLepkxl9vNyhOq/hRRSYw5NxRSZgFIJ5KKZP cwwRtVN09HuMQ== From: Pratyush Yadav To: Chris Down Cc: Pasha Tatashin , Mike Rapoport , Pratyush Yadav , Shuah Khan , Shuah Khan , linux-kselftest@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Subject: Re: [PATCH 1/2] liveupdate: Return -ENOTTY for unknown ioctl numbers In-Reply-To: <2b8066fe1f98c6063b94de5bf14e926ba13a58e6.1796194107.git.chris@chrisdown.name> (Chris Down's message of "Tue, 01 Dec 2026 22:53:44 -0800") References: <2b8066fe1f98c6063b94de5bf14e926ba13a58e6.1796194107.git.chris@chrisdown.name> Date: Wed, 02 Dec 2026 10:16:16 +0000 Message-ID: <2vxzv75cugwf.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) X-Mailing-List: linux-api@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain On Tue, Dec 01 2026, Chris Down wrote: > include/uapi/linux/liveupdate.h documents the errno contract for > /dev/liveupdate and session fds: ENOTTY means "the IOCTL number itself > is not supported at all", and EINVAL means "everything about the IOCTL > was understood, but a field is not correct". luo_ioctl() and > luo_session_ioctl() only keep that promise when the command number > lands inside their ops table. If _IOC_NR(cmd) falls outside it, they > return -EINVAL, but they return -ENOIOCTLCMD (which userspace sees as > ENOTTY) when the number is in the table and the full command does not > match. > > This matters most for feature detection. Say a program built against a > newer uAPI calls an ioctl the running kernel does not have yet, such as > LIVEUPDATE_SESSION_GET_NAME on a kernel that predates it. It gets > EINVAL, which is exactly what a known ioctl with a bad argument > returns, so it cannot tell "unsupported" from "I passed something > wrong". A kernel that returns ENOTTY for the same number is > unambiguous. > > It also shows up when something probes an fd it did not create, which > session fds allow since they can be passed around (eg. via a service > manager's fd store). Current glibc sends TCGETS2 from isatty() and > tcgetattr(), and its number is outside both tables: > > isatty(luo_fd) -> EINVAL > isatty(session_fd) -> EINVAL > ioctl(session_fd, TCGETS, buf) -> EINVAL > ioctl(session_fd, _IO('T', 0x40), buf) -> ENOTTY > > Documentation/driver-api/ioctl.rst also says an unknown command should > get -ENOTTY or -ENOIOCTLCMD and that returning -EINVAL there is wrong. > > Let's return -ENOIOCTLCMD for out-of-range numbers too, as the in-range > mismatch already does. This does change the errno for a released > interface, but the selftests only expect EINVAL for known commands with > bad arguments, and those still get EINVAL, E2BIG and so on from the > later checks. systemd's fd_get_luo_session_name() already treats ENOTTY > and EINVAL alike when it falls back for a missing GET_NAME, and its > other LUO ioctls only issue commands the kernel knows. > > Fixes: 81cd25d263a1 ("liveupdate: luo_core: add user interface") > Fixes: 16cec0d26521 ("liveupdate: luo_session: add ioctls for file preservation") > Signed-off-by: Chris Down Reviewed-by: Pratyush Yadav [...] -- Regards, Pratyush Yadav