From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4CC5606A336 for ; Wed, 2 Dec 2026 10:16:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=2kuZvqBc; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WUf5QV8a DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:References:In-Reply-To:Subject:Cc:To:From:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=lqf70M+kyox6UvzPpJ0AqwGMVZ2vDiG1rNrkRKurWTY=; b=2kuZvqBcHucD9o/9bsWhzcWhFj CWrZl2XNJCaBV+25hTrbYb0tgOdxsP/ewQBiNWBIK/6xfuwfumKaSIANYxeEIZ9UZshY2YGwyis89 3l8d7mpYZP08VDvCjU0jnikL1Lk4j0CAVvLkjkmr3dIrj/BT8cz5C0ztUDiu4urZTT1kJrCYKlkzB Klj1DlwzxkmvgASmAlH6ZUqRAzf3l9XdgTx46EsPYAkMddzEL3u6tz8ufOWeFa+D+Jv50FkuqIAfY OB6Tg92LfVdproXR+nucdvG2nKfKPfdABgHSglQmP/ZGjQ414cnpyQLB05ILOTLGLAsrqcAewq2ms RGt2vWGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYhNu-0000000B7jS-2LcI; Wed, 02 Dec 2026 10:16:22 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYhNt-0000000B7ia-0J3R for kexec@lists.infradead.org; Wed, 02 Dec 2026 10:16:21 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 76E50439AC; Wed, 2 Dec 2026 10:16:20 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" X-Spam-Status: No, score=-12.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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