Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp358802pxb; Fri, 3 Sep 2021 03:54:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOK3YuH5S/Ysyw/5J/Z0cStOJdwfIbXURb2I+WPw9lW+JBZjoiCtZDWd9+iGlwKVFoNWqp X-Received: by 2002:a05:6402:40cf:: with SMTP id z15mr3314105edb.70.1630666448807; Fri, 03 Sep 2021 03:54:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630666448; cv=none; d=google.com; s=arc-20160816; b=e1GrxqRt3vBCoTGyV0XPXlElPJKR/lEEi6QjAwuErnkesK4LDi6s/GL2srVHkRy8sw /44xqnq/XINmq2NtBIlzIeYV4OfjCjrKxR8un+qnwSWETGyPQlo6k9ABGD2Fy+SgYfnK O1ON5o/5r7n/1yvEfkJGdDf9qDnQrchyR2UGIc/9DH0vtcuRAP1JMssCecTI+hKmPUdX 50fhA06JvIMNGkksD/R/r60gfYgc0QfNlulh4FfIk6Z2dQ5oiozeuogyMan1Ty1nNycM v5UM9dS3bgKjWzOwtwgcTrBXaHje3apjYD3Hb1M3x7mAZU3QgnL/SXqX4GBsnS3xGwE5 hkOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=lbV0NDhew56g4UstfAcUlFvfBwK5IWCquZ80NfOV7bs=; b=gTkmI0pU5qB5p6wZZNBU1DToSiVJhtphwA+LvZDJHANfIF1XFk2+0jkqVRFllHIt4H 5xqq+Xr6Gwl+3g413NYZuJxN+4PVKOQHw83M04QWKEnErYku5+/wvb+yV7lWMRs2bQrR NTWireX4F1xhkWkGqrQ9/Uh3x/GidTLo6yUsZFbr569NVjjQjvJCjEv7mK5QWuHUaQOh Tt/JUGIkRAbXsCA01JR5uKXBDqo2QVnGRVbmLx4pu+g2X/EywBJsrQ+Yd6nVEh1JqZba wW74hDLRCDT7PhavnvppbEkHrWtb7o405TkXEHm24sezCsxWfb8ZMbVeSQVGhdhfvIlE odEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fj2si4381335ejc.474.2021.09.03.03.53.44; Fri, 03 Sep 2021 03:54:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348469AbhICIzF (ORCPT + 99 others); Fri, 3 Sep 2021 04:55:05 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:50843 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234865AbhICIzE (ORCPT ); Fri, 3 Sep 2021 04:55:04 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4H1BRb3THfz9sT9; Fri, 3 Sep 2021 10:54:03 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U9JmwoyaGwxb; Fri, 3 Sep 2021 10:54:03 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4H1BRY486Bz9sTF; Fri, 3 Sep 2021 10:54:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6F4348B8D5; Fri, 3 Sep 2021 10:54:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Mih_7c73FeuN; Fri, 3 Sep 2021 10:54:01 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 010A58B764; Fri, 3 Sep 2021 10:54:00 +0200 (CEST) Subject: Re: [PATCH v2 5/5] powerpc/signal: Use unsafe_copy_siginfo_to_user() To: "Eric W. Biederman" Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <7d391d915d2bd1c0f601f55f61f8dd4c70066229.1629732940.git.christophe.leroy@csgroup.eu> <87y28ex1ov.fsf@disp2133> From: Christophe Leroy Message-ID: <08117c1e-7805-534f-42ca-54a885f272cd@csgroup.eu> Date: Fri, 3 Sep 2021 10:53:49 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <87y28ex1ov.fsf@disp2133> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 02/09/2021 à 20:38, Eric W. Biederman a écrit : > Christophe Leroy writes: > >> Use unsafe_copy_siginfo_to_user() in order to do the copy >> within the user access block. >> >> On an mpc 8321 (book3s/32) the improvment is about 5% on a process >> sending a signal to itself. > > Nacked-by: "Eric W. Biederman" > > copy_siginfo_to_user is not the same as copy_siginfo_to_user32. > > As in this patch breaks 32bit userspace on powerpc. I don't understand your comment. As you can see below, copy_siginfo_to_user32() is used in the compat case (ie 32 bit userspace on PPC64) and unsafe_copy_siginfo_to_user() is used on the non-compat case (ie 32 bit userspace on PPC32). So what's the issue really ? > > >> Signed-off-by: Christophe Leroy >> --- >> arch/powerpc/kernel/signal_32.c | 13 ++++++------- >> arch/powerpc/kernel/signal_64.c | 5 +---- >> 2 files changed, 7 insertions(+), 11 deletions(-) >> >> diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c >> index ff101e2b3bab..f9e16d108bc8 100644 >> --- a/arch/powerpc/kernel/signal_32.c >> +++ b/arch/powerpc/kernel/signal_32.c >> @@ -710,12 +710,6 @@ static long restore_tm_user_regs(struct pt_regs *regs, struct mcontext __user *s >> } >> #endif >> >> -#ifdef CONFIG_PPC64 >> - >> -#define copy_siginfo_to_user copy_siginfo_to_user32 >> - >> -#endif /* CONFIG_PPC64 */ >> - >> /* >> * Set up a signal frame for a "real-time" signal handler >> * (one which gets siginfo). >> @@ -779,14 +773,19 @@ int handle_rt_signal32(struct ksignal *ksig, sigset_t *oldset, >> asm("dcbst %y0; sync; icbi %y0; sync" :: "Z" (mctx->mc_pad[0])); >> } >> unsafe_put_sigset_t(&frame->uc.uc_sigmask, oldset, failed); >> +#ifndef CONFIG_COMPAT >> + unsafe_copy_siginfo_to_user(&frame->info, &ksig->info, failed); >> +#endif >> >> /* create a stack frame for the caller of the handler */ >> unsafe_put_user(regs->gpr[1], newsp, failed); >> >> user_access_end(); >> >> - if (copy_siginfo_to_user(&frame->info, &ksig->info)) >> +#ifdef CONFIG_COMPAT >> + if (copy_siginfo_to_user32(&frame->info, &ksig->info)) >> goto badframe; >> +#endif >> >> regs->link = tramp; >> >> diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c >> index 2cca6c8febe1..82b73fbd937d 100644 >> --- a/arch/powerpc/kernel/signal_64.c >> +++ b/arch/powerpc/kernel/signal_64.c >> @@ -901,15 +901,12 @@ int handle_rt_signal64(struct ksignal *ksig, sigset_t *set, >> } >> >> unsafe_copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set), badframe_block); >> + unsafe_copy_siginfo_to_user(&frame->info, &ksig->info, badframe_block); >> /* Allocate a dummy caller frame for the signal handler. */ >> unsafe_put_user(regs->gpr[1], newsp, badframe_block); >> >> user_write_access_end(); >> >> - /* Save the siginfo outside of the unsafe block. */ >> - if (copy_siginfo_to_user(&frame->info, &ksig->info)) >> - goto badframe; >> - >> /* Make sure signal handler doesn't get spurious FP exceptions */ >> tsk->thread.fp_state.fpscr = 0;