Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp565984imw; Thu, 14 Jul 2022 06:49:50 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vdwu/K9vc/JVEge4qrtGtq21iSQEA0+gEmPfdlvpfQFVUZU0hp8hPQJeJG47dyVVJxuWI+ X-Received: by 2002:a63:4d66:0:b0:419:8648:194c with SMTP id n38-20020a634d66000000b004198648194cmr7923612pgl.32.1657806590399; Thu, 14 Jul 2022 06:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657806590; cv=none; d=google.com; s=arc-20160816; b=lL0z2fBl81GPgThcrv4Q82I8frkmiSdddLyW3edNcbxPKnwKYS7bwWNNiKok8U7Pwr ZqdhY9KROkRLXenaRf97wQ4Wt996XjDdAjqacVRYMk3QRwKZkxLhStDXOjoUwXbLUjkr eRLgKqZIhLtN33Ai4d/QBDVuqBRo+N4AD+r22zi+OcQthO3DPSuk6AK6S+JXXQrUDCJN pjFmVYWSY0xFwFR1DO0UBmeuxikdB0o0JZ4wSjDk9gOQuQpY4pt/Xd1Y3bmh40dMHmOt hbPdw0WDVYoJGt9wIiM9t1lwZ7e5N6lgeptRZzmvdoqFZSPv8c0gVw+sikGuaj9H/NoV 2zAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GwfgwT58WtrLD6tEdvWjwH5XkUpMSdfeXX8cWUlB1o8=; b=pncSHT0ULFj1DTj9Ihmf65Q2QsCrChcm5JcnIZbv7BmMnibkmJVvv+G9BnNL7vBpv7 z+kVjbvJv1mhvciGzqZgFhB4ndNLaq6Sp41/NJ3cVrwYtypr0ofyGnSyR2GvTSerVHqp 6WgOkPiX5AiXJWUeXAEaFo6rIeK2hkUFMWGcHFZvlo0yqUox+CA6dl6xGInpAXLhkHaI QfRRkxb3hxlYkPbOlrc+sXy9Vy9PS2nJHD+QhkGq/w+mOaRT+iPjz25YCj2ptll/U83x 435GAmZyqukJ4KBVw/1cQT6kdCg+NznAw18Yig3qYfNP/V0LB5vBkX5WnO6ATgLqzlhS i7sQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K4QkIeEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q6-20020aa79606000000b0052551b26480si2046974pfg.99.2022.07.14.06.49.38; Thu, 14 Jul 2022 06:49:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K4QkIeEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239225AbiGNNMg (ORCPT + 99 others); Thu, 14 Jul 2022 09:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbiGNNMf (ORCPT ); Thu, 14 Jul 2022 09:12:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA6D43E60 for ; Thu, 14 Jul 2022 06:12:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 890BD62047 for ; Thu, 14 Jul 2022 13:12:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DFF7BC34115 for ; Thu, 14 Jul 2022 13:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657804353; bh=nEK6K0+xvlBOpmwF55h7AMv2fTvVGg4WhQpZfCPwTck=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=K4QkIeEnSjNOVvIakhJPaz+BMQichtSdqlqgo/9PLPrADjb9O9Q7eTVA5sAArg7G7 Wz2U29ZAffJAfCXtoyOV+ugQq7WiQTilWhdtejxGRfB79Ei8UPkylXA7hifTOYzqpj 9eX59A1bmQ3oOtuS7yZxkIBZwJGXLb+YCFMrXg3CYQJ1PRRSeHFzf+o083G/g+ZpBO 9bueQO2PlVC/gxQyaExACobVz9Y4bQZD+UWOczvu6Jwr3S1gjUffzVLPx7VLI0t5H/ hNOIwmDnOoxuaMcs3fXNaRIurBTkTWzTK5+hYAONAWeGobvMhsha+U2cAlgrdgnXBr FcjGfj2Ij2hbA== Received: by mail-vk1-f169.google.com with SMTP id y129so780486vkg.5 for ; Thu, 14 Jul 2022 06:12:33 -0700 (PDT) X-Gm-Message-State: AJIora953oNUQIlXXnw8fdyPmH7mD81x8JDXXYDQdve5cRFkHcie0QPy ZTUnchA+YIq2ZA+QJ2ROSSuTanmcjZs4QbWGPFw= X-Received: by 2002:a05:6122:329:b0:374:f09c:876f with SMTP id d9-20020a056122032900b00374f09c876fmr3625484vko.12.1657804352795; Thu, 14 Jul 2022 06:12:32 -0700 (PDT) MIME-Version: 1.0 References: <20220714062550.4934-1-huqi@loongson.cn> In-Reply-To: <20220714062550.4934-1-huqi@loongson.cn> From: Huacai Chen Date: Thu, 14 Jul 2022 21:12:20 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] LoongArch: Fix missing fcsr in ptrace's fpr_set To: Qi Hu Cc: WANG Xuerui , Oleg Nesterov , Xu Li , loongarch@lists.linux.dev, LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, Jul 14, 2022 at 2:26 PM Qi Hu wrote: > > In file ptrace.c, function fpr_set does not copy fcsr data from ubuf > to kbuf. That's the reason why fcsr cannot be modified by ptrace. > > This patch fixs this problem and allows users using ptrace to modify > the fcsr. > > Signed-off-by: Qi Hu > Signed-off-by: Xu Li > --- > arch/loongarch/kernel/ptrace.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/arch/loongarch/kernel/ptrace.c b/arch/loongarch/kernel/ptrace.c > index e6ab87948e1d..dc2b82ea894c 100644 > --- a/arch/loongarch/kernel/ptrace.c > +++ b/arch/loongarch/kernel/ptrace.c > @@ -193,7 +193,7 @@ static int fpr_set(struct task_struct *target, > const void *kbuf, const void __user *ubuf) > { > const int fcc_start = NUM_FPU_REGS * sizeof(elf_fpreg_t); > - const int fcc_end = fcc_start + sizeof(u64); > + const int fcsr_start = fcc_start + sizeof(u64); > int err; > > BUG_ON(count % sizeof(elf_fpreg_t)); > @@ -209,10 +209,12 @@ static int fpr_set(struct task_struct *target, > if (err) > return err; > > - if (count > 0) > - err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf, > - &target->thread.fpu.fcc, > - fcc_start, fcc_end); > + err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf, > + &target->thread.fpu.fcc, fcc_start, > + fcc_start + sizeof(u64)); > + err |= user_regset_copyin(&pos, &count, &kbuf, &ubuf, > + &target->thread.fpu.fcsr, fcsr_start, > + fcsr_start + sizeof(u32)); You shouldn't remove (count > 0) here, because the above user_regset_copyin() will modify count inside, and so "count == 0" is possible. Huacai > > return err; > } > -- > 2.37.0 >