Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp49191pxb; Tue, 2 Mar 2021 18:43:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3EyCDqxNWH+hhBgO25iN9neJaCHOMRJHOgz+E2LP+1J5cPJkK6mnPPHt9g5qwy2sG201R X-Received: by 2002:a17:906:2816:: with SMTP id r22mr23367141ejc.2.1614739413354; Tue, 02 Mar 2021 18:43:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614739413; cv=none; d=google.com; s=arc-20160816; b=UUsXfTP3is585dxsCHHGEoHjYo+e062vCBW8qc3Rh4cL4eb/g2CR4TK31ETHZ4c/rF OWPX3w3L94ur9zs/3F5EjeACMb/jTb2wjGCOxyN2AWajLNTZTRVEHRFIwPEcsmftQh52 E7K85yb+ccSHh9wBk2fJpImC1cqJf78QH6Fl/4s9X4903MTRof2Ui0JZDjranx9ojM/B XKZngkTkLopMVMH4sTz097lEfH5wSzeze9SlSgFmM3R2Cp7ZqB+LD26kTSlKlHRGdY1j vINZDU815GaxN8fJ2V1yMHjQd7kC2IEKTDR+IAF+53gO8k3FQZDbTgzPPTwYy18m8PNY nuDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from; bh=UQjeMsK4NPLFcI7tyjtZz2GrWjVvrq9/vybIGZAFOQo=; b=wfjwStQwvq4R12B5dfPeSt2giW8nkHjC1z9rmTWdGLgxbZWrBSC5fduGB9rV49c4uC MGM4mqTPcUgFdvwo4yLfAW912c13minazsSt8F3QucUGO9lWevujNpeYYgiQdWqSU9qx IEKX29ZWGS5aIvIS0vYN3pveqljjQCKaq5AsungaGjZ+OF31mGRANxTdnl8dsSxosAJk 5uAT+2yXkGjqadANtYdDWORY1SO614n4MVhQP+JSJMlU5MQlHVLU8TcRx6dz8VW5sQ3K o3prZOQAjPj0ba1jCrS+5WdFuLFfVwW1zNoGMTjHEVCtsmRtuHHcOj80xvQncIN18oRh qsnQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si15417328edj.93.2021.03.02.18.43.10; Tue, 02 Mar 2021 18:43:33 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbhCAMGs (ORCPT + 99 others); Mon, 1 Mar 2021 07:06:48 -0500 Received: from mail-m121143.qiye.163.com ([115.236.121.143]:32868 "EHLO mail-m121143.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230459AbhCAMGs (ORCPT ); Mon, 1 Mar 2021 07:06:48 -0500 Received: from vivo-HP-ProDesk-680-G4-PCI-MT.vivo.xyz (unknown [58.250.176.228]) by mail-m121143.qiye.163.com (Hmail) with ESMTPA id 2A463540317; Mon, 1 Mar 2021 20:06:02 +0800 (CST) From: Wang Qing To: Vineet Gupta , Jens Axboe , Wang Qing , Thomas Gleixner , "Gustavo A. R. Silva" , linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arc: kernel: Return -EFAULT if copy_to_user() fails Date: Mon, 1 Mar 2021 20:05:48 +0800 Message-Id: <1614600349-15662-1-git-send-email-wangqing@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGEweGR5CT0xJTEIZVkpNSk9NS0tITUlPTEtVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWU FZT0tIVUpKS0hNSlVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PDI6Lww5Pj8QSBAdQyEjEzIr CQ5PCSlVSlVKTUpPTUtLSE1JQ0lJVTMWGhIXVQwaFRwKEhUcOw0SDRRVGBQWRVlXWRILWUFZTkNV SU5LVUpMTVVJSUNZV1kIAVlBSUtOSTcG X-HM-Tid: 0a77edae5993b038kuuu2a463540317 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The copy_to_user() function returns the number of bytes remaining to be copied, but we want to return -EFAULT if the copy doesn't complete. Signed-off-by: Wang Qing --- arch/arc/kernel/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c index a78d8f7..fdbe06c --- a/arch/arc/kernel/signal.c +++ b/arch/arc/kernel/signal.c @@ -96,7 +96,7 @@ stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, sizeof(sf->uc.uc_mcontext.regs.scratch)); err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t)); - return err; + return err ? -EFAULT : 0; } static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) @@ -110,7 +110,7 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) &(sf->uc.uc_mcontext.regs.scratch), sizeof(sf->uc.uc_mcontext.regs.scratch)); if (err) - return err; + return -EFAULT; set_current_blocked(&set); regs->bta = uregs.scratch.bta; -- 2.7.4