Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp685931ybv; Thu, 13 Feb 2020 07:45:30 -0800 (PST) X-Google-Smtp-Source: APXvYqwEqdHvI5sDdDbeudWoxnIFjnDnr0gCQkl5dZ7EX11B0qTjhF3c/xw9VZ6M370yfSsa5njk X-Received: by 2002:aca:f305:: with SMTP id r5mr3448034oih.174.1581608730317; Thu, 13 Feb 2020 07:45:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608730; cv=none; d=google.com; s=arc-20160816; b=XIhhwwzlczD0VdiawVjLKlITpvJkZQS+NIRPtkR2xzTGxPvQzkZsOYcX71d5uYKe6e AzmnmYkEObyS5aV7FVVbMBPhbtZ48Do3U1mflyFXbGcGpOazefZVFu5WIXF0K3U4x7Mo 4NkhG0OyFJh+AFrJFm3XapC7V9RPoe2EDTWEQ+bjw/OlAdMKRQCU+FSCpjQ8dd010Xpu bg1B4NrxIIzNNxubkyhrrk0VS0o1O8EySx0BNu0+86lWWPMkk9PoIro5PKJf175ELZIG O/cOlyMZR9mC5nRs2dMvRSaKtHlJaIgZK2JGdH626ib2QSSk8ysds/jK6racB2ObKnWy 5dSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LYNW/LUDWbrJlUkIpIAn5XLHtnrflUAeR/SYYoQiPgg=; b=Xd0pRs8qFpevhBV92SoTKZf+4bGrXTZUTonYi+a0kX//uqdF4BJWQMsZtJUxvW+u+K 5LH/punWehqw/zf5UTtGE6FUA/RhKEui0DAovHl7J0+S8sOSl1qlSr7uB26eQdf/WEhy 8J9Mp1RDvCDYcNDDxt7N1Fx2g07oMfcuO4wyaUZR5LYlBisaODKU+5Gm68p52SnZQdGk LoaQ907/G74PCd6taqLf1kNOPzihMsusjz8oBi34kPtyJoy7V+IADgzuCWPe1Sxvk/oX u92wjyXbqJnW/4bupHW5+W1PRbTHFqvd33LeDciIazWhOFqr3L3N8P8XicUr5y57SU5+ v/yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2B1LiMA0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p191si1266988oic.257.2020.02.13.07.45.17; Thu, 13 Feb 2020 07:45:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2B1LiMA0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729877AbgBMPpJ (ORCPT + 99 others); Thu, 13 Feb 2020 10:45:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:51292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728970AbgBMP1e (ORCPT ); Thu, 13 Feb 2020 10:27:34 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BEA6424670; Thu, 13 Feb 2020 15:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607653; bh=/6nvKJXpUQXg8GvlxjuliI9HJ8lsGRxn/EMimUQ8VTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2B1LiMA0Cf7PN9qPTZVfXhQJG1auE7GYiLX68PAw87bWY0FtCsv8bJs2Q07GE10dC 3wqxRBA05b4hNZaYI4mOwvdcQ8h0zJ1kRJzbwK+rN+Il5I9Pev8w0MsrVgmt3FK4b5 9efaE3v1zevF6p7yRDvE6W+IyC/h6VGt/BJZc7wI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Mark Rutland , Ard Biesheuvel , Catalin Marinas , Suzuki K Poulose Subject: [PATCH 5.4 67/96] arm64: ptrace: nofpsimd: Fail FP/SIMD regset operations Date: Thu, 13 Feb 2020 07:21:14 -0800 Message-Id: <20200213151904.616191583@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose commit c9d66999f064947e6b577ceacc1eb2fbca6a8d3c upstream. When fp/simd is not supported on the system, fail the operations of FP/SIMD regsets. Fixes: 82e0191a1aa11abf ("arm64: Support systems without FP/ASIMD") Cc: Will Deacon Cc: Mark Rutland Reviewed-by: Ard Biesheuvel Reviewed-by: Catalin Marinas Signed-off-by: Suzuki K Poulose Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/ptrace.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -615,6 +615,13 @@ static int gpr_set(struct task_struct *t return 0; } +static int fpr_active(struct task_struct *target, const struct user_regset *regset) +{ + if (!system_supports_fpsimd()) + return -ENODEV; + return regset->n; +} + /* * TODO: update fp accessors for lazy context switching (sync/flush hwstate) */ @@ -637,6 +644,9 @@ static int fpr_get(struct task_struct *t unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf) { + if (!system_supports_fpsimd()) + return -EINVAL; + if (target == current) fpsimd_preserve_current_state(); @@ -676,6 +686,9 @@ static int fpr_set(struct task_struct *t { int ret; + if (!system_supports_fpsimd()) + return -EINVAL; + ret = __fpr_set(target, regset, pos, count, kbuf, ubuf, 0); if (ret) return ret; @@ -1134,6 +1147,7 @@ static const struct user_regset aarch64_ */ .size = sizeof(u32), .align = sizeof(u32), + .active = fpr_active, .get = fpr_get, .set = fpr_set }, @@ -1348,6 +1362,9 @@ static int compat_vfp_get(struct task_st compat_ulong_t fpscr; int ret, vregs_end_pos; + if (!system_supports_fpsimd()) + return -EINVAL; + uregs = &target->thread.uw.fpsimd_state; if (target == current) @@ -1381,6 +1398,9 @@ static int compat_vfp_set(struct task_st compat_ulong_t fpscr; int ret, vregs_end_pos; + if (!system_supports_fpsimd()) + return -EINVAL; + uregs = &target->thread.uw.fpsimd_state; vregs_end_pos = VFP_STATE_SIZE - sizeof(compat_ulong_t); @@ -1438,6 +1458,7 @@ static const struct user_regset aarch32_ .n = VFP_STATE_SIZE / sizeof(compat_ulong_t), .size = sizeof(compat_ulong_t), .align = sizeof(compat_ulong_t), + .active = fpr_active, .get = compat_vfp_get, .set = compat_vfp_set },