Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp730770imm; Wed, 20 Jun 2018 05:50:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK+uZg9t8AfHa4rB2OGlXKUBvNlSKXXjQ8w9+dK2fSgsekvMS9SL9oUorwYIrfTeo6JSeLc X-Received: by 2002:a65:608c:: with SMTP id t12-v6mr19097214pgu.159.1529499059657; Wed, 20 Jun 2018 05:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529499059; cv=none; d=google.com; s=arc-20160816; b=Ar271gHEasIUBrwOw/jMR8SzPAsyJzkpqu2eGQp/9lpkIrC86lwOuxxcYbmTx/rI2Y 6Sj/vgA+r3yPb+ebtv+ybwedTaEgKYflM2MLO0ii1yXohvPz4I6WY3jZ40aR49MnkQuE TqpYoZ02UjsEhTvtTbU9uo8HMRUsYI3o9lj39grqQgJGBQGCmYU5MY52xW5hdQspRG5s ur0L+o92W5VkYR0TjC/emXKGSM3APqs8gp65y7OIqEBvo9jaaozrEWc+TisTX9m/wEXP UnR+NvNn+0GyjBkQedAE7d3dbL9KnbIpw05JSum4FyvdmazAf0zrNyU49XgU7vB9COYf 85/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=OCLtQOflFVE+x7sjSfDqt+HKMgDHqFZwp5574KB2LEg=; b=NRE4Zr6QDgj3tNvjJben9durEyB1JTT8RHrMmzwyzXhh24BKjoPtcUqcL/paPRuXTW CuH+BV++bowcBkn8DWQ0xBJQZ1kLDoBQaxKbjMpZxB9mXDqM5N1ZilY8c4GmtEa8E68y vz+qnJrsgK7jtZhpRFMMSua1Tac+wXM6wZUYRr7n8uWPrv5DsQI3FCed7ClUczHnsnxi EGR8SAm3bIXzSR/Aw2HMdMpeKaxndVDDnCEiHrOv83mOzjK8pALmeQMWi6O5mPmoQnRr bNWGdNxgRFn4WQ8cD366F5w7ATol/8OdbsDr5X54XyapK0SeqH5d0xqEsr3C7Ze3ONjU g16Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w23-v6si2417506pfj.144.2018.06.20.05.50.45; Wed, 20 Jun 2018 05:50:59 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753938AbeFTMsX (ORCPT + 99 others); Wed, 20 Jun 2018 08:48:23 -0400 Received: from mga06.intel.com ([134.134.136.31]:35849 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751337AbeFTMsW (ORCPT ); Wed, 20 Jun 2018 08:48:22 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jun 2018 05:48:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,247,1526367600"; d="scan'208";a="60783704" Received: from dengy1x-mobl1.ccr.corp.intel.com (HELO wfg-t570.sh.intel.com) ([10.254.213.248]) by orsmga003.jf.intel.com with ESMTP; 20 Jun 2018 05:48:18 -0700 Received: from wfg by wfg-t570.sh.intel.com with local (Exim 4.89) (envelope-from ) id 1fVcX4-0001dE-1q; Wed, 20 Jun 2018 20:48:18 +0800 Date: Wed, 20 Jun 2018 20:48:18 +0800 From: Fengguang Wu To: Dmitry Vyukov Cc: Sergey Senozhatsky , Petr Mladek , Tetsuo Handa , Sergey Senozhatsky , syzkaller , Steven Rostedt , LKML , Linus Torvalds , Andrew Morton Subject: Re: [PATCH] printk: inject caller information into the body of message Message-ID: <20180620124818.4bnkp3i7q2wuwx4y@wfg-t540p.sh.intel.com> References: <20180620083126.GA477@jagdpanzerIV> <20180620090413.GA444@jagdpanzerIV> <20180620113731.y7apmqoh6ke6ar2v@wfg-t540p.sh.intel.com> <20180620124157.gd5245o63dq6teul@wfg-t540p.sh.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 20, 2018 at 02:45:25PM +0200, Dmitry Vyukov wrote: >On Wed, Jun 20, 2018 at 2:41 PM, Fengguang Wu wrote: >> On Wed, Jun 20, 2018 at 02:31:51PM +0200, Dmitry Vyukov wrote: >>> >>> On Wed, Jun 20, 2018 at 1:37 PM, Fengguang Wu >>> wrote: >>>> >>>> On Wed, Jun 20, 2018 at 11:30:05AM +0200, Dmitry Vyukov wrote: >>>>> >>>>> >>>>> On Wed, Jun 20, 2018 at 11:06 AM, Sergey Senozhatsky >>>>> wrote: >>>>>> >>>>>> >>>>>> Hi Dmitry, >>>>>> >>>>>> On (06/20/18 10:45), Dmitry Vyukov wrote: >>>>>>> >>>>>>> >>>>>>> Hi Sergey, >>>>>>> >>>>>>> What are the visible differences between this patch and Tetsuo's >>>>>>> patch? >>>>>> >>>>>> >>>>>> >>>>>> I guess none, and looking at your requirements below I tend to agree >>>>>> that Tetsuo's approach is probably what you need at the end of the day. >>>>>> >>>>>>> The only thing that will matter for syzkaller parsing in the >>>>>>> end is the resulting text format as it appears on console. But you say >>>>>>> "I'm not pushing for this particular message format", so what exactly >>>>>>> do you want me to provide feedback on? >>>>>>> I guess we need to handle pr_cont properly whatever approach we take. >>>>>> >>>>>> >>>>>> >>>>>> Mostly, was wondering about if: >>>>>> a) you need pr_cont() handling >>>>>> b) you need printk_safe() handling >>>>>> >>>>>> The reasons I left those things behind: >>>>>> >>>>>> a) pr_cont() is officially hated. It was never supposed to be used >>>>>> on SMP systems. So I wasn't sure if we need all that effort and >>>>>> add tricky code to handle pr_cont(). Given that syzkaller is >>>>>> probably the only user of that functionality. >>>>> >>>>> >>>>> >>>>> Well, if I put my syzkaller hat on, then I don't care what exactly >>>>> happens in the kernel, the only thing I care is well-formed output on >>>>> console that can be parsed unambiguously in all cases. >>>> >>>> >>>> >>>> +1 for 0day kernel testing. >>>> >>>> I admit that goal may never be 100% achievable -- at least some serial >>>> console logs can sometimes become messy. So we'll have to write dmesg >>>> parsing code in defensive ways. >>>> >>>> But some unnecessary pr_cont() broken-up messages can obviously be >>>> avoided. For example, >>>> >>>> arch/x86/mm/fault.c: >>>> >>>> printk(KERN_ALERT "BUG: unable to handle kernel "); >>>> if (address < PAGE_SIZE) >>>> printk(KERN_CONT "NULL pointer dereference"); >>>> else >>>> printk(KERN_CONT "paging request"); >>>> >>>> I've actually proposed to remove the above KERN_CONT, unfortunately the >>>> patch was silently ignored. >>> >>> >>> >>> I've just cooked this change too, but do you mind reviving your patch? >> >> >> Yes, sure. My version is more dumb. Since I'm not sure if it's OK to >> do string formatting at this critical point. Let's see how others >> think about the 2 approaches. I'm fine as long as our problem is fixed. :) > >It already does string formatting for address. And I think we also >need to get rid of KERN_CONT for address while we are here. Ah yes, sorry I overlooked the next KERN_CONT.. > >> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c >> index 9a84a0d08727..c7b068c6b010 100644 >> --- a/arch/x86/mm/fault.c >> +++ b/arch/x86/mm/fault.c >> @@ -671,11 +671,10 @@ show_fault_oops(struct pt_regs *regs, unsigned long >> error_code, >> printk(smep_warning, from_kuid(&init_user_ns, >> current_uid())); >> } >> >> - printk(KERN_ALERT "BUG: unable to handle kernel "); >> if (address < PAGE_SIZE) >> - printk(KERN_CONT "NULL pointer dereference"); >> + printk(KERN_ALERT "BUG: unable to handle kernel NULL pointer >> dereference"); >> else >> - printk(KERN_CONT "paging request"); >> + printk(KERN_ALERT "BUG: unable to handle kernel paging >> request"); >> >> >> printk(KERN_CONT " at %px\n", (void *) address); >> >>> It actually makes the code even shorter, which is nice: >>> >>> --- a/arch/x86/mm/fault.c >>> +++ b/arch/x86/mm/fault.c >>> @@ -671,13 +671,9 @@ show_fault_oops(struct pt_regs *regs, unsigned >>> long error_code, >>> printk(smep_warning, from_kuid(&init_user_ns, >>> current_uid())); >>> } >>> >>> - printk(KERN_ALERT "BUG: unable to handle kernel "); >>> - if (address < PAGE_SIZE) >>> - printk(KERN_CONT "NULL pointer dereference"); >>> - else >>> - printk(KERN_CONT "paging request"); >>> - >>> - printk(KERN_CONT " at %px\n", (void *) address); >>> + printk(KERN_ALERT "BUG: unable to handle kernel %s at %px\n", >>> + (address < PAGE_SIZE ? "NULL pointer dereference" : >>> + "paging request"), (void *) address); >>> >>> dump_pagetable(address); >>> } >>> >> >