Return-Path: Date: Fri, 2 Jul 2021 10:51:13 +0200 From: Peter Zijlstra Subject: Re: [PATCH 2/4] arch/x86: implement the process_vm_exec syscall Message-ID: References: <20210414055217.543246-1-avagin@gmail.com> <20210414055217.543246-3-avagin@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210414055217.543246-3-avagin@gmail.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+geert=linux-m68k.org@lists.infradead.org To: Andrei Vagin Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-um@lists.infradead.org, criu@openvz.org, avagin@google.com, Andrew Morton , Andy Lutomirski , Anton Ivanov , Christian Brauner , Dmitry Safonov <0x7f454c46@gmail.com>, Ingo Molnar , Jeff Dike , Mike Rapoport , Michael Kerrisk , Oleg Nesterov , Richard Weinberger , Thomas Gleixner I'm terrified of all of this... On Tue, Apr 13, 2021 at 10:52:15PM -0700, Andrei Vagin wrote: > +long swap_vm_exec_context(struct sigcontext __user *uctx) > +{ > + struct sigcontext ctx = {}; > + sigset_t set = {}; > + > + > + if (copy_from_user(&ctx, uctx, CONTEXT_COPY_SIZE)) > + return -EFAULT; > + /* A floating point state is managed from user-space. */ > + if (ctx.fpstate != 0) > + return -EINVAL; > + if (!user_access_begin(uctx, sizeof(*uctx))) > + return -EFAULT; > + unsafe_put_sigcontext(uctx, NULL, current_pt_regs(), (&set), Efault); > + user_access_end(); But here you save the sigcontext without FPU state. > + > + if (__restore_sigcontext(current_pt_regs(), &ctx, 0)) > + goto badframe; And here you restore sigcontext, *with* FPU state. At which point your FPU state is irrecoverably lost. Also, I'm not at all convinced this can ever do the right thing when the tasks don't agree on what the FPU state is. I suppose in the best case the save will EFAULT. > + > + return 0; > +Efault: > + user_access_end(); > +badframe: > + signal_fault(current_pt_regs(), uctx, "swap_vm_exec_context"); > + return -EFAULT; > +} _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um