From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E293C43461 for ; Thu, 3 Sep 2020 14:54:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 19A6F2072A for ; Thu, 3 Sep 2020 14:54:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="MfmZFBjT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19A6F2072A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4E9C96B0002; Thu, 3 Sep 2020 10:54:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4998A6B0037; Thu, 3 Sep 2020 10:54:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B07D6B005A; Thu, 3 Sep 2020 10:54:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0214.hostedemail.com [216.40.44.214]) by kanga.kvack.org (Postfix) with ESMTP id 25BED6B0002 for ; Thu, 3 Sep 2020 10:54:29 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 393693620 for ; Thu, 3 Sep 2020 14:54:28 +0000 (UTC) X-FDA: 77222046216.06.wax62_2f0bd95270aa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 54FA7104FE23F for ; Thu, 3 Sep 2020 14:54:20 +0000 (UTC) X-HE-Tag: wax62_2f0bd95270aa X-Filterd-Recvd-Size: 4985 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Sep 2020 14:54:19 +0000 (UTC) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 454F520786 for ; Thu, 3 Sep 2020 14:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599144858; bh=mriIatmtdubimfxx6F+KYhhAQsXMp4Zfj9n/rnqEnYg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MfmZFBjT64s2kj82dccACMNfccL3q/EDxxTceknRnn5UC3AImrGOzEffZCZJBQLHb xsY0ha/O5YBHgCotpGQ0WDdqXQ8tT675l0QXQ1Xgz+E+lw7gbhM7WmZIOITJodOcZN IMv6xVYpajk0/OrPonK7qnFLO3OuTIBZUFe3Lv/M= Received: by mail-wm1-f43.google.com with SMTP id b79so3188046wmb.4 for ; Thu, 03 Sep 2020 07:54:18 -0700 (PDT) X-Gm-Message-State: AOAM530dnGsbs+jD9IRQGYHYoHhBUJAtbtxDGhsy99QHELnCSqbQOhfe 58spPO62D3d4N7XHlWVnSw/jzM0j//Q8aAiIDOoTwg== X-Google-Smtp-Source: ABdhPJwZWPiuPxsfeWv1J/1dfx0Phx0Z+CR6jZc6Vth7ClO5Nnnsw9BnQ2BG0ronnM+rSbGLQcOzQkjyBYwFKrdO6uM= X-Received: by 2002:a1c:740c:: with SMTP id p12mr2909254wmc.176.1599144856798; Thu, 03 Sep 2020 07:54:16 -0700 (PDT) MIME-Version: 1.0 References: <46e42e5e-0bca-5f3f-efc9-5ab15827cc0b@intel.com> <40BC093A-F430-4DCC-8DC0-2BA90A6FC3FA@amacapital.net> In-Reply-To: From: Andy Lutomirski Date: Thu, 3 Sep 2020 07:54:05 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v11 6/9] x86/cet: Add PTRACE interface for CET To: Dave Hansen Cc: "Yu, Yu-cheng" , Jann Horn , "the arch/x86 maintainers" , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , kernel list , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 54FA7104FE23F X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 3, 2020 at 7:27 AM Dave Hansen wrote: > > On 9/2/20 9:35 PM, Andy Lutomirski wrote: > >>>>>> + fpu__prepare_read(fpu); > >>>>>> + cetregs =3D get_xsave_addr(&fpu->state.xsave, XFEATURE_CET= _USER); > >>>>>> + if (!cetregs) > >>>>>> + return -EFAULT; > >>>>> Can this branch ever be hit without a kernel bug? If yes, I think > >>>>> -EFAULT is probably a weird error code to choose here. If no, this > >>>>> should probably use WARN_ON(). Same thing in cetregs_set(). > >>>> When a thread is not CET-enabled, its CET state does not exist. I l= ooked at EFAULT, and it means "Bad address". Maybe this can be ENODEV, whi= ch means "No such device"? > > Having read the code, I=E2=80=99m unconvinced. It looks like a get_xsav= e_addr() failure means =E2=80=9Cstate not saved; task sees INIT state=E2=80= =9D. So *maybe* it=E2=80=99s reasonable -ENODEV this, but I=E2=80=99m not = really convinced. I tend to think we should return the actual INIT state an= d that we should permit writes and handle them correctly. > > PTRACE is asking for access to the values in the *registers*, not for > the value in the kernel XSAVE buffer. We just happen to only have the > kernel XSAVE buffer around. > > If we want to really support PTRACE we have to allow the registers to be > get/set, regardless of what state they are in, INIT state or not. So, > yeah I agree with Andy. I think the core dump code gets here, too, so the values might be in registers as well. I hope that fpu__prepare_read() does the right thing in this case. --Andy