From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Schmitz Subject: Re: Kernel stack read with PTRACE_EVENT_EXIT and io_uring threads Date: Mon, 14 Jun 2021 17:03:32 +1200 Message-ID: <924ec53c-2fd9-2e1c-bbb1-3fda49809be4@gmail.com> References: <87sg1p30a1.fsf@disp2133> <87pmwsytb3.fsf@disp2133> <87sg1lwhvm.fsf@disp2133> <6e47eff8-d0a4-8390-1222-e975bfbf3a65@gmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=/Shcl0CcwcVQvnqm4kjruvfteHB5V70Bgq+EW67+hVs=; b=B5SBMSbjT8JJZ0clP7225Gi2clR3Q4OchlvIiY/CVvOS/s3gFjPf0ybYVRqwbIG/dZ Y8fJHjfu8wY1guNyM/wNNFbHK+cMl/eMbnj3TVjh8v7tBKbjRrt5ivQORq0NjueN9QXa x6x0nPCYp+HfTubRj1wmV4idu6a/kvc2wnsRx5LyQ7CLvBsu7qQIu6s5MRo+cSTHs51z FJRDLeLVosLvWgeGb5rV8piHUEoVvgaZ8PYvVHCrSOExft7bgqRESMuQ+KAxHiCu22A+ lSmXN9GdGs/9vgPpg0Md5tu3/RxBd29BWkXJYO1MPH6PcllXlp8hVlnIvMHJQm5foksZ Ue2A== In-Reply-To: <6e47eff8-d0a4-8390-1222-e975bfbf3a65@gmail.com> List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: Linus Torvalds , "Eric W. Biederman" Cc: linux-arch , Jens Axboe , Oleg Nesterov , Al Viro , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo , Kees Cook On second thought, I'm not certain what adding another empty stack frame would achieve here. On m68k, 'frame' already is a new stack frame, for running the new thread in. This new frame does not have any user context at all, and it's explicitly wiped anyway. Unless we save all user context on the stack, then push that context to a new save frame, and somehow point get_signal to look there for IO threads (essentially what Eric suggested), I don't see how this could work? I must be missing something. Cheers, Michael Schmitz Am 14.06.2021 um 14:05 schrieb Michael Schmitz: >> >> I wouldn't be surprised if m68k has the exact same thing for the exact >> same reason, but I didn't check.. > > m68k is indeed similar, it has: > > if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) { > /* kernel thread */ > memset(frame, 0, sizeof(struct fork_frame)); > frame->regs.sr = PS_S; > frame->sw.a3 = usp; /* function */ > frame->sw.d7 = arg; > frame->sw.retpc = (unsigned long)ret_from_kernel_thread; > p->thread.usp = 0; > return 0; > } > > so a similar patch should be possible. > > Cheers, > > Michael > > > >> >> Linus