Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3153855imm; Thu, 17 May 2018 04:23:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqTTc9yVmMn0Qk70vdsKQt3aoyYw4astksSpqiSMVPipG7hbNVQBGjiZVkJq1vUlJ/NxkzT X-Received: by 2002:a62:cf43:: with SMTP id b64-v6mr4783442pfg.248.1526556223465; Thu, 17 May 2018 04:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526556223; cv=none; d=google.com; s=arc-20160816; b=ahCrGWuDJW4e/hu7KKTbAgmiFGyfkmgNSuz3OZLD0Q/uthHB/Gfae7y6QJhJNzmiAP otYYWgkl7N+qZDQgZrl9AGSKhRlahNmN6gscaymlJBCgO3Ka7k/otQJS0oaTSDQS0h54 iuaxNSiZYNybVh2gdHWxtBjhJTFkPoxLrvqYV/DcBbBa55dTTzYiI18D+m8FQf/twHoL llvSozpkrZVjjo6sWQ7GWuwMC50f+GEGMfVCUL3LFcY0ZIe+alXjESscil5GqIYBtRxb Y+JV8AIdLcpCYmmFTMxvroOEckKu8rrGZ+ystzRrT/kmxAw6QMBmUIuWONmsfGfl966H yHIA== 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:dkim-signature:arc-authentication-results; bh=vrZ8EBVkcpkM/Poaa9TUeQY7n2psiXuQ2hYzEqWrhUI=; b=beYTgh0pVP7ICk2IT+2EOtQzFIv4+eDcssdV6/XkbLMHHw94rpLDRwbW5YnfgjaSft wXUeEQLRD1Mc7zPs7m1x4t7aOXxMfPhAXnPurATpJNAOffdgWsemJ7Lk4SacBow7vWZV PuuON61mZhb4zKXeMWJPK4NqZp0VlmhjvdHsM5YtHX+rbwguEu5HLJw9EXUj0MopTYfl SiIHA6mgQdAlKXs4QeK0HBtLLUeGMDdlJ1KfT+e/0KUKWmsFUMhLhW7rOWC4wZimJ52r x2ofwPkoC8jD+D0iBf7p3nTRL6QKoqs7ciif7J0xfrUyyYy2O68oNy8pRkTeeqNKM4Wv huGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LHwTvEQ0; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3-v6si4785661pfh.101.2018.05.17.04.23.29; Thu, 17 May 2018 04:23:43 -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=@gmail.com header.s=20161025 header.b=LHwTvEQ0; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbeEQLVm (ORCPT + 99 others); Thu, 17 May 2018 07:21:42 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:41534 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752168AbeEQLVk (ORCPT ); Thu, 17 May 2018 07:21:40 -0400 Received: by mail-pf0-f193.google.com with SMTP id v63-v6so1946158pfk.8 for ; Thu, 17 May 2018 04:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=vrZ8EBVkcpkM/Poaa9TUeQY7n2psiXuQ2hYzEqWrhUI=; b=LHwTvEQ0INQS7j71Genwta14xsCON1SCgHFChJQPOLff0kZ3E80HEBPh39hC1qtKhr ZeXYaVO+djpMqn6MC1IMqjMNflNYA/gX0fJpFSdZov+dGNNY5qABtewGIGrqAPNmpyYi KXNGs/ouPEdN3QCgDCrGGjGwPuVYXz2tKAgMJhISUpp3VPTYlCsD41x4P0pgephbUHmT tirwaWanKI4SLJEAQt5fbPEcAzIu9kOZgkf0IXzhpQrAC5fVC0pbdDg4YVnZDceT7bMz XehdcwpdxX1Jmn9INTYgEFCyZZfsgyo8fpIOohjTHF5cmvE5bBYXlciZYQGOP7RuAkaP as3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=vrZ8EBVkcpkM/Poaa9TUeQY7n2psiXuQ2hYzEqWrhUI=; b=IRTHG02H2PmJd/X3ijD/lXXvQ6dMbXEcYLqJ34FymlOWCbj71aFV99avCxuwC3lGLP mlBSSFO7oJCy6/j02T1qjaUVAbh3oGsUNnRjRXDiLTbBPljuI4FsUTJFiX0glOKDLnTm kvlMJf0q1xHPFr49dIwyu/fbmWuwNDYpFkBb5wLzb5oUBEa47tuwiSQIQE0KgaWeW1QO AOdtILPcKnzuqfCZR0CXgVeILmzlWyhqx9fdaZEM2xi169dviTo1jluqh2WNu0UzoieX 4uBNYSAFGc1BTsH74iHdly3meyBfKm17EFtwmPhBJdMDu79JTI9b164zms/hdaNfhHqS l5SA== X-Gm-Message-State: ALKqPwcB39qSb75kzyTloYAzCA1yTuvtFrZffgFRSFe25cDW1j/FdqeN z8G9Xfz7ZBkvT9sRB5JqKq0= X-Received: by 2002:a65:5183:: with SMTP id h3-v6mr3757750pgq.58.1526556100155; Thu, 17 May 2018 04:21:40 -0700 (PDT) Received: from localhost ([175.223.26.113]) by smtp.gmail.com with ESMTPSA id b72-v6sm10501314pfm.69.2018.05.17.04.21.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 04:21:38 -0700 (PDT) Date: Thu, 17 May 2018 20:21:35 +0900 From: Sergey Senozhatsky To: Tetsuo Handa Cc: sergey.senozhatsky.work@gmail.com, dvyukov@google.com, pmladek@suse.com, sergey.senozhatsky@gmail.com, syzkaller@googlegroups.com, rostedt@goodmis.org, fengguang.wu@intel.com, linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org Subject: Re: [PATCH] printk: inject caller information into the body of message Message-ID: <20180517112135.GB20796@jagdpanzerIV> References: <20180511014515.GA895@jagdpanzerIV> <201805110238.w4B2cIGH079602@www262.sakura.ne.jp> <20180511062151.GA18160@jagdpanzerIV> <20180511095004.GA6575@jagdpanzerIV> <201805112058.AAB05258.HJQFFOMFOVtOSL@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201805112058.AAB05258.HJQFFOMFOVtOSL@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (05/11/18 20:58), Tetsuo Handa wrote: [..] > - if (nr_ext_console_drivers || cont.len + len > sizeof(cont.buf)) { > + if (nr_ext_console_drivers) { > + cont_flush(); > + return false; > + } > + > + /* Inject before memcpy() in order to avoid overflow. */ > + if (!cont.len) > + text = printk_inject_caller_info(text, &len); > + > + /* If the line gets too long, split it up in separate records. */ > + if (cont.len + len > sizeof(cont.buf)) { > cont_flush(); > return false; > } > @@ -1820,6 +1860,9 @@ static size_t log_output(int facility, int level, enum log_flags lflags, const c > return text_len; > } > > + /* Inject caller info. */ > + text = printk_inject_caller_info(text, &text_len); > + > /* Store it in the record log */ > return log_store(facility, level, lflags, 0, dict, dictlen, text, text_len); > } [..] I think this is slightly intrusive. I understand that you want to avoid struct printk_log modification, let's try to see if we have any other options. Dunno... For instance, can we store context tracking info as a extended record data? We have that dict/dict_len thing. So may we can store tracking info there? Extended records will appear on the serial console /* if console supports extended data */ or can be read in via devkmsg_read(). Any other options? > #include "internal.h" > > @@ -83,6 +84,17 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s, [..] > len = atomic_read(&s->len); > @@ -102,7 +114,15 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s, > smp_rmb(); > > va_copy(ap, args); > - add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, ap); > + if (printk_caller_info) { > + struct va_format vaf = { .fmt = fmt, .va = &ap }; > + > + add = scnprintf(s->buffer + len, sizeof(s->buffer) - len, > + "(%c%u) %pV", c, v, &vaf); > + } else { > + add = vscnprintf(s->buffer + len, sizeof(s->buffer) - len, > + fmt, ap); > + } A bit of a silly question - do we want to modify printk_safe at this point? With this implementation printk_safe entries will have two context info-s attached: one from original printk_safe_log_store and another one from printk_safe_flush->log_store. I suspect that adding context info in printk_safe_log_store is, probably, not really needed. We flush printk_safe from irq work on the CPU that issued unsafe printk, so part of the context info will be valid if you append context info only in printk log_store - at least the correct smp_processor_id. -ss