Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2973761pxy; Tue, 3 Aug 2021 22:01:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPCHA8aBAzavzB8+Ga29CDKkNjg/nWQgh7uhBLvhlUjSAjj+7zluTUiST5bihNaUPjkjUo X-Received: by 2002:a92:cacd:: with SMTP id m13mr1176285ilq.256.1628053311304; Tue, 03 Aug 2021 22:01:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628053311; cv=none; d=google.com; s=arc-20160816; b=BIUZ9PiIHX3ajg54tO+MUVQf91L5yuJoedQuCxYG7fFnR1JWzBvoTMKJu5MZOQRQpY dTtuUtcT8g5WTdlIz4fXcp7MjL8ntkup6LfnHHCu4HkFh8McgIC6BDF3RMmEknDfcfqf 8Pg3OubHRl6b+//gXdYVtQ0ibIn2xalmTZAVKiKPg25CSp9GedQpb8q7Sm2iCUTQDoQx V8f7oZsxXjvMXmUo9Bvjybs74zlq0MMaPV4tGTnplc2c6RT8woJ9fToDtcIOzFnznCKb H3yCEfosVtqpBR1j+5KgDTjarBgWkEqBePRroXrFBGD2FJZTVqf3oQqd6ozEWIRDI39w L0Fg== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=vKtpxFfXXonzxQpVSnSTmoh4P23uDt+JR975j7vzGY4=; b=OaNbxfl8XwSu0vmwmEBy51Y5Tn3aKYCi2a7H6n8AYwx03ejg2DOGPRm/KYW749ORo/ +FkFTUm7XwIL0M0GJHB9qj5o2uu26J1TwEBYiSw0OYEJBT1Zf3HdVghHO26cXfXXaAJp 1GwYCpz0lHT2M0GGwCsG9TcRW+9+H1HHssE/MSBRlvbKUlzHHci/nXkQUI60stbkxCCO dWCkA9r7sQZaosXbCk9Xjvrq7K3Qq4tV/aF4QEqTX5u19IWXuVQer6feHqDEupDe5Pmy vKa9azuV6irAytM7aCmWoS+hlZSIi1Df/IzsrFqzGp5W8qSzvaTROO434lEI8ijGQqmr DkSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=or4MtC5P; 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 c16si1187572ilr.12.2021.08.03.22.01.14; Tue, 03 Aug 2021 22:01:51 -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=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=or4MtC5P; 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 S232010AbhHDERx (ORCPT + 99 others); Wed, 4 Aug 2021 00:17:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbhHDERw (ORCPT ); Wed, 4 Aug 2021 00:17:52 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D75D8C0613D5 for ; Tue, 3 Aug 2021 21:17:40 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id e2-20020a17090a4a02b029016f3020d867so1782602pjh.3 for ; Tue, 03 Aug 2021 21:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=vKtpxFfXXonzxQpVSnSTmoh4P23uDt+JR975j7vzGY4=; b=or4MtC5Pa4CHAc3sHN8vhHOBNZECV0NeNG52atUIvJ97vUKZ7iKFlI7i7xyi2oWoCl OLZ9Z1MyXwztCijqG5Jjc4zOlgeEeMtkXCqA9JED/mzH0JY3F1oR3EYJCmxag21gKGek 24xvgcmy2Ke9tggxbTUUqWLns8bFbF1za4wLPM/FwEVUSa2g6U+Thg/IU3R5kdAPou+n 0CGaRnD5rejAOKudXbqqgJBtsCgWJh/QLXTR3yg9XELegw3OADOY/BRn40MXwJVugREE 7Gv5yx3UkMy4+0NU9dEpuDDUgoJXg81Igw7QbMICjaMxN6VMLWCGS0VsYK2lTjNZDuaR o05Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=vKtpxFfXXonzxQpVSnSTmoh4P23uDt+JR975j7vzGY4=; b=f2us1UO+r5kTGavdHXTHGAGVoEuy48MK2cYSb5ym9emY8pHReilRUxZ2F6p7uWo9qS 8bC38e4Douq4gCsy+RmavWYNDiz0p2zaNcHiNDGeMB6pcxjecl8fBhXSOvuoges7Q2zM q9TwX/meiNwucSxQ8Bn8/rObwe+VVVL3+b+HehvCmDeR7vRcPfSY/uHIq2prHQoLOR1f w04SkfUhGPY1IVcn4OZnc+v/JK4vEudL5nLl0ao9ZexaXJEDLI8bktX25F3OQfqzhyn7 RKCYrmBm5WYe8WWlNbepZmpuOt/AmdFhlDBTzsfj0hzZeIPx+03edo/OK7ft/QnfpYLL B+jg== X-Gm-Message-State: AOAM531R+W7ZHyPgGVoVj5rP3zVh35H/8g7+eW+ymGqYD0U1BpEd/zkv S0s7iAwT7kZo8IL5MH+GP5Pigg== X-Received: by 2002:a05:6a00:188e:b029:3c3:1142:15f2 with SMTP id x14-20020a056a00188eb02903c3114215f2mr8894882pfh.36.1628050660207; Tue, 03 Aug 2021 21:17:40 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id k25sm751605pfa.213.2021.08.03.21.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 21:17:39 -0700 (PDT) Date: Tue, 03 Aug 2021 21:17:39 -0700 (PDT) X-Google-Original-Date: Tue, 03 Aug 2021 21:13:20 PDT (-0700) Subject: Re: [PATCH -next] riscv: Implement thread_struct whitelist for hardened usercopy In-Reply-To: <20210702045422.3527469-1-tongtiangen@huawei.com> CC: Paul Walmsley , aou@eecs.berkeley.edu, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, tongtiangen@huawei.com From: Palmer Dabbelt To: tongtiangen@huawei.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 01 Jul 2021 21:54:21 PDT (-0700), tongtiangen@huawei.com wrote: > This whitelists the FPU register state portion of the thread_struct for > copying to userspace, instead of the default entire struct. > > Signed-off-by: Tong Tiangen > --- > arch/riscv/Kconfig | 1 + > arch/riscv/include/asm/processor.h | 8 ++++++++ > 2 files changed, 9 insertions(+) > > diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig > index 821081bdb8b8..5c26c0726944 100644 > --- a/arch/riscv/Kconfig > +++ b/arch/riscv/Kconfig > @@ -70,6 +70,7 @@ config RISCV > select HAVE_ARCH_MMAP_RND_BITS if MMU > select HAVE_ARCH_SECCOMP_FILTER > select HAVE_ARCH_TRACEHOOK > + select HAVE_ARCH_THREAD_STRUCT_WHITELIST > select HAVE_ASM_MODVERSIONS > select HAVE_CONTEXT_TRACKING > select HAVE_DEBUG_KMEMLEAK > diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h > index 021ed64ee608..46b492c78cbb 100644 > --- a/arch/riscv/include/asm/processor.h > +++ b/arch/riscv/include/asm/processor.h > @@ -37,6 +37,14 @@ struct thread_struct { > unsigned long bad_cause; > }; > > +/* Whitelist the fstate from the task_struct for hardened usercopy */ > +static inline void arch_thread_struct_whitelist(unsigned long *offset, > + unsigned long *size) > +{ > + *offset = offsetof(struct thread_struct, fstate); > + *size = sizeof_field(struct thread_struct, fstate); > +} > + > #define INIT_THREAD { \ > .sp = sizeof(init_stack) + (long)&init_stack, \ > } Thanks, this is on for-next.