From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4CupGJMvpGB7JAAAWB0awg (envelope-from ) for ; Tue, 18 May 2021 17:20:19 -0400 Received: by simark.ca (Postfix, from userid 112) id 62C7B1F11C; Tue, 18 May 2021 17:20:19 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 837AE1E813 for ; Tue, 18 May 2021 17:20:18 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC171385781F; Tue, 18 May 2021 21:20:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC171385781F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621372817; bh=ySJuO5cf6ZFlV9MO0g1Hp8e4M8WncFqfxjFkgOOIGac=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Wc9pcWaDYxhKsDWCsGwNxjjF4t6bXWxO4Dv0IE/z7SreVpKddBk3vl2Q//VHkYQkp t/lx0+J+TK2Qx/zJUki1TdWZtbpJCLVF8GW0Qr6s17YWodPECf5jyHwsbZHeyh4b/j Gsd/1A44NJnXnIwYo9adKf6umBHDT30UbFwYHATw= Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by sourceware.org (Postfix) with ESMTPS id 51D4F385781F for ; Tue, 18 May 2021 21:20:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 51D4F385781F Received: by mail-qk1-x72a.google.com with SMTP id i67so10791027qkc.4 for ; Tue, 18 May 2021 14:20:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ySJuO5cf6ZFlV9MO0g1Hp8e4M8WncFqfxjFkgOOIGac=; b=WSS+soKvp9iRmHtg6qwTbzNnNcypeJ5s+dnTYzDnWMshySA3JgIQBL84mguuQm9Zc2 SBg+bjPgiaZzM3KeBeht3HlXGETpuiry7krw2mU1ff7mXtknUaYXSmSXAnIwBt3XHAjx s7mGrnArxck3alWMgbtM830Zq9w5eNXsBWHnA1i85HCLTAk7krwSSM6Ix0t7U5nmvluO wucfJCSltw0gmlyiqeI/IxJYxSgWXc6CoBThUZM14iNOeFl+ACBfCjfQQb/LP6qsR9EN 4YycspjzwKP9ytOq0zO5S7aKRCHSIbX08Q8kARPvKHVkxCzdmqBi1g25uvj83ZFGonyy xC6g== X-Gm-Message-State: AOAM531tkWDilfxc/W8aY38VR7T0Anh5SdxTSVVU/ycOb8v5f52Ls/4f dT0CVbkWNr5ymlRpupbuoYt+tzI1SfSxCQ== X-Google-Smtp-Source: ABdhPJz9MvRDTIdG39AliquRAmq0l7JHwHFDmj6NaMde/Imp34nXMGzbvKlpY6CUjjLnxPEO3WNhcQ== X-Received: by 2002:a37:2e05:: with SMTP id u5mr7879681qkh.139.1621372814904; Tue, 18 May 2021 14:20:14 -0700 (PDT) Received: from ?IPv6:2804:7f0:4841:40ad:9dc9:85ce:6858:530f? ([2804:7f0:4841:40ad:9dc9:85ce:6858:530f]) by smtp.gmail.com with ESMTPSA id q13sm14114420qkj.43.2021.05.18.14.20.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 May 2021 14:20:14 -0700 (PDT) Subject: Re: [PATCH] [AArch64] Sanitize the address before working with allocation tags To: Simon Marchi , gdb-patches@sourceware.org References: <20210518201953.3491983-1-luis.machado@linaro.org> Message-ID: Date: Tue, 18 May 2021 18:20:11 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 5/18/21 5:33 PM, Simon Marchi wrote: > On 2021-05-18 4:19 p.m., Luis Machado via Gdb-patches wrote: >> Remove the logical tag/top byte from the address whenever we have to work with >> allocation tags. > > Can you explain a bit more why this is needed? What down the line > doesn't like to receive an address with a logical tag? We shouldn't be passing an address with a non-zero top byte (or tag) to a ptrace request, for example. It may work (in fact, it works) but we are not supposed to rely on it. So we sanitize the pointer before it gets to fetch_memtags/store_memtags. This is clarified in the AArch64 Tagged Address ABI document (https://www.kernel.org/doc/html/latest/arm64/tagged-address-abi.html). In an upcoming patch to support memory tags in core files (https://sourceware.org/pipermail/gdb-patches/2021-May/178973.html), this address also gets passed down to the core target's fetch_memtags implementation. It needs to compare addresses, so it doesn't make sense to let through an address with a non-zero top byte, or else we risk not having a match due to differences in the upper byte.