Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp726728imm; Wed, 20 Jun 2018 05:46:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJEyKa8F05VL82LjDYyOWPwY0xp++fBznihf+33VylQPwpNpFho9J6Kw6WxiWDSt9x0WEzk X-Received: by 2002:a62:2414:: with SMTP id r20-v6mr22661989pfj.108.1529498802559; Wed, 20 Jun 2018 05:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529498802; cv=none; d=google.com; s=arc-20160816; b=fNf2HH2SuF16SstuRwOGwwCnhzkGY+PzhiUG1TY/GvgX+VEfS8p3K0c9rjzDDuT5s0 fPrecpeaBK/DEa7MK3c39Xna4yUYw8KXdzv6GRLDPDj96L4w58Lwf4SIJuCzhxYVqsrx tuU5tOHAYWuIeTw5Rk/CCUI25+guT0Wr8zwQVWvtanKSnpYHCoPgOTpfUqdjt6/EsZaD H039Bv8yXAk49pEDvyjmox9Yeu9m/wWhUPWG+3yjS8r+6BKsaxGGRedtRkWJRHW9ZmPN MyX2+Pe0KhjBK8Er/3IfKhh2w2GnN887/uJQj2RKTtXDv1EshfG0ASFYLBfeSkU78Hkg spCA== 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=Zhem3wX2ow7r4xpwamydPZjHq8/E7WZ8t6kOTQo01JQ=; b=W8nZF4uwEpjzWTumWSY02u2uOPJfcxsVHbM7KK5ZYP0kzFt8dgHx2DaWeno7KOjYdj oy2oypXxdNp62XjqT4Zxxv/5F0CDpj/yfH6Ch+1c2wg4wSszSyHUHzQRetsuIClM6eLF KdaF4uFHsR1MGu5wsXkRdkpqW3H1mvjuS7m4L5vPEVWbNFzd3AajgzpMPzg77q9Z99mK 0VsV8sE6HFMO4vIbKk6qOZ4mDwk8w3kTHyZ7xbQxkMrVn+teB4qQ/utmbEGgLJhQP1+j 2V00lgaWqNHGCEnIXFueHKKsu0agzE0Lt+KCHsHRpFYhetkD5ctwCkfv9TN9XV3FIJCw yH+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=st4sI9yh; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si1904670pgv.668.2018.06.20.05.46.28; Wed, 20 Jun 2018 05:46:42 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=st4sI9yh; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753885AbeFTMpr (ORCPT + 99 others); Wed, 20 Jun 2018 08:45:47 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:45810 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751340AbeFTMpq (ORCPT ); Wed, 20 Jun 2018 08:45:46 -0400 Received: by mail-pl0-f68.google.com with SMTP id c23-v6so1708257plz.12 for ; Wed, 20 Jun 2018 05:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Zhem3wX2ow7r4xpwamydPZjHq8/E7WZ8t6kOTQo01JQ=; b=st4sI9yh9JDXdlX5P+1fq8yU54Hjvsf+ZEsXQ4WIGOgXibHqchhfGrPXBTUqsz1nhK Y4bw3vRvHWsePBUgr2SSxDyvXEcw/3KSrZ48LK/vVcat5Hz5d4hCipyBaVgqIJmomkqX 5lhU5t45ONOeCsOOJuH4Wl2ZJmQd3taVNtemFP5xphi8cvv4AYnoBVjVudDC8YCreWVw hq5PW6hpnSP9IyCUBeqLyDtGsSSuoRoBsj4ht5rbtLXcjglPX9qthj8bj88gxHMxpznQ d325/mG0xVQukOEeez+TImB2FYbHFyTds8QhUMCQX4PXNatmDlJ+5wDcGJJhKkSHzTAd T+8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Zhem3wX2ow7r4xpwamydPZjHq8/E7WZ8t6kOTQo01JQ=; b=nTAhD+28/8m93Hc1RO6EIfvP3dY48WRQgwmmbez7pjNYztykMgCks5M5LtanW4Zk1a lCzvTT0DERgw0zTinj4s3LOjULe2M0z2/c/GKi0fEj0NmOTeyknNtDIZMNMJZnDeSsNL NcEPF0ZzwfPOPZClE+GjQuiJ0vlunva1w1IW+PsRkEyRIqsgGVC6hOgRuOKtuZVNK3fp J9V7AkT1NNKGudEC59Q0eVPbvNmzd49dNYUfR/F7+GicFasaW40B4k6teqKF961bv/TI Zf+rhctRGoowLPRqge6EWVzunyR3a1z3z5qWB2Xw7KcjYlVd12/nN4FAm0QT3e6bXo/r Ejzw== X-Gm-Message-State: APt69E0nQIvVTVHCn+74qWqn+SowlpPGUlcXqJoXEM0MlT5AQ8NvOLZ7 Tg41Ww2H5FYzMwzwsc3h7ZODaUy2zJXZh9hMh4jM4g== X-Received: by 2002:a17:902:8d85:: with SMTP id v5-v6mr23607915plo.93.1529498745767; Wed, 20 Jun 2018 05:45:45 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:de2:0:0:0:0 with HTTP; Wed, 20 Jun 2018 05:45:25 -0700 (PDT) In-Reply-To: <20180620124157.gd5245o63dq6teul@wfg-t540p.sh.intel.com> References: <20180518121506.wilixxkznbtskw34@pathway.suse.cz> <20180524021451.GA23443@jagdpanzerIV> <20180620083126.GA477@jagdpanzerIV> <20180620090413.GA444@jagdpanzerIV> <20180620113731.y7apmqoh6ke6ar2v@wfg-t540p.sh.intel.com> <20180620124157.gd5245o63dq6teul@wfg-t540p.sh.intel.com> From: Dmitry Vyukov Date: Wed, 20 Jun 2018 14:45:25 +0200 Message-ID: Subject: Re: [PATCH] printk: inject caller information into the body of message To: Fengguang Wu Cc: Sergey Senozhatsky , Petr Mladek , Tetsuo Handa , Sergey Senozhatsky , syzkaller , Steven Rostedt , LKML , Linus Torvalds , Andrew Morton 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 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. > 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); >> } >> >