Received: by 10.223.176.5 with SMTP id f5csp804442wra; Wed, 7 Feb 2018 07:49:45 -0800 (PST) X-Google-Smtp-Source: AH8x226ytEDIPsEvKz6ILqyLesRwpkMcxvfvllzd1Szul6nmekqR3dQlH+JbmXaS5MDy8vw7G6jZ X-Received: by 2002:a17:902:8f90:: with SMTP id z16-v6mr6558563plo.370.1518018585047; Wed, 07 Feb 2018 07:49:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518018585; cv=none; d=google.com; s=arc-20160816; b=y6LHAb8nMJHVQ1sLiuyNOvIkahTt2lnEUwQwLk0d+gE2ZMb1H3B4gQlpiAaBLLFjdb VJ1M4O0udRo+jV1P45O/j3Cr/mETlOkHLQAVaeJv5cUZtji6tydqckYWi2KKMEKZZKvT Yf76z5lUpvIWDZdN1zJ9l9l5pRBk6LL4HEH2vMyHEjmizsmKSowI3vlml93oG3wdvGFh lb+mo97VqUIQ3dNp+8lL7qVCq7Nqu4jT5RfZZs3F3z6evYiR4/SO2G9LsNjBsj03FUOH ENEH+pXVM10x9pazYr6+X2lNi+NONTv/4JvjH5VRKazUAmI+nNYgWeCAhPDTKYnAyV7f L6gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=5XSAopS4WiRI0WpQRT3y7TQOy5JQmcdD1H73YBcdoEQ=; b=ng7gFqpoXOtXXv43e43286lec6H2Mgjx+EalYETOcJ7QigF17ocabrafPmjzUEALDW Dy5hZtuOsV1/Y5ioLeSJ7ck4vSdd1o86sl3KjsMEAKA37H3d7lhxCV8lYZKxHkSvPc7R mPcE2hOoi3y0mp9LknOFb02WybFT2pmNEmBOPihSbs/SYXZkDpqYtnWVJLesrGhz0jWi fculwQltKTMcVj2KRu+vwOp1u4BkbKQVm+mfm3NK2SelQmhVVWCYB5yj07JpSi3LOUAf q2z269AFPBmvvK10cL55bh1xWoRChpJ+ei4iXu6hiyqP0jemMy6nFAD/egnX1IliUGwo /eog== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=IxfZXdxd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si1235074plq.540.2018.02.07.07.49.31; Wed, 07 Feb 2018 07:49:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=IxfZXdxd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754436AbeBGPsO (ORCPT + 99 others); Wed, 7 Feb 2018 10:48:14 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:37264 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754150AbeBGPsN (ORCPT ); Wed, 7 Feb 2018 10:48:13 -0500 Received: by mail-qk0-f195.google.com with SMTP id c128so1639259qkb.4 for ; Wed, 07 Feb 2018 07:48:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=5XSAopS4WiRI0WpQRT3y7TQOy5JQmcdD1H73YBcdoEQ=; b=IxfZXdxd5BoHwWh/x8NNKajYfGDNeKoZ0HR2sshqNyEjGpTajD/Cs2YMCr0lHUSfti Mxf2gZDG5hj4e97lU0LkSwkMq69Z6q0rroilZmeDiH/Qjft0Mis1ekhCb3zbMCxQMTFc FfNa0BAsC5sHB+YzsGMGQSP4BgywgZGezZfTiknzy0JOJsTpqZNCb/La++fYC0R2MuI0 nLra8WL2t7EDIZbl6j97HMFPcJ4/BKRflYoHPrIm0ZSydBSYB6SuaAydOs7JkNasQf8E PVhqikFP0pPB3iIsMPKLAOYoG51pFHWsEixUI0bDt7eA1u7sMVXMz+NGxKk/2OndOhh+ pyrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=5XSAopS4WiRI0WpQRT3y7TQOy5JQmcdD1H73YBcdoEQ=; b=soTcwrjXeppHEgYv+kLT14gx9IodkhJyI3tVbz5dkaj8305n93HFWT/72AjalFFlbG MYVCVmnpGSEb/ALQPCRM7NAjncK3LpJAClj50iyGA2PTi7cqNqzr1ySmH6XNhmMaQUc4 lWpuY19smrj2+Vme/DKfWvARQ5S0CdYh3MvhkHAoOZjGs/DQYjD8sKdR6SPrJ4+45Rjx 0axcGbkNDas+za35ibCt3dh0LRfpl0Te6xox4ZwrwB00GxJBSZcF8vU5iEzT0+DNq71A uEJCCZUvuZKWCr8k8DCrZ4B1RxAeeNuuSb9AAmVm5IWiCIknzKMNY5dORBUUSEnd5Udy Yl7w== X-Gm-Message-State: APf1xPBT5UnErpb+REuoGSRmh1kdW4z4tKjoikMcxn5cs2fxY00wfI4p Rm3sw3zijyGQkxC4YZvKp+8cUDrNFCeVNnD9Ogg= X-Received: by 10.55.46.69 with SMTP id u66mr9230721qkh.259.1518018492339; Wed, 07 Feb 2018 07:48:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.237.39.197 with HTTP; Wed, 7 Feb 2018 07:48:11 -0800 (PST) In-Reply-To: <20180207154116.xvojw3bzmnmexkav@pathway.suse.cz> References: <20180204174521.21383-1-kilobyte@angband.pl> <20180205094438.pfd7ffymlvklpxe7@pathway.suse.cz> <20180205201555.GQ29988@eros> <20180205205817.72dy7e7xzjcnwmhs@angband.pl> <20180207150328.nuk7f76nutq2trcg@pathway.suse.cz> <20180207154116.xvojw3bzmnmexkav@pathway.suse.cz> From: Geert Uytterhoeven Date: Wed, 7 Feb 2018 16:48:11 +0100 X-Google-Sender-Auth: bLyZGH6ttjAWut2B-fu9PxA5BZM Message-ID: Subject: Re: [PATCH] vsprintf: avoid misleading "(null)" for %px To: Petr Mladek Cc: Adam Borowski , Kees Cook , "Tobin C. Harding" , Sergey Senozhatsky , Steven Rostedt , LKML , Andrew Morton , Joe Perches , "Roberts, William C" , Linus Torvalds , David Laight , Randy Dunlap Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Petr, On Wed, Feb 7, 2018 at 4:41 PM, Petr Mladek wrote: > On Wed 2018-02-07 16:11:13, Geert Uytterhoeven wrote: >> On Wed, Feb 7, 2018 at 4:03 PM, Petr Mladek wrote: >> > [*] I made some archaeology: >> > >> > The "(null)" string was added by the commit d97106ab53f812910 >> > ("Make %p print '(null)' for NULL pointers"). >> > >> > It was a generic solution to prevent eventual crashes, see >> > https://lkml.kernel.org/r/1230979341-23029-1-git-send-email-xyzzy@speakeasy.org >> > >> > From this point, printing 00000000 for %px looks perfectly fine because >> > it does not crash. >> > >> > In fact, it would have made perfect sense to print 00000000 for pure >> > %p because it did not crash. But nobody has cared about the eventual >> > confusion yet. >> > >> > I am not sure if it makes sense to change the pure %p handling >> > now. Note that printing "(null)" has the advantage that we >> > get this string instead of the hash ;-) >> >> Note that "(null)" is also used for printing strings, where you do dereference >> the pointer, unlike for printing pointers. >> In addition, "(null)" for strings is not just printed for real NULL >> pointers, but >> also for anything pointing within the first page of virtual memory. > > We are on the safe side. "(null)" for "%s" is handled > separately, see string() function in lib/vsprintf.c. I know. > To make it clear. I was talking about "%p" format that is handled > in the pointer() function in lib/vsprintf.c. The "(null)" makes > sense only for the many modifiers that do deference of > the pointer, e.g. "%pa", "%pE", "%ph". It makes less sense > for the pure "%p" used without any modifier. Well, it actually > started to makes some sense after we started printing > the hash instead of the real pointer value. Sure. I agree with all of that. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds