Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3012789pxb; Mon, 18 Oct 2021 06:35:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc4sgz6fLtSXndU0Z9NZUZr142I9iSENoZMOJJnr2jCPG6hpvBsfOIfJqke1LnQiD6WzFJ X-Received: by 2002:a63:5544:: with SMTP id f4mr23905778pgm.431.1634564152054; Mon, 18 Oct 2021 06:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564152; cv=none; d=google.com; s=arc-20160816; b=EsOOtx8xteQlR81CTmNCC/1UcX5qOWyFDng7qiC9x7fJKPJIO1CeQRLnZgwx+S2Z4d PrzU/OcYH6YWTy38mMmmyxQeBHwJcBhWkobMpig0GnS0A+PNuduX9Hom2Eg2jfezOrAF 8906gdLJVRn+pjc30/5bnNBhRFVUwRDQ1ViB1NyxSuytT/63PwRR06u2YEaISmwid2kW ERl1u0zWhBXsdZ5xf04ECmwltb10VR27ZTW8cTHhydTC6uKoSsbf6hu4DDSFGxjjO9kS QE7NjNQcWF5ouNY5dI/dQ8kzH0zD5zE8KXuQGdkFbz1k37Z2KqLhu6GGx7qVPCP17Dt7 3JiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9yNZQsdoPQWu9a9eooPLE7kBMGhETkjWzmM3R22EYvg=; b=z6jdacf1oVD865bq2jnAeT4DAxlyTy6yXrdZ78qsyy+Du2KRgy9NZ9Iv8h8s8iDYyh 0jkF6QXU6GyiDx3p5yOwHU5v12Mk+y9oRbaqw0Z3zUZ/GkmM0dfSlDFGNW1uoavRdho+ tFXrCJ2lBru4Ob0tWIrkZDLY9lb0LbGQVLhjay1EmFppk1QJXepF9MdBybjUeDsDLjyl 7vAOa++aTLn68hkJkrcQgPaoYXdtuYVCdBO+SfyEYwSFhXtUlCDM8VdqHfiv76I9qiyr RRHD/mnuc5w4n+wur3qavyao8j+/CiKpgdpEPmZa0YsgClKfNifbr3VE1Vuyeb8eI11p gd4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yobzgN81; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 140si400090pfy.240.2021.10.18.06.35.33; Mon, 18 Oct 2021 06:35:52 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yobzgN81; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232969AbhJRNfH (ORCPT + 99 others); Mon, 18 Oct 2021 09:35:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:43774 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233172AbhJRNdX (ORCPT ); Mon, 18 Oct 2021 09:33:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2859861357; Mon, 18 Oct 2021 13:29:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563779; bh=ftJcYa5tYRmlDTN9v6teyzo1AQ+5+Sb5uPNE16kOzk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yobzgN81rb57r9e1qJaL7QMURrNvEMcb/Rr7kqj7RmtMvK1cLhVo8XT8h7HJnfjWH oNZrJQp7U42jZmiymQN3EPMh1sTWbm3wcrYtn0R+uD6ygbEmX5Np4wC7ysDNjXUuXs o2vvIJ1BfALZgcnheCaNLosCueuT5LXkdOEoLHN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guo Ren , Al Viro Subject: [PATCH 5.4 11/69] csky: Fixup regs.sr broken in ptrace Date: Mon, 18 Oct 2021 15:24:09 +0200 Message-Id: <20211018132329.825628897@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guo Ren commit af89ebaa64de726ca0a39bbb0bf0c81a1f43ad50 upstream. gpr_get() return the entire pt_regs (include sr) to userspace, if we don't restore the C bit in gpr_set, it may break the ALU result in that context. So the C flag bit is part of gpr context, that's why riscv totally remove the C bit in the ISA. That makes sr reg clear from userspace to supervisor privilege. Signed-off-by: Guo Ren Cc: Al Viro Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/csky/kernel/ptrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/csky/kernel/ptrace.c +++ b/arch/csky/kernel/ptrace.c @@ -96,7 +96,8 @@ static int gpr_set(struct task_struct *t if (ret) return ret; - regs.sr = task_pt_regs(target)->sr; + /* BIT(0) of regs.sr is Condition Code/Carry bit */ + regs.sr = (regs.sr & BIT(0)) | (task_pt_regs(target)->sr & ~BIT(0)); #ifdef CONFIG_CPU_HAS_HILO regs.dcsr = task_pt_regs(target)->dcsr; #endif