Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755273AbdIGMiv (ORCPT ); Thu, 7 Sep 2017 08:38:51 -0400 Received: from mout.gmx.net ([212.227.17.20]:50472 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754393AbdIGMit (ORCPT ); Thu, 7 Sep 2017 08:38:49 -0400 Subject: Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages To: Sergey Senozhatsky Cc: linux-kernel@vger.kernel.org, Sergey Senozhatsky , Petr Mladek , Andrew Morton , Tony Luck , Fenghua Yu , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman References: <1504729681-3504-1-git-send-email-deller@gmx.de> <20170907004522.GA3885@jagdpanzerIV.localdomain> <8b93f9ca-95f6-4e40-1cc8-d1a65833abff@gmx.de> <20170907075653.GA533@jagdpanzerIV.localdomain> <20170907083207.GC533@jagdpanzerIV.localdomain> <667b8849-fb60-a312-2483-505252ff737e@gmx.de> <20170907093631.GD533@jagdpanzerIV.localdomain> <20170907095119.GE533@jagdpanzerIV.localdomain> From: Helge Deller Message-ID: <0604f27e-24ab-625b-9013-c6c0f4f6acc1@gmx.de> Date: Thu, 7 Sep 2017 14:38:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170907095119.GE533@jagdpanzerIV.localdomain> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:1SSn2JXey+Nstq3tqZlcIs+YoLwZmlASiSN71budtOaONB/T4RP yPnH72PBi6R+89zY6/E2GBHug5LKALALMxmL2RT/RNXydR7YBcVx9i3qYOaVhqGKXS1m8sr hzV2++3WtY3/BHmPkSPvbCQ4nhmRjnwnWxCnQ0OlYDYX98N3X+dAK42mQ/RmlLyEPAzu2o6 jI2A8bGGOVOhwV6+faIkQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:vUticnTTvAs=:on3H0DlZEUC509Ix2HuZfR ltBvHDIEuYWzBPuJ4sjDrOMquGWxxy+myf+UtH4JwxD4F3SphPuXc2T7hkJV//yrpHnQXpyMU J4PFQDjuINuGZw6rFLwWPCSDQSIiTkvuSkBuXam/ZVGRqVOuCwDUmsmpG9Dk4qSh8j+LfpWox T9d/olJDSk9D5+oUPXi4YVkoorFG8L1le9V0RcgF3RxBgeVVVOM2qZcEQv9NcKgRJwo999oRA X/cB5mK9r3UkPnk44UHI1NWRPb3Fz1t4abQlfZKRNxj89ZqZZKcD2bFJA53GLFWIsRkVzkox5 uNCB2zb31lWIQvuWuaesfOCPg0Dn7P0fu9r+hlK+yNBAeQHZYKqZ2d/EaqHsOg5WBvP3M9pD8 DHT8JA/HxJ2pHprC4SQXNr/ofz/cI+GnI3pfzBN4IstMHfMbU3/xpOnPTB49Lp0GyefDL8Mhy tkDm5FNucRDqMvoZrwfFrve/psMIsd6ao0nR0QiM2iJOCNhU6YJ4AzCEFyFmgFlNOrpfI21eE 1TtO0HTxpeh6fIPEXgH36p32SnAvonxviDwFLJ8kRKcHZlywW/Lg0+dsB4bkYM+D91iZGieup yrm5H27EU5tlbJdQIFlQ1KnPchQX3AQEbGiDDhyZkMrnvO6s5EdVxWlG4jfZslZhzFUZWmHsX zcX4sL7YGp6upRCN5LAKSsLc2uA1RDmz0v1SxEMte9/+Te2PJ56DuQZGZ1c0SOd4Kll6tLM14 6xkmvX/bzjhwCnZP0tafVv+3yGqhYY0uU6nhOq0tRuMEDdK2s5XYWG+vD46yAUOVkWgvbB2CO 3BIFYmlAIf9o0Mj864pDoZog/4F06cmB1uTxOALHii91C4luyg= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2173 Lines: 71 On 07.09.2017 11:51, Sergey Senozhatsky wrote: > On (09/07/17 18:36), Sergey Senozhatsky wrote: > [..] >>> I can look into adding such check-code, but even then the warning will >>> only show up if you run on ia64, ppc64 and parisc64. > > sorry, not sure I understand the "warning" part. I was thinking about adding code which warns at runtime if %pF/%pS is presumable used wrongly. You are thinking about code to work around the complexity by some kind of autodetection. > what I'm thinking about is: > > - every platform that needs descriptor dereference defines its own > function. otherwise dereference_descriptor(p) is just (p). > > - so it's something like > > arch/platform_abc/include/asm/sections.h > > #undef dereference_function_descriptor > static inline void *dereference_function_descriptor(void *ptr) > { > if (not_a_function_descriptor(ptr)) > return ptr; I'm not sure if it's possible on ia64/ppc64/parisc64 to reliably detect if it's a function descriptor or not. > if (!probe_kernel_address(....)) > return function_ip; > return ptr; > } > > - so then in lib/vsprintf.c we can do unconditionally > > case F: > case f: > case S: > case s: > case B: > ptr = dereference_function_descriptor(ptr); > return symbol_string(....); > > because platforms will take care of proper descriptor dereference, > when needed. Ok, but... > - and ideally we even can drop %pF-%pf. because there won't > be any difference between `S' and `F'. > something like this. > let's see if this is possible. > any thoughts? I see your idea, nevertheless, there *is* a difference between a "pointer to some assembler statement" (%pS), and a "pointer to a function" (%pF) on some architectures. That's why %pF and %pS printk specifiers were introduced in 2008 by Linus in commit 0fe1ef24f7bd0020f29ffe287dfdb9ead33ca0b2. People will probably get it wrong sometimes, and to try to avoid this by some magic autodetection is IMHO the wrong solution. Instead, maybe adding some checks to scripts/checkpatch.pl can help? E.g. warn if %pF is used in combination with the keywords like _builtin_return_address, _RET_IP_, and similar. Helge