Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp47580pxf; Wed, 24 Mar 2021 20:33:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeO5/ZqFsQif1Tb/iEqQb4FAQE9lABa8X0GMaw83QwqfuQvw0pudoI1qGqjxGwsGhrwaiO X-Received: by 2002:a17:906:90c5:: with SMTP id v5mr7050873ejw.466.1616643215179; Wed, 24 Mar 2021 20:33:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616643215; cv=none; d=google.com; s=arc-20160816; b=DP4durM6H9E9Rby1gy75Mrpao5FoTU1dRRjruDmf7cUCnYw4b8UVDqBiHwXH0mjQh7 W7POr2yv7UbtWt71d6xrCq182S7cDOoUNoINVchD1GM+KBlRmBfugUFAL28788jOrUn9 ATyED1JdpT9gy4I+FMBtn/NZUkcsgQw4k9Lc6MXx78gQ+MGHiWQm3kRrGSe1OaPUFtEu mhdN3ptAvNogl2i0MY2mManTsTXYejzfi3HlhI5Zf6CkO4ca6Cj15eATtxms2otxFpbX hv+0FfcMWOg1+oP2TUX82UsGnl0TaPtnqWsGUFT4z2ADrGyPFV2H/CRg+PPAuXJrzBUW DmMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=tq8n+zigNCmvjneFzOW0Jj/uC4JegpXE/jMM6W6rwRA=; b=SzVDgqHMh0YT5/JaDLU+AYFNL4yIS+99ySgOBz8rd9fkZWUP8ewTaWSooSIHQ2PMHG 6K7xgDU6I6QFFbYGS/E51DjbD2rXza3Ld9fYVyTuPc5S9TZRW1qUdygoQ7TqZ/a3w2Q3 X+uKGi0Io226Uwg7fycUSQt0rhI4Mk+GlTJHezP2qsR6l0IqjMadsWDfGftw62GrnFhk g3+z/xKEl/R2rv8QuK1pth/CTG3f52U+iUYKWoQgCX8GCBDgIbgbM0EOaWqrcOenPXPo lXKE1gFiIuA7hqpi2hK6P/Hy469N7NhfuOW7LmL5a2K3xfefViNuOf/xl6iWogRJHhpY MccA== ARC-Authentication-Results: i=1; mx.google.com; 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 c14si3546988edn.523.2021.03.24.20.33.12; Wed, 24 Mar 2021 20:33:35 -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; 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 S238759AbhCXWS5 (ORCPT + 99 others); Wed, 24 Mar 2021 18:18:57 -0400 Received: from smtprelay0134.hostedemail.com ([216.40.44.134]:43810 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231854AbhCXWSm (ORCPT ); Wed, 24 Mar 2021 18:18:42 -0400 Received: from omf13.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 6A9901822451D; Wed, 24 Mar 2021 22:18:41 +0000 (UTC) Received: from [192.168.1.159] (unknown [47.151.137.21]) (Authenticated sender: joe@perches.com) by omf13.hostedemail.com (Postfix) with ESMTPA id D56711124F6; Wed, 24 Mar 2021 22:18:36 +0000 (UTC) Message-ID: <9d320cd403921f4b36b726b71a51572463599cf5.camel@perches.com> Subject: Re: [RFC patch] vsprintf: Allow %pe to print non PTR_ERR %pe uses as decimal From: Joe Perches To: Rasmus Villemoes , 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 Date: Wed, 24 Mar 2021 15:18:35 -0700 In-Reply-To: <3d66137e-7842-2764-456f-7cc9e54a6d2e@rasmusvillemoes.dk> 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> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: D56711124F6 X-Spam-Status: No, score=0.10 X-Stat-Signature: jght7a4w3aihr8qtzepipotqu39yx7bw X-Rspamd-Server: rspamout01 X-HE-Tag: 1616624316-471145 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ERR_PTR is just include/linux/err.h:static inline void * __must_check ERR_PTR(long error) include/linux/err.h-{ include/linux/err.h- return (void *) error; include/linux/err.h-}f > 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. It already does that in 2 cases.