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=-8.5 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 B40A6C433E0 for ; Fri, 26 Jun 2020 12:03:54 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F2452078D for ; Fri, 26 Jun 2020 12:03:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="u91wRsOL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="teoMQEZx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F2452078D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gn8FpMzwMU6iVpLg22X9NqvaATh0oIngSrbHmiJvw6Q=; b=u91wRsOLwY7Z3DFQLYuCQaSRQ O0p/2gJH0It9y8eDH36MaL/eB6LOZ4h2JliEpYfKib4wLpn8LIHGZml1Hl8jIWtT9y6s/xjbcu00n N1OJ08fykKbojcdNv8rs1RSkIDDNYWt4VWU/rxPH7C5l2Q22JSgKa/Tf6upmPNMfg5fiKLyf9AsS+ 7IaehlmJYAkB02YCdSHrSYGEHi6cb8OsEZGTN8kpE6pRoyQPWCOP+toyKd7ckeFfgrPN7srQjwP+1 XzngaVKxpbRs44RBFar9oDRSEijHQNHsgXOfojoWPPsQM50TNnh+MOS+kTqjGvJKTvXFw69FLyQAX fDourbD1Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jon35-00023B-PZ; Fri, 26 Jun 2020 12:01:40 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jomS8-00015T-NA for linux-arm-kernel@lists.infradead.org; Fri, 26 Jun 2020 11:23:34 +0000 Received: by mail-ed1-x542.google.com with SMTP id z17so6618177edr.9 for ; Fri, 26 Jun 2020 04:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=n+tht2DGNjBrmARE6GPyjVkkvtq8Xj+55csOpCDEf8A=; b=teoMQEZx/+IkQWYbD58QpSoZ2D+BL0cSKEu3XLbKu1cYdeUStLfNlJFeOiJHIpFLGz On0fODc1R/LIL8kNNkVVGTjI8wwrWFqGJ/nZHZ686KFpR0nIlBcpIGP5hcC8nh1CPsa2 fd2tnIbLJqhqwrgTbER2pnyhneRgtHGY48h7VN6yAA6l5Dljt+tUP/EYhknVYz0AZPE5 IbFAsYRi5AaWR6VyjBQCDljiVm6vEyozIjgAe6kZC5O59c8nKinUepu2tB38nnlEeqyg QufFVB0i2vKAqQuXx/AWHnloGVd2o6qm/5R1pxoN29+9JgOSvtEfRK7qJPHYO9J3QDYq KQmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=n+tht2DGNjBrmARE6GPyjVkkvtq8Xj+55csOpCDEf8A=; b=InyZn2dh+NAN2nRJcOpp8iCjQKLwJIrTpcImtKyaf3x67+9cA1KTAfZCjpQzwWPQv+ GLDay4DROwN2rTLzc9mO/l0mQeAKgjpZ+8jjIVGuBDJaLcUTxponFnM3aVkGxYWMDYoH h9PdgqMFCVhnQiEIGhSsMy0bGIaTN+u0/DDOb0CToDWcJU6qUUqX0F9t5QOeGQjvC7vv G4n81IYcmwpBofVQ5ai4zPF3Kg6qThISeGDafb3JTz23HobcJyuvDiev5ndqhdnfIoc0 zRB+3jbQRQnlyL9OTG+j7JPPQJnKePtR6+TDYqpkGkrF98sQhPKNEriSw5EOta5ME8tZ 9VDw== X-Gm-Message-State: AOAM530M5Os6J31xAIGtMcbO4oHqtbC41c3Xas9BEn8bLfc/c5WZfyFA hxkUlg41/2Pd3sa1Tl9oEL0= X-Google-Smtp-Source: ABdhPJxiYLI2/4TKg5gS1zTkmkQjcYL3InoAu3asWDGa93+g2osyJGPfwfgHVBN1u5JHQCkoqCWMuw== X-Received: by 2002:a50:cf05:: with SMTP id c5mr2955330edk.232.1593170607485; Fri, 26 Jun 2020 04:23:27 -0700 (PDT) Received: from ?IPv6:2001:a61:253c:8201:b2fb:3ef8:ca:1604? ([2001:a61:253c:8201:b2fb:3ef8:ca:1604]) by smtp.gmail.com with ESMTPSA id r6sm20942428edx.83.2020.06.26.04.23.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 26 Jun 2020 04:23:27 -0700 (PDT) Subject: Re: [PATCH v3 2/2] prctl.2: Add tagged address ABI control prctls (arm64) To: Dave Martin References: <1593020162-9365-1-git-send-email-Dave.Martin@arm.com> <1593020162-9365-3-git-send-email-Dave.Martin@arm.com> From: "Michael Kerrisk (man-pages)" Message-ID: <660e8900-ca23-d022-79bd-3b16c70d36d2@gmail.com> Date: Fri, 26 Jun 2020 13:23:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1593020162-9365-3-git-send-email-Dave.Martin@arm.com> Content-Language: en-US X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-man@vger.kernel.org, Vincenzo Frascino , mtk.manpages@gmail.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Dave, On 6/24/20 7:36 PM, Dave Martin wrote: > Add documentation for the the PR_SET_TAGGED_ADDR_CTRL and > PR_GET_TAGGED_ADDR_CTRL prctls added in Linux 5.4 for arm64. > > Signed-off-by: Dave Martin > Reviewed-by: Catalin Marinas > Cc: Vincenzo Frascino Thanks for another nicely written patch! I've applied locally, but won't push just yet, to allow for some (more) reviews/acks to come in. Thanks, Michael > --- > > Kept Catalin's Reviewed-by, since the changes are pretty minor. > > Changes since v2: > > * Clarified type of PR_SET_TAGGED_ADDR_CTRL arg2. > > * Added Linux commit where enforecement of zeroing reserved args was > added for PR_SET_TAGGED_ADDR_CTRL. > > * Added explicit text regarding how to disable the tagged-address ABI > globally through sysctl. > > * Rearrange the tagged argument syscall exclusion list so that shmdt() > isn't called out specially. The reader probably doesn't care about > this history here. > > * Minor rewordings. > --- > man2/prctl.2 | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 161 insertions(+) > > diff --git a/man2/prctl.2 b/man2/prctl.2 > index 46ea9d2..cf92f3b 100644 > --- a/man2/prctl.2 > +++ b/man2/prctl.2 > @@ -1522,6 +1522,148 @@ For more information, see the kernel source file > (or > .I Documentation/arm64/sve.txt > before Linux 5.3). > +.\" prctl PR_SET_TAGGED_ADDR_CTRL > +.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d > +.TP > +.BR PR_SET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)" > +Controls support for passing tagged userspace addresses to the kernel > +(i.e., addresses where bits 56\(em63 are not all zero). > +.IP > +The level of support is selected by > +.IR "arg2" , > +which can be one of the following: > +.RS > +.TP > +.B 0 > +Addresses that are passed > +for the purpose of being dereferenced by the kernel > +must be untagged. > +.TP > +.B PR_TAGGED_ADDR_ENABLE > +Addresses that are passed > +for the purpose of being dereferenced by the kernel > +may be tagged, with the exceptions summarized below. > +.RE > +.IP > +The remaining arguments > +.IR arg3 ", " arg4 " and " arg5 > +must all be zero. > +.\" Enforcement added in > +.\" commit 3e91ec89f527b9870fe42dcbdb74fd389d123a95 > +.IP > +On success, the mode specified in > +.I arg2 > +is set for the calling thread and the the return value is 0. > +If the arguments are invalid, > +the mode specified in > +.I arg2 > +is unrecognized, > +or if this feature is unsupported by the kernel > +or disabled via > +.IR /proc/sys/abi/tagged_addr_disabled , > +the call fails with > +.BR EINVAL . > +.IP > +In particular, if > +.BR prctl ( PR_SET_TAGGED_ADDR_CTRL , > +0, 0, 0, 0) > +fails with > +.B EINVAL > +then all addresses passed to the kernel must be untagged. > +.IP > +Irrespective of which mode is set, > +addresses passed to certain interfaces > +must always be untagged: > +.RS > +.IP \(em > +.BR brk (2), > +.BR mmap (2), > +.BR shmat (2), > +.BR shmdt (2), > +and the > +.I new_address > +argument of > +.BR mremap (2). > +.IP > +(Prior to Linux 5.6 these accepted tagged addresses, > +but the behaviour may not be what you expect. > +Don't rely on it.) > +.IP \(em > +\(oqpolymorphic\(cq interfaces > +that accept pointers to arbitrary types cast to a > +.I void * > +or other generic type, specifically > +.BR prctl (2), > +.BR ioctl (2), > +and in general > +.BR setsockopt (2) > +(only certain specific > +.BR setsockopt (2) > +options allow tagged addresses). > +.RE > +.IP > +This list of exclusions may shrink > +when moving from one kernel version to a later kernel version. > +While the kernel may make some guarantees > +for backwards compatibility reasons, > +for the purposes of new software > +the effect of passing tagged addresses to these interfaces > +is unspecified. > +.IP > +The mode set by this call is inherited across > +.BR fork (2) > +and > +.BR clone (2). > +The mode is reset by > +.BR execve (2) > +to 0 > +(i.e., tagged addresses not permitted in the user/kernel ABI). > +.IP > +For more information, see the kernel source file > +.IR Documentation/arm64/tagged\-address\-abi.rst . > +.IP > +.B Warning: > +This call is primarily intended for use by the run-time environment. > +A successful > +.B PR_SET_TAGGED_ADDR_CTRL > +call elsewhere may crash the calling process. > +The conditions for using it safely are complex and system-dependent; > +Don't use it unless you know what you are doing. > +.\" prctl PR_GET_TAGGED_ADDR_CTRL > +.\" commit 63f0c60379650d82250f22e4cf4137ef3dc4f43d > +.TP > +.BR PR_GET_TAGGED_ADDR_CTRL " (since Linux 5.4, only on arm64)" > +Returns the current tagged address mode > +for the calling thread. > +.IP > +Arguments > +.IR arg2 ", " arg3 ", " arg4 " and " arg5 > +must all be zero. > +.IP > +If the arguments are invalid > +or this feature is disabled or unsupported by the kernel, > +the call fails with > +.BR EINVAL . > +In particular, if > +.BR prctl ( PR_GET_TAGGED_ADDR_CTRL , > +0, 0, 0, 0) > +fails with > +.BR EINVAL , > +then this feature is definitely either unsupported, > +or disabled via > +.IR /proc/sys/abi/tagged_addr_disabled . > +In this case, > +all addresses passed to the kernel must be untagged. > +.IP > +Otherwise, the call returns a nonnegative value > +describing the current tagged address mode, > +encoded in the same way as the > +.I arg2 > +argument of > +.BR PR_SET_TAGGED_ADDR_CTRL . > +.IP > +For more information, see the kernel source file > +.IR Documentation/arm64/tagged\-address\-abi.rst . > .\" > .\" prctl PR_TASK_PERF_EVENTS_DISABLE > .TP > @@ -1767,6 +1909,7 @@ On success, > .BR PR_GET_SPECULATION_CTRL , > .BR PR_SVE_GET_VL , > .BR PR_SVE_SET_VL , > +.BR PR_GET_TAGGED_ADDR_CTRL , > .BR PR_GET_THP_DISABLE , > .BR PR_GET_TIMING , > .BR PR_GET_TIMERSLACK , > @@ -2074,6 +2217,24 @@ is > .B PR_SVE_GET_VL > and SVE is not available on this platform. > .TP > +.B EINVAL > +.I option > +is > +.BR PR_SET_TAGGED_ADDR_CTRL > +and the arguments are invalid or unsupported. > +See the description of > +.B PR_SET_TAGGED_ADDR_CTRL > +above for details. > +.TP > +.B EINVAL > +.I option > +is > +.BR PR_GET_TAGGED_ADDR_CTRL > +and the arguments are invalid or unsupported. > +See the description of > +.B PR_GET_TAGGED_ADDR_CTRL > +above for details. > +.TP > .B ENODEV > .I option > was > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel