From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70857409634; Tue, 19 May 2026 14:29:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779200991; cv=none; b=n5aqXCNTwXl2K3V6RNcTngpF0W0CK7cu9pvlA2DK1PYNEO4+4kGqLwp5rkBdgeV2vpYLWW/nMXwXQBkM4JYhEbtck478vfTOTAoKSd95RPJros94FHH0cUpPSXMe5aLMyaUAcVNFy3OkNTwhqEs5rrFn53mhLiRoFbSAB1LjC6k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779200991; c=relaxed/simple; bh=wpYoLkXbZ09JzWdvWlJaLOcA/ezxAkZJMM14JmrXOeA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=tBT4ZmDJr3AAAPR+1BT3Lq3v18Or6OXQDxFJfLG1BUhbB4pkYvLkljY352mn/fOHylhQHfD8H/CUh4TMpW/ifhnwyqOPyt/9iDIB5opYoSl+C0l/NS4TI8gUc/UbjqtUlPNlXyJJak+FrkWzeWTTepzrOYSMGrAPHQecDOZmf0w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ieTKkMkI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ieTKkMkI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BAE54C2BCB3; Tue, 19 May 2026 14:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1779200991; bh=wpYoLkXbZ09JzWdvWlJaLOcA/ezxAkZJMM14JmrXOeA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ieTKkMkIGrPorjzAIC4Qowt46zqplcOBeUNq1ZB3HqLlNbHueXrmtCW/ZkgG0EbTh da9NpHNjB4JmLOePSe7mAZffwVia+K5LpQ+R9okatjch7uJynWL+BHhiJL8asUZN03 UGRfIveprZCY6DLtutBFKcGgDFP0DFn6m0pAmBfjqZm7qym1JF8c8XmeQQVBisXfNp AVAVw7TFaLjdxxHF6O+rCUv+i9z2qy5tL7Y46XXddbgMP1fdmT3eHkN+B2qWsv5n7J Wya8na+pgNRBx4iVhGW9AiQXq2KTI6SaZjljOl4nYEIpVQCFrGj4NJPIj6vwDU/6eI FMom3pl8gSKrw== From: Pratyush Yadav To: Pasha Tatashin Cc: Pratyush Yadav , Mike Rapoport , Andrew Morton , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, stable@vger.kernel.org Subject: Re: [PATCH] liveupdate: validate session type before performing operation In-Reply-To: (Pasha Tatashin's message of "Tue, 19 May 2026 14:11:26 +0000") References: <20260519122428.2378446-1-pratyush@kernel.org> Date: Tue, 19 May 2026 16:29:48 +0200 Message-ID: <2vxzfr3n8obn.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, May 19 2026, Pasha Tatashin wrote: > On 05-19 14:24, Pratyush Yadav wrote: >> From: "Pratyush Yadav (Google)" >> >> The sessions ioctls are not applicable to all session types. PRESERVE_FD >> is only applicable to outgoing sessions. RETRIEVE_FD and FINISH are only >> valid for incoming session. Calling a incoming ioctl on an outgoing >> session is invalid and can cause file handlers to run into unexpected >> errors. >> >> For example, a user can create a (outgoing) session, preserve a memfd, >> and then immediately do a retrieve without doing a kexec in between. > > Please add a self-test tools/testing/selftests/liveupdate/liveupdate.c > to verify that outgoing sessions do not accept retrieve_fd ioctl. > Option, you could also add to luo_multi_session.c a test to verifying > that incoming does not accept preserve_fd Right, forgot about that. Will do. > >> This would result in memfd's retrieve handler to run. The handlers >> expects to be called from a post-kexec context, and will try to do a >> kho_restore_vmalloc() or kho_restore_folio() to try and restore memory. >> >> KHO catches this (thanks to KHO_PAGE_MAGIC) and returns an error, but >> since this is considered an internal error and KHO throws out a bunch of >> WARN()s. >> >> Associate a type with each ioctl op and validate the type in >> luo_session_ioctl() before dispatching the ioctl handler to make sure >> the op is being called for the right session type. >> >> Fixes: 16cec0d26521 ("liveupdate: luo_session: add ioctls for file preservation") >> Cc: stable@vger.kernel.org >> Signed-off-by: Pratyush Yadav (Google) -- Regards, Pratyush Yadav