From nobody Tue Jun 16 11:17:58 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 2853F3A6B63 for ; Mon, 20 Apr 2026 14:17:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694669; cv=none; b=aoxe4dZ3kYANbRtWsjo2DSfYq3/6W3kxmQE8GGOeO01YNIt89Nrzb1Ylu1/RrZjQ0V+nxN/p1qe8Tl9mMaHANaD/4wJIu6zF+mc2LSY+P/uaNuUTmDNQ5aKeFpWvpNawNWHT0200CDLTFCkgINo2KcHKAQMDW0eKkgJ9KCtB4eQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694669; c=relaxed/simple; bh=XXPkTwopdDCp7FeFrFKnbkYSe6hdz8wRc/+VgjZoHw4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YlT83doJBDa5AR0Ay0s8bF4yxa3G7X0M9jAOZuFTupIpQX6UqfEitGs0h/T5i4ANRC2k8//L174xdX/svnkIao71AEr19KN5BK8QkFdsgFVDFdtZT5Al/aOZ4FXA7ujibB3vy/FZ5ywzTK2+k9yaUxV9v1w7VVwB7eeWES6kkX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l6TILPns; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l6TILPns" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4891e5b9c1fso8913905e9.2 for ; Mon, 20 Apr 2026 07:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776694666; x=1777299466; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qewxjB4gqze9ueAsfaggwvN0d9awd7MKHEueXVS3eI8=; b=l6TILPns07lq4uvJwZqzNiuzzM6F9qqtZWmQYElP/VeiAWjIXq2CAmw6SlwzKwQq94 qekzmWYDZtJLD7rb3wwf9vedTO4kpihlax4+OFn56RMaYXjrUgqV8wrf5ws3krgeSN8Z x2FhlU6YVmIjdGT0uxq6v/+1dSWm+DxapV3gnmnrA1s0IRXTuyhAuBAVIp/nvCOPPe9W /TuFu9vrEHjQvXSKGWsY6EAKIyWpLzD15bv5mu9Ny/rwGWPoHvErfUsIUwFb/RQMVdO4 6j/2NzxUTIxPgnwYuZwRZqLSbXgMYKmu3Fomy0LkwEjAvAAKoQ7rDSwRmWg5trPNODHo xfaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776694666; x=1777299466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qewxjB4gqze9ueAsfaggwvN0d9awd7MKHEueXVS3eI8=; b=Q039jy59pT7Go8OMKp+0RX51UHz5G3HIx7i6VDOPoalYX3gBOq3nVy17cYz94LZDP5 F3h3v9kIj2yka2ugu9/b5RQZcXUFizK+N5Wfx3/Bc4vEExBGf5Vp0xS/USxSZwxW0r9q 5kaUS2eUWWXoF1H8lbASjjZSDMErmXiXcWBJEtm/yiUWPQ5tNkqup7vnEWd29Ht+iM1Y VKrZfH5zSlfQnqjiLRbuwvGnbLFxFAD0hkg7beVSaHZ7v+B5bm5yslt3gbgC9F2sW9Jo HaNnK5qYmP3jXKtr5dARpqOZB9krKrqmU9WS4A0NBTkRoZ8LlWD9yraQDtNm2mwx6HJ+ i+PQ== X-Forwarded-Encrypted: i=1; AFNElJ/nwqkdO97Z0dRV/sZkR2N3w9ICgz6TATH4DDYMv6xWGTkxhSPkughCDd368n/AgDXubhF7x/AS7x4EzjA=@vger.kernel.org X-Gm-Message-State: AOJu0YxWMOBqliCnQJgJAXCKX7VW2dcTspHTSJa+lYN8U0K6+sX5iUku fcn+vImAb6W2Ap1NNTo/TqyQGtdzk+6IeJlrrp8YQdYab4IUrXOfU8i6plnNtQ== X-Gm-Gg: AeBDieuaKBZb3niaNVGBoeozj80Xw6rrB7c8dWACf0SmQXvYlVF/tsOTFdNZUkEB+XO udJs4q3UC0S+EAnzkIsNcPVVvV1G0nOwesoGROLpeeJVygC3vfWGw1ZhVtnT0guL6+ShNoNTHUS 4+0eKy/o5nFM+C70nDxXlShvuahNarCnF12x95gHnLiYmM0MlW++TWrECEpKJA35EL+iRy1AOf9 lJ6RrtBNAkJJsne5pPRLbtYPKie7B8/iPmUNjXViYtkMwJcIh63PZzbRe0xD3VW22uIVi8qCeJQ MnOqjD6T/ZROqH0EzEqC+o98zc/R1Gy2VuQk6sZ2qR02QNsVbUFLfff+ZL0xYYVGMQB8YiZDtk8 tuWgLkF5sKxgAc6LYIv8vJ3uLqv0Z9YRLXNwFVgNaUPwXsV6A0A99wI2AWqb+Rid2WQS7INjsKG IlojO0TBijK5aNBMpLKId6vNYE3Q+/Xcp2pzrdXqfxgPpRoKs5sQ== X-Received: by 2002:a05:600c:6296:b0:488:c40b:c8a4 with SMTP id 5b1f17b1804b1-488fb73d764mr194293145e9.1.1776694666131; Mon, 20 Apr 2026 07:17:46 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:355d:3be4:308b:c943]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-488fc1c0354sm269742375e9.11.2026.04.20.07.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 07:17:45 -0700 (PDT) From: luca.boccassi@gmail.com To: kexec@lists.infradead.org Cc: linux-mm@kvack.org, graf@amazon.com, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org, Luca Boccassi Subject: [PATCH v9 1/6] liveupdate: reject LIVEUPDATE_IOCTL_CREATE_SESSION with invalid name length Date: Mon, 20 Apr 2026 15:15:09 +0100 Message-ID: <20260420141741.2688371-2-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260420141741.2688371-1-luca.boccassi@gmail.com> References: <20260420141741.2688371-1-luca.boccassi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luca Boccassi A session name must not be an empty string, and must not exceed the maximum size define in the uapi header, including null termination. Fixes: 0153094d03df ("liveupdate: luo_session: add sessions support") Signed-off-by: Luca Boccassi Reviewed-by: Pasha Tatashin Acked-by: Mike Rapoport (Microsoft) --- kernel/liveupdate/luo_session.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_sessio= n.c index 25ae704d7787..5e316a4c5d71 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -382,9 +382,13 @@ static int luo_session_getfile(struct luo_session *ses= sion, struct file **filep) =20 int luo_session_create(const char *name, struct file **filep) { + size_t len =3D strnlen(name, LIVEUPDATE_SESSION_NAME_LENGTH); struct luo_session *session; int err; =20 + if (len =3D=3D 0 || len > LIVEUPDATE_SESSION_NAME_LENGTH - 1) + return -EINVAL; + session =3D luo_session_alloc(name); if (IS_ERR(session)) return PTR_ERR(session); --=20 2.47.3 From nobody Tue Jun 16 11:17:58 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 4868E3A6B9C for ; Mon, 20 Apr 2026 14:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694670; cv=none; b=qfVZ2ScIDvvQvqb/G2LyOYv8CA6j99/g34v1GO+aH9Zaooa34AfJB8Hpsc5D9qo9e/Uxdh4RSyS5RXPe8G5mr1nfCe/nqqqjAUVtrtBbaD8ZWrkCrDUw9tT6elC+bHKe1XO3PlhJYRCwZpklA29kGRfkv2bQiaYNzcpPC5374As= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694670; c=relaxed/simple; bh=QhJfDHi/8rLPhR+jmwtM7LFYMmAbOTEzS0sOBNZ8mPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nDjvuqRe4mHSwxTskD6Glzjk2WTQKlUydIb+Kh9hA0qBZqNJNl1i29yL7/xNVF/SWdiRDkhkk0FgLEQIr2sI+o1OcdvldSLvWsuhSJcfC3m+6lyzLxSBsIgD7KVettxTlhwQnNBlfHEoR6uRPcUtUhhn0TFwQciBFnzJvahNEGY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WgEC06F4; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WgEC06F4" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-43d7650202fso2501296f8f.2 for ; Mon, 20 Apr 2026 07:17:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776694668; x=1777299468; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f2+fqkbJq3L5Dr2igTq44CcXT0ZR7odi5lkKx2bdprE=; b=WgEC06F4JxIs32kX0Vb+4cG66uC2jiFJmhaOGZqTVeE5PumisJ62aSX4HRig43+5LU oXnqz9mBJz3cNTCYses2NtAp+gS/DklxitRBNNwASHeccNMVQqRcRNRTxIvIRhTqSezx eC66DWGpL6ab4hRugP+5H3Ch8J65VYXC/ktKUUjtOKBzIlNQW7bGDK5agc0xAvepVJhU Fb0riNFCnD4ZdrPpwtzTMS/r8R2LRF5UO3T3mcPatxI1VVbF3LqRSqe5Rbb81i7+fLHZ bX4AeLgJQhFMILL+gy8SffNPTitDz12Rwa754vsJdYmtlvcOI9Rvtq9GF61+uCaabv2u fTZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776694668; x=1777299468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=f2+fqkbJq3L5Dr2igTq44CcXT0ZR7odi5lkKx2bdprE=; b=rj9IPXSKnOTMT8+AvbU2jbmwubFQtyPb/LtHDGNHVUR5EVVbDZa76wx2+6nchob7xd hFVtTUof5LjuqW4TYjPpXNNyWQkJJhiWffdauz0FiecUwGoLJ5xIchU1shOymbhAf+zo s2WQi+1MXL1NE0Oz0bAdAWws7Y6fXdy2eHRnbBHDPIr0YNCIx7ZQPEcM3v7FxVmkk/hC OJsAjOvThpY4TLNOB8nc6C5OvmDp3Ov+jdrfBPg6I75kWn2t4wQ3BQmWxoEnPVqRMfaZ pI7xn++kYiZgKGTDfD3HA/JacAKKrFAFPITD7Ma4RYqwFl27gZJTkmDLJbgvUrBptF69 earg== X-Forwarded-Encrypted: i=1; AFNElJ8vHB8nWSwuVpj7wvaSxSz67p2jbpOp1sDzUqWxIkUrT41UY4t4rFhq0RTR8GYvLBR/8tvC3nYiNtUEMxg=@vger.kernel.org X-Gm-Message-State: AOJu0Yxli5yfNnn3Cis+VV5/o1R6JQXbINtjRjBFi/Rf0M/qT07A7U0h vDR9Ek12q4TinUtXfU42O6B4k2aI1aA2pdAKErahH2ngnLbk+BRU/Fvp X-Gm-Gg: AeBDietb0691RCoi1qKPNX6yVTR7yUao4Uwxuu0vv3WZHDZsI4r+uezOIsn8wNtTLyQ FiDcbdO+87dtWl6Z0uCSV2jup+BKnrdMcZfX+XqpjdnZvFwWflRdiLfIODU8oMeRmopuah9iMCE YWGpHefqvAYhTlh4pUeXwRC0lVCMSZ/gKRGf4M44zU4LW/Qc4FtsEj4g5V0xtM6x5E09Rm3twrm 7qDpB9deaHErV/ixILAVChB62MCSamOXR+Q1M+ZLuqnfghU1fJnE0UL67S1d9ShqZ5xjRCSiB2W 9Dl/dSz3BEI76LOVUR6k5PNtUsA2C00Xu2gMvrm7VgYR8ZstNdSpaTANvr1Ejuhd2k4NM32byIZ FcO+tYcbDUG9mkjvSOHIQcw2mS4ghXm4JCI6ZKT+AxodnR4Ph49i9Lw6mquni2ES3nXs7WeXlLo 4cotNdTEjM0OlbwFGpPB4S79vIEqb7beyXsfDogWQ= X-Received: by 2002:a05:6000:186c:b0:43e:a703:3665 with SMTP id ffacd0b85a97d-43fe3e0c6femr21089126f8f.25.1776694667476; Mon, 20 Apr 2026 07:17:47 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:355d:3be4:308b:c943]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-43fe4cc375dsm26832847f8f.14.2026.04.20.07.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 07:17:46 -0700 (PDT) From: luca.boccassi@gmail.com To: kexec@lists.infradead.org Cc: linux-mm@kvack.org, graf@amazon.com, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org, Luca Boccassi Subject: [PATCH v9 2/6] selftests/liveupdate: add test cases for LIVEUPDATE_IOCTL_CREATE_SESSION calls with invalid length Date: Mon, 20 Apr 2026 15:15:10 +0100 Message-ID: <20260420141741.2688371-3-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260420141741.2688371-1-luca.boccassi@gmail.com> References: <20260420141741.2688371-1-luca.boccassi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luca Boccassi Verify that LIVEUPDATE_IOCTL_CREATE_SESSION ioctl which provide a name that is an empty string or too long are not allowed. Signed-off-by: Luca Boccassi Reviewed-by: Pasha Tatashin Acked-by: Mike Rapoport (Microsoft) --- .../testing/selftests/liveupdate/liveupdate.c | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tools/testing/selftests/liveupdate/liveupdate.c b/tools/testin= g/selftests/liveupdate/liveupdate.c index c2878e3d5ef9..f0a8e600c154 100644 --- a/tools/testing/selftests/liveupdate/liveupdate.c +++ b/tools/testing/selftests/liveupdate/liveupdate.c @@ -345,4 +345,46 @@ TEST_F(liveupdate_device, preserve_unsupported_fd) ASSERT_EQ(close(session_fd), 0); } =20 +/* + * Test Case: Create Session with No Null Termination + * + * Verifies that filling the entire 64-byte name field with non-null chara= cters + * (no '\0' terminator) is rejected by the kernel with EINVAL. + */ +TEST_F(liveupdate_device, create_session_no_null_termination) +{ + struct liveupdate_ioctl_create_session args =3D {}; + + self->fd1 =3D open(LIVEUPDATE_DEV, O_RDWR); + if (self->fd1 < 0 && errno =3D=3D ENOENT) + SKIP(return, "%s does not exist", LIVEUPDATE_DEV); + ASSERT_GE(self->fd1, 0); + + /* Fill entire name field with 'X', no null terminator */ + args.size =3D sizeof(args); + memset(args.name, 'X', sizeof(args.name)); + + EXPECT_LT(ioctl(self->fd1, LIVEUPDATE_IOCTL_CREATE_SESSION, &args), 0); + EXPECT_EQ(errno, EINVAL); +} + +/* + * Test Case: Create Session with Empty Name + * + * Verifies that creating a session with an empty string name fails + * with EINVAL. + */ +TEST_F(liveupdate_device, create_session_empty_name) +{ + int session_fd; + + self->fd1 =3D open(LIVEUPDATE_DEV, O_RDWR); + if (self->fd1 < 0 && errno =3D=3D ENOENT) + SKIP(return, "%s does not exist", LIVEUPDATE_DEV); + ASSERT_GE(self->fd1, 0); + + session_fd =3D create_session(self->fd1, ""); + EXPECT_EQ(session_fd, -EINVAL); +} + TEST_HARNESS_MAIN --=20 2.47.3 From nobody Tue Jun 16 11:17:58 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 6447C3A6EFF for ; Mon, 20 Apr 2026 14:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694673; cv=none; b=WcZRY0u29umAp4y9mmAKjbci+qbIcYI56VXBgAgSgNi1A8WSqcS+Oi2C/ppbgMsPEYqmEVHH74z81WD+12ClNG6Y0F6tOEh5mIIYTBal1tcCXozKzDWH/7KSpg8fPrgdQ10IVCUMNHsaNsBWuei1QCSsuUI3IFi+pkcPVT0+qfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694673; c=relaxed/simple; bh=FMg4HugNWBcQQnbNv1qg8BJUGKAih9Ij59/oNIpscbg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iez1Fk1WSwRHSF0rPTHbk3UEV7ajI3+hiWLvqq274Joy1CttVbXcw9BncEEoXUzmliVY2jNmbyaIzLBDFMTo5/ZH/wMw187NvN5azwmTz4CbMI1Rh6J1gxE8858ZjYljJvBfvvkO20kfUmfgmE1CwYYuuVPWGHjW5BPvSHXExIU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pjo9I9A/; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pjo9I9A/" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-43d76dd4ee8so2905437f8f.2 for ; Mon, 20 Apr 2026 07:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776694669; x=1777299469; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M1sjF4LQS9btS3anaMkMUdTrbJ6r/ruqhuae7ESZnko=; b=pjo9I9A//JloxG1m1cMDMZ6+PmINfrZ51P9ZKj002xU3WJRkCGpuED6FUjCZamNVYb yUTEPqEu7rF3dktqH/eiHaVh87jkknL/WNi4n3PWEklKGwpllU2CbDU759GvPqRjs6j4 TC3pgm2M4asMZYF42nHS6BqGu50CIVlS+SH6uP/liV43TQ1V1vrU7/LBC/y3TUEO1hv2 0uWcf1wCCqnkN2EVD0496ZXB5EEQjRfXs3ymtxcwt6tBOfvdm9BMJtOXlQmbagzJm47a naD5plnKnYXufVmRKyreKEM0ASjpjdrEShqQS90I3iQw7LA/IX69ggAxMcCjkPLoCx5i yu0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776694669; x=1777299469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=M1sjF4LQS9btS3anaMkMUdTrbJ6r/ruqhuae7ESZnko=; b=tQqBfhJpxtb7YMn19aYwtsNR1yKxtUB/RyiPB4lLcAZF2ZclNwMTYGZPYPsU5UfgiI YPUcuUbklfaYMW4rVy8Sv6Qeq2PNvWI+pym21XvxEvRGcfxYshHI3AVbzFDDe7uGwiFT n5ZQPG0n6yNFlm0dzv6GtLZ8RIQZFUY7N6XsKQbvdCCk0H2QHDu6MgeJ6h3TsnPHIHXO Dy+UVLoZgFF4RkVDahF5EYAJjUpGSkC91swawmnh8Ewsl0qz+bDdK96nnxhY0/GTZmWB Y8T5oibzW75DP1arezxUmQAdKYfw7UmQto6yEWhUf0Grz6w9DyBnSFCePradKhSh/aw5 W78w== X-Forwarded-Encrypted: i=1; AFNElJ9p96zoNeX+JQ9QMLRVEfahVz9dflFQooOf5pgVtSilxbZBGh2aiG5ZXAWurfVJSqLzbwzKRuUYNoNoSwY=@vger.kernel.org X-Gm-Message-State: AOJu0YxGT1TmmA7pIrDi68NL3tISsmGIKbgaxNdyAb+/Cp5DPsr3WGIT h6vr8rNgps8hsCX0iFoeU9jbaGXV7VE7pk4nKaqZEHjy0qHquqRJY0IQ X-Gm-Gg: AeBDietUpgbSTWkhvFqnX26JH0BhwOM+Y6g9hFafuF4KDNavvbA1nZxO3O9TkGlPCjm fWa5IGgKo8e5Q8LgC2FSOgmkq/VWFmGdGqDBKtr156tCca/O8LvqgL494dnqUmVmg+3TLQjC8a6 +OhuKcbEbzEBC9zaMPBbYPwxI0C3ZgXD5VF9mGM4yztX7NguVtGQjgON/fbiVBjNl1OskRJaRk2 3qLan1UwlkgunFmAoz7RX5ROFqEmv8TjYrdy+2ZnDT//+gv15sxFqd5zOe/ia5Gt4feIo5OTo2/ dIA4XDgWScaStNzT5IdyClLgvgmcxZd10UauMKK5rklm6G7WlubElWo+s65F8mEDEmLf4Kfv4+T 4RC+onpNUmEsDGNb9rHbZ/Czb9jj771HSYQ4GRLsWIlhj5MOve+ROFbC03BV7lu7IGXoXMuUIbK IhSI/D5UjHZAXx9nbTqs+SwZnGHWk8PYRJPWJOdCI= X-Received: by 2002:a5d:5f43:0:b0:43c:fde6:212d with SMTP id ffacd0b85a97d-43fe3e13d46mr21731613f8f.33.1776694668709; Mon, 20 Apr 2026 07:17:48 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:355d:3be4:308b:c943]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-43fe4cb1405sm28641928f8f.4.2026.04.20.07.17.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 07:17:48 -0700 (PDT) From: luca.boccassi@gmail.com To: kexec@lists.infradead.org Cc: linux-mm@kvack.org, graf@amazon.com, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org, Luca Boccassi Subject: [PATCH v9 3/6] liveupdate: add LUO_SESSION_MAGIC magic inode type Date: Mon, 20 Apr 2026 15:15:11 +0100 Message-ID: <20260420141741.2688371-4-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260420141741.2688371-1-luca.boccassi@gmail.com> References: <20260420141741.2688371-1-luca.boccassi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luca Boccassi In userspace when managing LUO sessions we want to be able to identify a FD as a LUO session, in order to be able to do the special handling that they require in order to function as intended on kexec. Currently this requires scraping procfs and doing string matching on the prefix of the dname, which is not an ideal interface. Add a singleton inode type with a magic value, so that we can programmatically identify a fd as a LUO session via fstatfs(). Signed-off-by: Luca Boccassi Reviewed-by: Pasha Tatashin Acked-by: Mike Rapoport (Microsoft) --- include/uapi/linux/magic.h | 1 + kernel/liveupdate/luo_core.c | 10 +++- kernel/liveupdate/luo_internal.h | 2 + kernel/liveupdate/luo_session.c | 91 ++++++++++++++++++++++++++++++-- 4 files changed, 98 insertions(+), 6 deletions(-) diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 4f2da935a76c..4f51005522ff 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@ -105,5 +105,6 @@ #define PID_FS_MAGIC 0x50494446 /* "PIDF" */ #define GUEST_MEMFD_MAGIC 0x474d454d /* "GMEM" */ #define NULL_FS_MAGIC 0x4E554C4C /* "NULL" */ +#define LUO_SESSION_MAGIC 0x4c554f53 /* "LUOS" */ =20 #endif /* __LINUX_MAGIC_H__ */ diff --git a/kernel/liveupdate/luo_core.c b/kernel/liveupdate/luo_core.c index dda7bb57d421..f1a63ebe4fa4 100644 --- a/kernel/liveupdate/luo_core.c +++ b/kernel/liveupdate/luo_core.c @@ -197,9 +197,17 @@ static int __init luo_late_startup(void) if (!liveupdate_enabled()) return 0; =20 + err =3D luo_session_fs_init(); + if (err) { + luo_global.enabled =3D false; + return err; + } + err =3D luo_fdt_setup(); - if (err) + if (err) { + luo_session_fs_cleanup(); luo_global.enabled =3D false; + } =20 return err; } diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_inter= nal.h index 8083d8739b09..d4ac7b4c5882 100644 --- a/kernel/liveupdate/luo_internal.h +++ b/kernel/liveupdate/luo_internal.h @@ -79,6 +79,8 @@ struct luo_session { =20 int luo_session_create(const char *name, struct file **filep); int luo_session_retrieve(const char *name, struct file **filep); +int __init luo_session_fs_init(void); +void __init luo_session_fs_cleanup(void); int __init luo_session_setup_outgoing(void *fdt); int __init luo_session_setup_incoming(void *fdt); int luo_session_serialize(void); diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_sessio= n.c index 5e316a4c5d71..9e343b6ce513 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -50,7 +50,6 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 -#include #include #include #include @@ -62,11 +61,15 @@ #include #include #include +#include +#include #include +#include #include #include #include #include +#include "../fs/internal.h" #include "luo_internal.h" =20 /* 16 4K pages, give space for 744 sessions */ @@ -363,18 +366,74 @@ static const struct file_operations luo_session_fops = =3D { .unlocked_ioctl =3D luo_session_ioctl, }; =20 +static struct vfsmount *luo_session_mnt __ro_after_init; +static struct inode *luo_session_inode __ro_after_init; + +/* + * Reject all attribute changes on the singleton session inode. + * Without this the VFS falls back to simple_setattr(), allowing + * fchmod()/fchown() to modify the shared inode. + */ +static const struct inode_operations luo_session_inode_operations =3D { + .setattr =3D anon_inode_setattr, +}; + +static char *luo_session_dname(struct dentry *dentry, char *buffer, int bu= flen) +{ + return dynamic_dname(buffer, buflen, "luo_session:[%s]", + dentry->d_name.name); +} + +static const struct dentry_operations luo_session_dentry_operations =3D { + .d_dname =3D luo_session_dname, +}; + +static const struct super_operations luo_session_sops =3D { + .drop_inode =3D inode_just_drop, + .statfs =3D simple_statfs, +}; + +static int luo_session_init_fs_context(struct fs_context *fc) +{ + struct pseudo_fs_context *ctx; + + ctx =3D init_pseudo(fc, LUO_SESSION_MAGIC); + if (!ctx) + return -ENOMEM; + + fc->s_iflags |=3D SB_I_NOEXEC; + fc->s_iflags |=3D SB_I_NODEV; + ctx->s_d_flags |=3D DCACHE_DONTCACHE; + ctx->dops =3D &luo_session_dentry_operations; + ctx->ops =3D &luo_session_sops; + return 0; +} + +static struct file_system_type luo_session_fs_type =3D { + .name =3D "luo_session", + .init_fs_context =3D luo_session_init_fs_context, + .kill_sb =3D kill_anon_super, +}; + /* Create a "struct file" for session */ static int luo_session_getfile(struct luo_session *session, struct file **= filep) { - char name_buf[128]; + char name_buf[LIVEUPDATE_SESSION_NAME_LENGTH + 1]; struct file *file; =20 lockdep_assert_held(&session->mutex); - snprintf(name_buf, sizeof(name_buf), "[luo_session] %s", session->name); - file =3D anon_inode_getfile(name_buf, &luo_session_fops, session, O_RDWR); - if (IS_ERR(file)) + + ihold(luo_session_inode); + + snprintf(name_buf, sizeof(name_buf), "%s", session->name); + file =3D alloc_file_pseudo(luo_session_inode, luo_session_mnt, name_buf, + O_RDWR, &luo_session_fops); + if (IS_ERR(file)) { + iput(luo_session_inode); return PTR_ERR(file); + } =20 + file->private_data =3D session; *filep =3D file; =20 return 0; @@ -653,3 +712,25 @@ void luo_session_resume(void) up_write(&luo_session_global.outgoing.rwsem); up_write(&luo_session_global.incoming.rwsem); } + +int __init luo_session_fs_init(void) +{ + luo_session_mnt =3D kern_mount(&luo_session_fs_type); + if (IS_ERR(luo_session_mnt)) + panic("Cannot create LUO Session pseudo-fs"); + + luo_session_inode =3D alloc_anon_inode(luo_session_mnt->mnt_sb); + if (IS_ERR(luo_session_inode)) { + kern_unmount(luo_session_mnt); + return PTR_ERR(luo_session_inode); + } + luo_session_inode->i_op =3D &luo_session_inode_operations; + + return 0; +} + +void __init luo_session_fs_cleanup(void) +{ + iput(luo_session_inode); + kern_unmount(luo_session_mnt); +} --=20 2.47.3 From nobody Tue Jun 16 11:17:58 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 DC4533A7595 for ; Mon, 20 Apr 2026 14:17:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694673; cv=none; b=fN1ScmhIhVNYQKcxTvsC3bomFau5JDnyLmyOmnCNcn19ls15wsufC5umG/Nr6c34fKaXuy2BNHQn4iJpdMgjFX712kH9qq3SOG30EcAJQh0kjfIY7C+ESjlEv9pnUUqFBoHzkKHhK7Om0IiQ4cOAaCfYOyaFUaD5zPVnLimcHvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694673; c=relaxed/simple; bh=9FPE02ERZryko8uGsS8iQk6xBAb6rnmNKWj00ovQPD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jvIQNVQdukJ5BuikUTyyi8Biv8VdTOFeve0zlIdon4TuC83kQuBc9osQrhDd+2Vt+sRKwcQpSROMGWk8CBhZ+UT9zYNJJVTI52IoWdiGbFsyq1O9qFuFI09MTkyj9OpFbv84En1z/0/YpBDpyFooRZvhybMzB3jiV4KDCLuiNkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iKHJHEiP; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iKHJHEiP" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-488b0e1b870so48092275e9.2 for ; Mon, 20 Apr 2026 07:17:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776694670; x=1777299470; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vjAX0smE41BTNjnnRZCLx7DL1jbmxY9+auerdTALqsI=; b=iKHJHEiPK8xLjyrLZEkNETEAR7JQl80wp15Ohde7KWWkSbKcq4Utrx65zBeAttzjIF fKhWrPwxphqvPSnUfViPlYamxRaGAhFTc7IYJUtNd/YRGns+beGtWlNdn2BbRYk++nFb M1qe5nQ7uRFnMqlGGLPe/TyuVLXhbuew97nEG3log9i8FXFho8HfBQHcjq9uCT84s+in pCYYflR4CMyw/Fm1DtPIgfSG96e0dYo5Hjc06AsxON8NSBS9xpsuKT6G9b93kEvK4/LT Vh+e1HdZYX4a7RnHrCmMzpf08cUO3W7vKeYuISqYZ2u7XSp5/0u25NwmfmOKOGjnirQz sgBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776694670; x=1777299470; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vjAX0smE41BTNjnnRZCLx7DL1jbmxY9+auerdTALqsI=; b=tRGTTGFTLH8QN+xduOpBO19rMncM3SQsgxm7/epI6LV6qvS0qGg3D4fBRLi/2+EgWl ZEJp84IgxbKGnXL/qR43P/85rSbEQPjb8M61kzfxcq9hlMIwow8o4GX7miEd6umrJLwZ TOFeTv3aqiZl2hI9EHXcKslF8G7kald7u2A0rtXClyHySvazO5FY0lnxX9n+9YtLJ32I i1EMdyb82Fwb3G2cw5r/yEejxzq8UXHnGRakJlZTpaOLTsOGyij9qqSs0h8YwaD86LPf 7m2WV2Yhhe6vYqKCyzDeaDU46yxUeZei8amuCs62OMxPXJrr4w7vaYg15yICUrA1c/tH 4DSw== X-Forwarded-Encrypted: i=1; AFNElJ/qMXy6NAcG2i/dtzyuofVqb+rsZxw5X29uk1kNZfEMuaIcyvAj5FXuPKEqEqF0932vFr4cyKYVukM0ua4=@vger.kernel.org X-Gm-Message-State: AOJu0Ywn3JiTDhyYtuZGhiqZjGf5kCXMWjpPfJ6En5vJIdOZpt9ACIMX SLtIsKclh7uqUJsRAPZozSBlpBHXHywl6y9+pTRQbxnHrDwEwyHyfYdA X-Gm-Gg: AeBDiev4VSwCzJmOXeKmbHpb0mV22t1zTcWWieDNnUCqBWViGHmV6JcYxR+KQRJsagF FsMEKY0AaI2lbyqZClcEWpQNYW5jySlMcutmRlf0AHHZotu7CjD/mcykJCXUDNxt+FBXNyY1aeG MC72HikAjZmxXZjSG9VWc5AX9yxHjTVnDLVSdk86hbRoiKvHece81pwEoXUflhOzih8sXx5KBVR NEXeVBResi7sZb1/Ikcr8Qwnzrh2vKYJssh6/868imRVLv1ZXpGx5P4bciHyAsY1YpvnwGAjCcB +/00+JHWP6pETMe1jnanlIvQ9VrwTRKejfSxTPcVDPs9a3ei+oRYWseLnnirPj9wNvLXq8nbMST 4jicYEZ7QL9knjlByKr/SD2+wl4eXmZ+il9DvBp2fASVnqm2IuiG2QVIuwS6bVRL6c9lfrdkXNI AmGwisMwxyfINoaMT6/j7Z4PXxddDHErQ29vB3/1o= X-Received: by 2002:a05:600c:8b38:b0:488:b14f:b8ed with SMTP id 5b1f17b1804b1-488fb6e815amr205856885e9.0.1776694669910; Mon, 20 Apr 2026 07:17:49 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:355d:3be4:308b:c943]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-489207ebd3asm23410595e9.6.2026.04.20.07.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 07:17:49 -0700 (PDT) From: luca.boccassi@gmail.com To: kexec@lists.infradead.org Cc: linux-mm@kvack.org, graf@amazon.com, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org, Luca Boccassi Subject: [PATCH v9 4/6] selftests/liveupdate: add test case for LUO_SESSION_MAGIC Date: Mon, 20 Apr 2026 15:15:12 +0100 Message-ID: <20260420141741.2688371-5-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260420141741.2688371-1-luca.boccassi@gmail.com> References: <20260420141741.2688371-1-luca.boccassi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luca Boccassi Verify that fstat works as expected after the switch from anon_inode to the new magic number. Signed-off-by: Luca Boccassi Reviewed-by: Pasha Tatashin Acked-by: Mike Rapoport (Microsoft) --- .../testing/selftests/liveupdate/liveupdate.c | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tools/testing/selftests/liveupdate/liveupdate.c b/tools/testin= g/selftests/liveupdate/liveupdate.c index f0a8e600c154..5e99af0cc6e9 100644 --- a/tools/testing/selftests/liveupdate/liveupdate.c +++ b/tools/testing/selftests/liveupdate/liveupdate.c @@ -22,9 +22,12 @@ #include #include #include +#include +#include #include =20 #include +#include =20 #include "../kselftest.h" #include "../kselftest_harness.h" @@ -387,4 +390,41 @@ TEST_F(liveupdate_device, create_session_empty_name) EXPECT_EQ(session_fd, -EINVAL); } =20 +/* + * Test Case: Session fstat + * + * Verifies that fstatfs() on a session file descriptor reports the + * LUO_SESSION_MAGIC filesystem type, and that fstat() returns consistent + * inode numbers across different sessions (shared singleton inode). + */ +TEST_F(liveupdate_device, session_fstat) +{ + int session_fd1, session_fd2; + struct stat st1, st2; + struct statfs sfs; + + self->fd1 =3D open(LIVEUPDATE_DEV, O_RDWR); + if (self->fd1 < 0 && errno =3D=3D ENOENT) + SKIP(return, "%s does not exist", LIVEUPDATE_DEV); + ASSERT_GE(self->fd1, 0); + + session_fd1 =3D create_session(self->fd1, "fstat-session-1"); + ASSERT_GE(session_fd1, 0); + + session_fd2 =3D create_session(self->fd1, "fstat-session-2"); + ASSERT_GE(session_fd2, 0); + + /* Verify the filesystem type is LUO_SESSION_MAGIC */ + ASSERT_EQ(fstatfs(session_fd1, &sfs), 0); + EXPECT_EQ(sfs.f_type, LUO_SESSION_MAGIC); + + /* Verify both sessions share the same inode number */ + ASSERT_EQ(fstat(session_fd1, &st1), 0); + ASSERT_EQ(fstat(session_fd2, &st2), 0); + EXPECT_EQ(st1.st_ino, st2.st_ino); + + ASSERT_EQ(close(session_fd1), 0); + ASSERT_EQ(close(session_fd2), 0); +} + TEST_HARNESS_MAIN --=20 2.47.3 From nobody Tue Jun 16 11:17:58 2026 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 2DFF83A6EF5 for ; Mon, 20 Apr 2026 14:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694684; cv=none; b=rLBRCY+fvdDD/KBSdVSlNp2SqhnYkn5yyyfw8sfh7joXSneja0BYecdOjdMvB5l/+f7WH9hAXC2GBDG4olOuwV5DvUvOey33YatbnspPb8+Kx6bwn9o1q0Xo7pFjvbQnX/1VASniR1KObUzjG8Y2vL92V5RFZ5h3pbmVAQIXif0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694684; c=relaxed/simple; bh=Iat0zTBfSOFlnYUAEt/j4W48wNopFaH0mZ/ikwy1TPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qx2wiyD1lkqBPACQebCA40OGQtUsQOoFjQyITWKWTWahSU3yJdM5vnvJqirraOP/eCGpXvT/sUJXuMxlSX1A4bhJiLz1wNqCEZ6YO9s1F3u8Se+Gri2bAdEA/HFuuiNcHDtu4dDJO4q3cd84rbNgoaLy8s9hHYUTB9SXixVQoQ0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fd4YB+81; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fd4YB+81" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-488ab2db91aso41700545e9.3 for ; Mon, 20 Apr 2026 07:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776694681; x=1777299481; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MNDqlHkLA3XwzqBTWyzDtldlB60yiBhHVXXXYk5oIQI=; b=fd4YB+81AtIINwZ1W4aVCB1vlwMBDflhpjVcRlUpLXD1p+PQTRDmnBhWAqaOYBYFN4 Yu4D2ks1zTEVmgHiwjpT8wNoHCdfI67g/2j11DB5h9aQhbbLhMDjrYpBHHyaqaKdlDtK 5t6xnhQFvBGxsX7Qwd3B2c2VTA8HOdQlJ7SHXj2HssoJx2dMCxZJv50qmez8/HRQVmlY Vuri/hDOa2F6kYn84ksUPr0Wdo9bEGe4VFN2FtRIKtD/hDjOdUbN/kAOjjlFZrM/FmSP aWkSdHKSx9W+kUHDud6w9ze/gSmiDdYS9eY1uM8aip3PIQjy+oWZ/tGogyBTaIh/T6+1 ltWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776694681; x=1777299481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MNDqlHkLA3XwzqBTWyzDtldlB60yiBhHVXXXYk5oIQI=; b=A5ZqqV+tXMm/z51R5xXjnwJxZ2kPNkk8UA9ZBj+Pj/92vI6TgPBSWC2nqGEA081xo7 1+yTOWGeMZnW1SHGfncx2hF1dWPRXwSxs4rdWLRlHHULRhUZhjnPdKLUWi5J30c6Sgne CqwAvfJB58AXKjiX8BIoJsan0Pba9QJiCkBu2E2yEJZ++ejBhiOzCPMdulOs705DjpqE JgyEPjsunNpvDqJEy2mnpw3Ei2iD1NR5koNbeJ1ps46bZsyrpedzsbiDvH0UEVFCriID JafycqwwjrNca5hysO/hPOI9ESuGwqGJE+hvVb17nAvp9wnQJBDyfbAeqwW4Q/jKQmCR aHag== X-Forwarded-Encrypted: i=1; AFNElJ/fyqo5tjLpzCZdfbj/Q8PPMOj2Kqliwj0CKb4mK4W1gFDziUCfwOGMx6kDmWmuGH+so3275ogMRpxjp5A=@vger.kernel.org X-Gm-Message-State: AOJu0Yyz4Jr+ssKzVSC70aFCKIjhXWJuv/4If7CYSsbgWTuz9sitfpwK 0SOsOwdmpGrX9UlwVBISP6fJzytR11gEd4DRzXW+qV22CRZgf+Py8PFI X-Gm-Gg: AeBDiev5TDTMc+vqjAb2d+LSx0qmvFgoo+9F+Ym8EfxXAbCUDvEKK8tC+JscLXNihRJ LVfDHDP3fh7HLoia9U6rgycdDXwvDH7wA7K5wlfIxAlWR1DbtiTdiKP8NQ/rqu8sJaeKV00Iaha kxhX/NF4cRmV9C7SeGCRhyVTNR5X6OqFKL9V0DV4ViYoXcgyT+xmYzZF/hFDUMPOJqVoYUfJ8z6 zYv0sti7+rPbNltuw5hGXiYovHquZJhu60/WdFaOZNZ2Zwjft7tuZaUhjeLvX0+tCqwiE8rLdZN md9hVca6NMu32pd+qKTB4XaXvrugozFhIMW6vYT8Y549nwcW7zHIpC3L6X1f9oUw1lHz2/IsoJo O3LanXdjLniXO8sJnsS7nQe9G2iUySI/D1mct2aY/G/jF6yajONwPmjhlt1ONsNMJBPFQOgTYnO CQRW5yGuJrRj5y77qat/3u1ma4spc5sE77sR5lIwY= X-Received: by 2002:a05:600d:8447:b0:489:1ff5:edda with SMTP id 5b1f17b1804b1-4891ff5efe1mr30879445e9.6.1776694681215; Mon, 20 Apr 2026 07:18:01 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:355d:3be4:308b:c943]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-48a52d232afsm6942375e9.31.2026.04.20.07.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 07:18:00 -0700 (PDT) From: luca.boccassi@gmail.com To: kexec@lists.infradead.org Cc: linux-mm@kvack.org, graf@amazon.com, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org, Luca Boccassi Subject: [PATCH v9 5/6] liveupdate: add LIVEUPDATE_SESSION_GET_NAME ioctl Date: Mon, 20 Apr 2026 15:15:13 +0100 Message-ID: <20260420141741.2688371-6-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260420141741.2688371-1-luca.boccassi@gmail.com> References: <20260420141741.2688371-1-luca.boccassi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luca Boccassi Userspace when requesting a session via the ioctl specifies a name and gets a FD, but then there is no ioctl to go back the other way and get the name given a LUO session FD. This is problematic especially when there is a userspace orchestrator that wants to check what FDs it is handling for clients without having to do manual string scraping of procfs, or without procfs at all. Add a ioctl to simply get the name from an FD. Signed-off-by: Luca Boccassi Reviewed-by: Pasha Tatashin Acked-by: Mike Rapoport (Microsoft) --- include/uapi/linux/liveupdate.h | 21 +++++++++++++++++++++ kernel/liveupdate/luo_session.c | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/uapi/linux/liveupdate.h b/include/uapi/linux/liveupdat= e.h index 30bc66ee9436..3a9ff53b02e0 100644 --- a/include/uapi/linux/liveupdate.h +++ b/include/uapi/linux/liveupdate.h @@ -59,6 +59,7 @@ enum { LIVEUPDATE_CMD_SESSION_PRESERVE_FD =3D LIVEUPDATE_CMD_SESSION_BASE, LIVEUPDATE_CMD_SESSION_RETRIEVE_FD =3D 0x41, LIVEUPDATE_CMD_SESSION_FINISH =3D 0x42, + LIVEUPDATE_CMD_SESSION_GET_NAME =3D 0x43, }; =20 /** @@ -213,4 +214,24 @@ struct liveupdate_session_finish { #define LIVEUPDATE_SESSION_FINISH \ _IO(LIVEUPDATE_IOCTL_TYPE, LIVEUPDATE_CMD_SESSION_FINISH) =20 +/** + * struct liveupdate_session_get_name - ioctl(LIVEUPDATE_SESSION_GET_NAME) + * @size: Input; sizeof(struct liveupdate_session_get_name) + * @reserved: Input; Must be zero. Reserved for future use. + * @name: Output; A null-terminated string with the full session name. + * + * Retrieves the full name of the session associated with this file descri= ptor. + * This is useful because the kernel may truncate the name shown in /proc. + * + * Return: 0 on success, negative error code on failure. + */ +struct liveupdate_session_get_name { + __u32 size; + __u32 reserved; + __u8 name[LIVEUPDATE_SESSION_NAME_LENGTH]; +}; + +#define LIVEUPDATE_SESSION_GET_NAME \ + _IO(LIVEUPDATE_IOCTL_TYPE, LIVEUPDATE_CMD_SESSION_GET_NAME) + #endif /* _UAPI_LIVEUPDATE_H */ diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_sessio= n.c index 9e343b6ce513..885e1f346caa 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -292,10 +292,21 @@ static int luo_session_finish(struct luo_session *ses= sion, return luo_ucmd_respond(ucmd, sizeof(*argp)); } =20 +static int luo_session_get_name(struct luo_session *session, + struct luo_ucmd *ucmd) +{ + struct liveupdate_session_get_name *argp =3D ucmd->cmd; + + strscpy((char *)argp->name, session->name, sizeof(argp->name)); + + return luo_ucmd_respond(ucmd, sizeof(*argp)); +} + union ucmd_buffer { struct liveupdate_session_finish finish; struct liveupdate_session_preserve_fd preserve; struct liveupdate_session_retrieve_fd retrieve; + struct liveupdate_session_get_name get_name; }; =20 struct luo_ioctl_op { @@ -322,6 +333,8 @@ static const struct luo_ioctl_op luo_session_ioctl_ops[= ] =3D { struct liveupdate_session_preserve_fd, token), IOCTL_OP(LIVEUPDATE_SESSION_RETRIEVE_FD, luo_session_retrieve_fd, struct liveupdate_session_retrieve_fd, token), + IOCTL_OP(LIVEUPDATE_SESSION_GET_NAME, luo_session_get_name, + struct liveupdate_session_get_name, name), }; =20 static long luo_session_ioctl(struct file *filep, unsigned int cmd, --=20 2.47.3 From nobody Tue Jun 16 11:17:58 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 6D85F3BADB6 for ; Mon, 20 Apr 2026 14:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694686; cv=none; b=irLFIHHOVCQRDc/71CnpIum3MlIdLxrmCoyx28cnmounVa4fILPBRdxgh4oulms43QKXmdU2AFajgmknaz1qEo5fJusR59qExsIQsH54p536Aq/k5RlMMkonsN+BUlk/pYi3NujEtcPJ4nVANtOtwCxIqee7eFv77fIBh4nvFJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776694686; c=relaxed/simple; bh=sPvUjpbwztOQkptVIoDbX5hm/zk3LypsaZ2N1gqbsIQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cSWIz5VKxsIiK9lXPHdyCxEiwEa91qgHhzbjQmf3lf4AoKbf81dS1z3FcuBhg8rSFZ8SBoQ9mYrI6skpki+5URMJqkjD9qTwmYdlnm9HothfWapRP5P1UajcNnItm0rNWsVHKrZaIuBLvRnCjJ5Ffjg3PEp1nRCGPOiOXTklpyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SK26vx1f; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SK26vx1f" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4891cd41959so10810595e9.3 for ; Mon, 20 Apr 2026 07:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776694683; x=1777299483; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vfZFpqwj1elMjnLHCUJlwJVYjCsTNOTD+bgkX23g2Wg=; b=SK26vx1f/6ylrppYRj7Jy+5Wsz5utvn49cLPG3kjdoEC7T5U6OO6BbsbLGZcqQqnks vwb/RAoyqVzTsykh6vQPPa+moOdNQtP3DDlUlVNDexYzOpua0aVg6n1sNoBsPtG6mqxJ eFSsfhQfaspyeuuNgeEsWqOiH5l4HgADOxhQYSFqiFZE1FcF0aELYHeFODTtaAYrAZcZ cL0PSsDZGO2ILeroLT8hrB9W4GmDUd4YGct25VycB0+MJDt36bQXhpTqc2lynA9WG3bg LrWtDfuuDiRiBevVMnPc6E3bc+eyK8B4jbNa1RlodHkmpww9q/bi46dxmvE+BvUPDe/E piHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776694683; x=1777299483; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vfZFpqwj1elMjnLHCUJlwJVYjCsTNOTD+bgkX23g2Wg=; b=WsttdBPqWrLCoprjIykrSsehSknUaVZzULj9aUgE1CucoynNokDd7poVE1q2zVHtuV S+our+srxGlLgefnG029cv60PRp2UYwaKKAxPvp/2T0fb7L9t+a4SLUYRgqMfMKffWJv pXLfO8skXOdS5WZ2ocWMkY+CEzLo+zsAblYaZzCE+lnxqHClW7AkfTP91A5Fbk8vRi6J yxo7OyOmLPpXM4mKYIHqSiUyCUh3OAhZCKqP9tmqL9PkmhNAL/5roUF+dJA49uMAqvW8 2IXFX2p1MOATnQBEby2R4+7vIi/I1HpbDnqpoea2O6DruoKebs59Py7bMRYt9y/yhJoa SQaw== X-Forwarded-Encrypted: i=1; AFNElJ8ewuUcPcngTtN3b20zjiWm3wGjPfevZJT3+0lbPYSAO3lC53iDUztYIOxr4z4QfgY7zQatq+x3XzN4kA8=@vger.kernel.org X-Gm-Message-State: AOJu0YwOZAqrwXQ6jb6rXRHaM1V/gBFO8M6THFbAMSlh/piM9uAEUK4S U/4ZQ1wMScLQw+fVsf6+XsZpYVR9XFrVgi1GaddL0dAqEnizMfn27L6A X-Gm-Gg: AeBDiesJ8gK3HR9loJxO5iTwetHLYZpcVO43qHwSEMyFU5zlO2OmtZDVNN4fBRPKtfr 7TkwJcg9uSGYSwE+qTcsGqSTLKi90W+jgucIoweu5+7VvVq2xim/+VQ2jWOcSDf5SBKKIyVWwXk WVJjAMsbHLsMpznFXz1ABkyGn8pxwo33/W7E3gqXGuuYkkk41gXffw7HZCjQpAcYzEGQhgutLOb t/Twy5fw2gSmvWOjujawABr+8TouD+ZLFav6od/70kjZwuqm2WZu7ehuKRMk/YDM3kCvtchfMUD PLnQUdEOjQd9FRkWhRvB2gFhhj5FuGJff7m7Fc8YY4DMP3iCV2PUMFB6PbLjPL6uVms6BXSToOC GSSVey6Eg7mqJlKscj1sNasKlWcfaXQ8FPwXAXnwEg6zdt+ow1hU6B4jCoVrBwXwUFohAXEqRe7 gFlVT/pS1f3VgPV6NM5oQQHCgynYxKCLu6wm4MpIPzRfouxalmbQ== X-Received: by 2002:a05:600c:3553:b0:48a:52f2:a0f1 with SMTP id 5b1f17b1804b1-48a52f2a5f0mr17660055e9.18.1776694682523; Mon, 20 Apr 2026 07:18:02 -0700 (PDT) Received: from localhost ([2a01:4b00:d036:ae00:355d:3be4:308b:c943]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-488fc0f82bbsm474198035e9.3.2026.04.20.07.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 07:18:01 -0700 (PDT) From: luca.boccassi@gmail.com To: kexec@lists.infradead.org Cc: linux-mm@kvack.org, graf@amazon.com, rppt@kernel.org, pasha.tatashin@soleen.com, pratyush@kernel.org, brauner@kernel.org, linux-kernel@vger.kernel.org, Luca Boccassi Subject: [PATCH v9 6/6] selftests/liveupdate: add test cases for LIVEUPDATE_SESSION_GET_NAME Date: Mon, 20 Apr 2026 15:15:14 +0100 Message-ID: <20260420141741.2688371-7-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260420141741.2688371-1-luca.boccassi@gmail.com> References: <20260420141741.2688371-1-luca.boccassi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Luca Boccassi Verify that the new LIVEUPDATE_SESSION_GET_NAME ioctl works as expected via new test cases in the existing liveupdate selftest. Signed-off-by: Luca Boccassi Reviewed-by: Pasha Tatashin Acked-by: Mike Rapoport (Microsoft) --- .../testing/selftests/liveupdate/liveupdate.c | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tools/testing/selftests/liveupdate/liveupdate.c b/tools/testin= g/selftests/liveupdate/liveupdate.c index 5e99af0cc6e9..c21354dc9b93 100644 --- a/tools/testing/selftests/liveupdate/liveupdate.c +++ b/tools/testing/selftests/liveupdate/liveupdate.c @@ -105,6 +105,22 @@ static int create_session(int lu_fd, const char *name) return args.fd; } =20 +/* Helper function to get a session name via ioctl. */ +static int get_session_name(int session_fd, char *name, size_t name_len) +{ + struct liveupdate_session_get_name args =3D {}; + + args.size =3D sizeof(args); + + if (ioctl(session_fd, LIVEUPDATE_SESSION_GET_NAME, &args)) + return -errno; + + strncpy(name, (char *)args.name, name_len - 1); + name[name_len - 1] =3D '\0'; + + return 0; +} + /* * Test Case: Create Duplicate Session * @@ -427,4 +443,59 @@ TEST_F(liveupdate_device, session_fstat) ASSERT_EQ(close(session_fd2), 0); } =20 +/* + * Test Case: Get Session Name + * + * Verifies that the full session name can be retrieved from a session file + * descriptor via ioctl. + */ +TEST_F(liveupdate_device, get_session_name) +{ + char name_buf[LIVEUPDATE_SESSION_NAME_LENGTH] =3D {}; + const char *session_name =3D "get-name-test-session"; + int session_fd; + + self->fd1 =3D open(LIVEUPDATE_DEV, O_RDWR); + if (self->fd1 < 0 && errno =3D=3D ENOENT) + SKIP(return, "%s does not exist", LIVEUPDATE_DEV); + ASSERT_GE(self->fd1, 0); + + session_fd =3D create_session(self->fd1, session_name); + ASSERT_GE(session_fd, 0); + + ASSERT_EQ(get_session_name(session_fd, name_buf, sizeof(name_buf)), 0); + ASSERT_STREQ(name_buf, session_name); + + ASSERT_EQ(close(session_fd), 0); +} + +/* + * Test Case: Get Session Name at Maximum Length + * + * Verifies that a session name using the full LIVEUPDATE_SESSION_NAME_LEN= GTH + * (minus the null terminator) can be correctly retrieved. + */ +TEST_F(liveupdate_device, get_session_name_max_length) +{ + char name_buf[LIVEUPDATE_SESSION_NAME_LENGTH] =3D {}; + char long_name[LIVEUPDATE_SESSION_NAME_LENGTH]; + int session_fd; + + memset(long_name, 'A', sizeof(long_name) - 1); + long_name[sizeof(long_name) - 1] =3D '\0'; + + self->fd1 =3D open(LIVEUPDATE_DEV, O_RDWR); + if (self->fd1 < 0 && errno =3D=3D ENOENT) + SKIP(return, "%s does not exist", LIVEUPDATE_DEV); + ASSERT_GE(self->fd1, 0); + + session_fd =3D create_session(self->fd1, long_name); + ASSERT_GE(session_fd, 0); + + ASSERT_EQ(get_session_name(session_fd, name_buf, sizeof(name_buf)), 0); + ASSERT_STREQ(name_buf, long_name); + + ASSERT_EQ(close(session_fd), 0); +} + TEST_HARNESS_MAIN --=20 2.47.3