Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp47179pxf; Wed, 24 Mar 2021 20:32:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJOZ8Uq/h3cdQn5Ayal0q6FFeTnrEsRhleg0ihRWzw6jPAgLir/1fKyWCDiStZkukIPg92 X-Received: by 2002:a17:906:b20b:: with SMTP id p11mr7271933ejz.0.1616643161034; Wed, 24 Mar 2021 20:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616643161; cv=none; d=google.com; s=arc-20160816; b=IgqU9o11FXyGWLYqJdNnO0dgOUR/c3d5oV3YBctlYXhVhPVcdObvB9Xyh+9u0ZZwbD QxRdmXf0Zt4ANR+sGxWRx+iZunIbETmsIzyZK3G5rSW59lhtKzvzxj2mVUkq4pTFZ1xW CKT0CgElsYyJaugMzUQBNJUD6wNECEKVLVSxJV2EMi2Wt10jY6XW5xhK9YUYSTsNbWBu HLhhAM7hrJv6SpaTburADsgalWNcF04VTUUtoBo9HJhvciiURLclk/hsRN0hI1IbImPG 11Fft7nR5Kt2VHjl48i7cYGE1A3T3oRbGrgCTAyvkP+Ss4ND3GrCyq198I0ey/dyk9BE vzGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=HrU0LEQQu62szOLJtECwzd0X8FkTv+FPbousgJV4Dpo=; b=Z8BeKFNc0ccMlLyPhWK7kJQE0/IvFtzgpyLFSxLMUKmCxIFsSJycHVRMA/FiC6qVf2 p/FqoC7Sd3OaQ8nJqLNI85xnkGQ/q5ROds1XWz4R5KG6IW1w0ea/pCKcIGE9VjVeTUp9 GJ3mE5kh/sR9JR+79nqBp74DKyUQDm7XaM2zVfSyagrsAv9j9N3PptJQeGBQL7uorXG4 f2rcIfP3KFYqjqKP9n83+Gjs2iDpPpkmY4Afrc6v7Y23ifiH9KYDHH0E+aCi0ixtquEn flTyxuueKS7zBTdgMX+xGCqof33xzS907RMjDll/KoSPkQo+F43BhXh10Pn5KUyQWpqw 70/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=R8y6i9CN; 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 r6si3322073eda.292.2021.03.24.20.32.18; Wed, 24 Mar 2021 20:32:41 -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=@rasmusvillemoes.dk header.s=google header.b=R8y6i9CN; 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 S238708AbhCXWg7 (ORCPT + 99 others); Wed, 24 Mar 2021 18:36:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233033AbhCXWg2 (ORCPT ); Wed, 24 Mar 2021 18:36:28 -0400 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A657C06174A for ; Wed, 24 Mar 2021 15:36:28 -0700 (PDT) Received: by mail-ed1-x52c.google.com with SMTP id y6so280670eds.1 for ; Wed, 24 Mar 2021 15:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=HrU0LEQQu62szOLJtECwzd0X8FkTv+FPbousgJV4Dpo=; b=R8y6i9CNrudieKcvjxBNrtnSuxS7RxwVCeP3FNC+TQrjrAc2dwq+8pr2w8NXzdDX2s 6eyB4YOTtskT1rFXmdrhfH6DRYaKh7/PIJhE/xX6XUk52fQXCG6wITUDn/Z+ZUSSBiq0 iZli6dy6oWmu8IBMakexH01HK+MDJ0Wt7wYEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HrU0LEQQu62szOLJtECwzd0X8FkTv+FPbousgJV4Dpo=; b=UFc8ZC5q+uYdtP72L+Gx/OEM3Z8sk9k9n46cshbbonTXTiOhuKdHr/Dek3ia1bVAL8 DlFss+HI1A0niH8QincGP7Goxu/oumtUn+MUXZfkSwkPyJBh+rsjvCUePEmVb5PkbZcw FkggQlq/SxOrVz6ok/7mqjXpNvAGwX2lZWz8aFGQImaN5ht/+v6o9Kj9KPolnTDdD6h9 TADUPrw8zPKcFNm3VyXGoJTDYjtpiH3cbVbOSvjO5WrJf7oW6cxCpH4asfVSZeDCJEGP cbu4FErbgUSowAhBkOziqnvMOGQhxiLZR/DM42Zw3wiHxnnxPo2O5vXYXMDIdX4XGiSU jkAA== X-Gm-Message-State: AOAM532/HT/32wNUvrc08l51mfpbffdqvC731tz0U+Sm1IAKYXLZH59f f5u610+q12XcKU8EQ91PJ04JmgAF634CpGKb X-Received: by 2002:aa7:d3ca:: with SMTP id o10mr5873130edr.374.1616625386815; Wed, 24 Mar 2021 15:36:26 -0700 (PDT) Received: from [192.168.1.149] ([80.208.71.248]) by smtp.gmail.com with ESMTPSA id cy5sm1787343edb.46.2021.03.24.15.36.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Mar 2021 15:36:26 -0700 (PDT) Subject: Re: [RFC patch] vsprintf: Allow %pe to print non PTR_ERR %pe uses as decimal To: Joe Perches , Arnd Bergmann , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko Cc: Philipp Zabel , David Airlie , Daniel Vetter , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Marco Felsch , Laurent Pinchart , Liu Ying , dri-devel , Linux ARM , Linux Kernel Mailing List References: <20210324121832.3714570-1-arnd@kernel.org> <810d36184b9fa2880d3ba7738a8f182e27f5107b.camel@perches.com> <3252fd83141aa9e0e6001acee1dd98e87c676b9a.camel@perches.com> <9feab1e8-4dee-6b79-03f7-7b9f0cb24f6e@rasmusvillemoes.dk> <3d66137e-7842-2764-456f-7cc9e54a6d2e@rasmusvillemoes.dk> <9d320cd403921f4b36b726b71a51572463599cf5.camel@perches.com> From: Rasmus Villemoes Message-ID: Date: Wed, 24 Mar 2021 23:36:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <9d320cd403921f4b36b726b71a51572463599cf5.camel@perches.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24/03/2021 23.18, Joe Perches wrote: > On Wed, 2021-03-24 at 22:27 +0100, Rasmus Villemoes wrote: >> On 24/03/2021 20.24, Joe Perches wrote: >>> On Wed, 2021-03-24 at 18:33 +0100, Rasmus Villemoes wrote: >>>> On 24/03/2021 18.20, Joe Perches wrote: >>>> >>>>> >>>>> Maybe it's better to output non PTR_ERR %pe uses as decimal so this >>>>> sort of code would work. >>>> >>>> No, because that would leak the pointer value when somebody has >>>> accidentally passed a real kernel pointer to %pe. >>> >>> I think it's not really an issue. >>> >>> _All_ code that uses %p extensions need inspection anyway. >> >> There are now a bunch of sanity checks in place that catch e.g. an >> ERR_PTR passed to an extension that would derefence the pointer; >> enforcing that only ERR_PTRs are passed to %pe (or falling back to %p) >> is another of those safeguards. >> >>> It's already possible to intentionally 'leak' the ptr value >>> by using %pe, -ptr so I think that's not really an issue. >>> >> >> Huh, what? I assume -ptr is shorthand for (void*)-(unsigned long)ptr. >> How would that leak the value if ptr is an ordinary kernel pointer? >> That's not an ERR_PTR unless (unsigned long)ptr is < 4095 or so. > > You are confusing ERR_PTR with IS_ERR No I'm not, I'm just being slightly sloppy - obviously when I say "not an ERR_PTR" I mean "not the result of ERR_PTR applied to a negative errno value", or "not the result of a valid invocation of ERR_PTR". But yes, feel free to read "not an ERR_PTR" as "something for which IS_ERR is false". Can you expand on why you think %pe, -ptr would leak the value of ptr? >> If you want to print the pointer value just do %px. No need for silly >> games. > > There's no silly game here. %pe would either print a string or a value. A hashed value, that is, never the raw value. > It already does that in 2 cases. Yes, if you pass it ERR_PTR(-1234) (where no E symbol exists) or ERR_PTR(-EINVAL) but CONFIG_SYMBOLIC_ERRNAME=n, it prints the value in decimal, because people will probably recognize "-22" and values in that range don't reveal anything about the kernel image. Anything outside [-4095,0] or so is hashed. Rasmus