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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 69421C433E6 for ; Tue, 1 Sep 2020 18:19:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3DB85206FA for ; Tue, 1 Sep 2020 18:19:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e3DcllFi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730074AbgIASTx (ORCPT ); Tue, 1 Sep 2020 14:19:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgIASTu (ORCPT ); Tue, 1 Sep 2020 14:19:50 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B721C061244; Tue, 1 Sep 2020 11:19:50 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id u126so2356658iod.12; Tue, 01 Sep 2020 11:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cLstzH1LNj+g6CEwT6Bs49sL4xGFgD5yGkJsHn4QoB0=; b=e3DcllFiRd99EFhMW9PLPljTKxeW0vc47NVr96CC+Vzh6dkUK4Mmdgcl1sZq/kJoLz 3gSmb4o3MV+chM/XWnck2/Zy6U7/keXIVgEz6ul7hTS5rc5nzSq0xbh/ySELyvsy9XIl lhjnS4qyrQbLLnuMaEAxGqsrEafBGzFSqtavTwXm8Ld91gWaaYxdXma2DtaUItBrCsZO rBFEQvxDLcIoPbDzdA8dqgJSFMXSmhb7Yy6Z4CsWymvHmVt6CT3Vu2JFpWvDhWC7XIDi pbII5TYx04WFyt8aDKcjv64XYlRzKlnU8AwnIK6LecQEoJlhDlzZTCKQpAjaKs0YXLkK rBBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cLstzH1LNj+g6CEwT6Bs49sL4xGFgD5yGkJsHn4QoB0=; b=YXNIdLVrd9ApRB1gt8TRDCQ1NV1gKC6y7ltZAPl7qHQvTRvOxP6ZElwhkpSl3uWMvb gsJO25nXa9LuXz8gKgiQ8+HFPcD4/WJhvJSB8LEfatek43PM9XB0L6808xerGLp4yeL1 5nRNqNayxA3SI+TnSVlBBET8bKxBINBL9BFL7B1t5clZ2ILDKIDNsQFSdYsaUCyTdDQN 10z+N5di2yRprnQWpDm0/BSTN7BO8lcd0xRwHWALGjL2EULv2i6akRdRVE+PeENgKpqr aDyCD1uL7Akgt1uPXqP5wljSQYPsdrshE4WAJFJyzSCyG1wm1kz9Y8YF0dghINwuVGmo d80Q== X-Gm-Message-State: AOAM531lGP+gtNCQ6IOHOvn/Tj8NfrS8B2ZJ3eQ+T0aXkCjh0UQJXAal jiDnFBMIuWFrf73yMTwWhGpTTHo+s1pyBp3jIJQ= X-Google-Smtp-Source: ABdhPJwd56XRn3AqwOqX/fuwEl0+tQ4bzTp0vBg+8n/ljzCRzmGOanyF29SjgH/2vSndKMmE/sNtorHvr4RnNE87cJ8= X-Received: by 2002:a05:6602:6c9:: with SMTP id n9mr269234iox.91.1598984389615; Tue, 01 Sep 2020 11:19:49 -0700 (PDT) MIME-Version: 1.0 References: <20200825002540.3351-1-yu-cheng.yu@intel.com> <20200825002540.3351-26-yu-cheng.yu@intel.com> <2d253891-9393-44d0-35e0-4b9a2da23cec@intel.com> <086c73d8-9b06-f074-e315-9964eb666db9@intel.com> <73c2211f-8811-2d9f-1930-1c5035e6129c@intel.com> <20200826164604.GW6642@arm.com> <87ft892vvf.fsf@oldenburg2.str.redhat.com> <20200826170841.GX6642@arm.com> <87tuwow7kg.fsf@oldenburg2.str.redhat.com> <873648w6qr.fsf@oldenburg2.str.redhat.com> <3c12b6ee-7c93-dcf4-fbf7-2698003386dd@intel.com> <87o8mpqtcn.fsf@oldenburg2.str.redhat.com> <87k0xdqs3t.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87k0xdqs3t.fsf@oldenburg2.str.redhat.com> From: "H.J. Lu" Date: Tue, 1 Sep 2020 11:19:13 -0700 Message-ID: Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: Florian Weimer Cc: "Yu, Yu-cheng" , Dave Martin , Dave Hansen , Andy Lutomirski , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Weijiang Yang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 1, 2020 at 11:17 AM Florian Weimer wrote: > > * Yu-cheng Yu: > > > On 9/1/2020 10:50 AM, Florian Weimer wrote: > >> * Yu-cheng Yu: > >> > >>> Like other arch_prctl()'s, this parameter was 'unsigned long' > >>> earlier. The idea was, since this arch_prctl is only implemented for > >>> the 64-bit kernel, we wanted it to look as 64-bit only. I will change > >>> it back to 'unsigned long'. > >> What about x32? In general, long is rather problematic for x32. > > > > The problem is the size of 'long', right? > > Because this parameter is passed in a register, and only the lower > > bits are used, x32 works as well. > > The userspace calling convention leaves the upper 32-bit undefined. > Therefore, this only works by accident if the kernel does not check that > the upper 32-bit are zero, which is probably a kernel bug. > > It's unclear to me what you are trying to accomplish. Why do you want > to use unsigned long here? The correct type appears to be unsigned int. > This correctly expresses that the upper 32 bits of the register do not > matter. > unsigned int is the correct type since only the lower 32 bits are used. -- H.J. 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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 38C51C433E2 for ; Tue, 1 Sep 2020 18:21:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC091206FA for ; Tue, 1 Sep 2020 18:21:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e3DcllFi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC091206FA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6B5B190001D; Tue, 1 Sep 2020 14:21:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 63E576B00CD; Tue, 1 Sep 2020 14:21:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 505FE90001D; Tue, 1 Sep 2020 14:21:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 3801A6B00C9 for ; Tue, 1 Sep 2020 14:21:04 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EA42B181AEF10 for ; Tue, 1 Sep 2020 18:21:03 +0000 (UTC) X-FDA: 77215309206.06.bath69_220ed2c2709a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id C681B1005FBF2 for ; Tue, 1 Sep 2020 18:19:50 +0000 (UTC) X-HE-Tag: bath69_220ed2c2709a X-Filterd-Recvd-Size: 5870 Received: from mail-io1-f65.google.com (mail-io1-f65.google.com [209.85.166.65]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 1 Sep 2020 18:19:50 +0000 (UTC) Received: by mail-io1-f65.google.com with SMTP id g128so2355193iof.11 for ; Tue, 01 Sep 2020 11:19:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cLstzH1LNj+g6CEwT6Bs49sL4xGFgD5yGkJsHn4QoB0=; b=e3DcllFiRd99EFhMW9PLPljTKxeW0vc47NVr96CC+Vzh6dkUK4Mmdgcl1sZq/kJoLz 3gSmb4o3MV+chM/XWnck2/Zy6U7/keXIVgEz6ul7hTS5rc5nzSq0xbh/ySELyvsy9XIl lhjnS4qyrQbLLnuMaEAxGqsrEafBGzFSqtavTwXm8Ld91gWaaYxdXma2DtaUItBrCsZO rBFEQvxDLcIoPbDzdA8dqgJSFMXSmhb7Yy6Z4CsWymvHmVt6CT3Vu2JFpWvDhWC7XIDi pbII5TYx04WFyt8aDKcjv64XYlRzKlnU8AwnIK6LecQEoJlhDlzZTCKQpAjaKs0YXLkK rBBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cLstzH1LNj+g6CEwT6Bs49sL4xGFgD5yGkJsHn4QoB0=; b=G7GKmH15R09tQnKsPxywHzOvGanor/NAMV38CsBbjE54/33tljZHwt+NE65/TNrD+W xqQZdhy4uy8II6c+tYLmUM0oElOrxUkH0uPZw+qWQUp1yb0YC0qGUol+EPo0bn54cIvz HCvTM3PxPxAdO0a4ar7D3Bowp09G34Vvediwq4Ykm+7OnMNs8XHfVIz3oqOnJksHYK3e ZHYePPdEeoSJf7qBEDSNNAibhglDi89hRobsIGoBi2V+vmUQb59kPCVEwES31OQJJQrc G8WeOlHVCN1kntmVwV1VVnE4XB1BevbDmNxNyfDr33X+8Wcv0G8E6HzhLhVLlyGist4Q I/0Q== X-Gm-Message-State: AOAM531IA3tb2HByZh4kf0xogDothPyZelZhRIt+h3HYctZ4XWmJoGtw mPWkdaFwL5XcFAd5ID886RoYVT/s52ZNRg3sSiw= X-Google-Smtp-Source: ABdhPJwd56XRn3AqwOqX/fuwEl0+tQ4bzTp0vBg+8n/ljzCRzmGOanyF29SjgH/2vSndKMmE/sNtorHvr4RnNE87cJ8= X-Received: by 2002:a05:6602:6c9:: with SMTP id n9mr269234iox.91.1598984389615; Tue, 01 Sep 2020 11:19:49 -0700 (PDT) MIME-Version: 1.0 References: <20200825002540.3351-1-yu-cheng.yu@intel.com> <20200825002540.3351-26-yu-cheng.yu@intel.com> <2d253891-9393-44d0-35e0-4b9a2da23cec@intel.com> <086c73d8-9b06-f074-e315-9964eb666db9@intel.com> <73c2211f-8811-2d9f-1930-1c5035e6129c@intel.com> <20200826164604.GW6642@arm.com> <87ft892vvf.fsf@oldenburg2.str.redhat.com> <20200826170841.GX6642@arm.com> <87tuwow7kg.fsf@oldenburg2.str.redhat.com> <873648w6qr.fsf@oldenburg2.str.redhat.com> <3c12b6ee-7c93-dcf4-fbf7-2698003386dd@intel.com> <87o8mpqtcn.fsf@oldenburg2.str.redhat.com> <87k0xdqs3t.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87k0xdqs3t.fsf@oldenburg2.str.redhat.com> From: "H.J. Lu" Date: Tue, 1 Sep 2020 11:19:13 -0700 Message-ID: Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: Florian Weimer Cc: "Yu, Yu-cheng" , Dave Martin , Dave Hansen , Andy Lutomirski , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Weijiang Yang Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: C681B1005FBF2 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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 Tue, Sep 1, 2020 at 11:17 AM Florian Weimer wrote: > > * Yu-cheng Yu: > > > On 9/1/2020 10:50 AM, Florian Weimer wrote: > >> * Yu-cheng Yu: > >> > >>> Like other arch_prctl()'s, this parameter was 'unsigned long' > >>> earlier. The idea was, since this arch_prctl is only implemented for > >>> the 64-bit kernel, we wanted it to look as 64-bit only. I will change > >>> it back to 'unsigned long'. > >> What about x32? In general, long is rather problematic for x32. > > > > The problem is the size of 'long', right? > > Because this parameter is passed in a register, and only the lower > > bits are used, x32 works as well. > > The userspace calling convention leaves the upper 32-bit undefined. > Therefore, this only works by accident if the kernel does not check that > the upper 32-bit are zero, which is probably a kernel bug. > > It's unclear to me what you are trying to accomplish. Why do you want > to use unsigned long here? The correct type appears to be unsigned int. > This correctly expresses that the upper 32 bits of the register do not > matter. > unsigned int is the correct type since only the lower 32 bits are used. -- H.J.