Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2296686imm; Mon, 16 Jul 2018 05:48:57 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe0YzRgqkE3hHbTRCua6KOyLik3gmrx1lG8Jr1s5fY7L01Q80THlp4q8Z26669/Jy0zwFGp X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr16849076pln.290.1531745337366; Mon, 16 Jul 2018 05:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531745337; cv=none; d=google.com; s=arc-20160816; b=dJSuYKJT6se7HEvFQVG/llaRLgCbURWp5u4kW197LUgYb9gU7JAOqJ82dfOzbs9HFy 00RMQ7N63bs0dnW+LyKsX2z/M3Fou0cU/sxiHujSUXjs9EM9629hrZaaBsjiZBxhKvyP jvMYSAYuwuE6+lnD7e3pczze/LDWzr8NhFMOyCpbpy4ixJZ/FEWMJt+0hd+KZ7NpJ/nn yYoeXeAHrSU2op2ncMlYPpCN0/le+IpA9mS8gT+fkRcHkXMc887Tk+Z9M5R0WNFS53Rd 8+c9VpJO59LV2MA/Sndj2O5wfhUv8WT4eb0yXw28/DW4gaqfd6pZOtmU4vUh1Ie4RS6j um0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:arc-authentication-results; bh=cMOt7fmoEKbIKn3d6c5L+TbnwpNE+o26/aG/ycAZ++Y=; b=zPSnOtEoZmB0d3K9qQQN9SDte194z/3rghjw5FF/oSoVsKeQ29DFBDtXV6HU1JE3uM uIPrjJYuowq6cS+KHAxeomxHcpbnKmH3mNLC6dOg586uu4xmFhZZ9+JkKPYtP/0u8hT0 iCcY2UDL7c5wAcJ2ffAVZViTs2fGWTVOGajtGlSWyFdB0li6aeQdRk9lhSLg7mOx0sFs p2/UIq81ukGY33mm93MOJRtch6MKd2WoKZOElUWhXWb4PP0IVnrWeGuGQNwirUbkWBzM UmASE6XHLEdbh/HIHysItUmdcjDbo7Oibulvg/1AF7atBifdJQ7LudrgKqSXPeneKACx pClQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73-v6si29168232pgh.343.2018.07.16.05.48.42; Mon, 16 Jul 2018 05:48:57 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729854AbeGPNOr (ORCPT + 99 others); Mon, 16 Jul 2018 09:14:47 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:63437 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728687AbeGPNOr (ORCPT ); Mon, 16 Jul 2018 09:14:47 -0400 Received: from fsav404.sakura.ne.jp (fsav404.sakura.ne.jp [133.242.250.103]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w6GClQV0059301; Mon, 16 Jul 2018 21:47:26 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav404.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav404.sakura.ne.jp); Mon, 16 Jul 2018 21:47:26 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav404.sakura.ne.jp) Received: from [192.168.1.8] (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w6GClLQ6059216 (version=TLSv1.2 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Jul 2018 21:47:26 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH] x86: Avoid pr_cont() in show_opcodes() From: Tetsuo Handa To: Ingo Molnar Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, Andy Lutomirski , Borislav Petkov , Josh Poimboeuf , Linus Torvalds , Peter Zijlstra , Thomas Gleixner References: <1530943625-3288-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> <20180707111209.GA27768@gmail.com> Message-ID: <77efbc52-60d0-c41b-640c-dfd0577192a2@i-love.sakura.ne.jp> Date: Mon, 16 Jul 2018 21:47:22 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ingo, is this patch acceptable? On 2018/07/07 22:54, Tetsuo Handa wrote: >From 61752cef56fad2a910f6bfd277e1b9b028aeab43 Mon Sep 17 00:00:00 2001 > From: Tetsuo Handa > Date: Sat, 7 Jul 2018 22:45:30 +0900 > Subject: [PATCH v2] x86: Avoid pr_cont() in show_opcodes() > > Since syzbot is confused by concurrent printk() messages [1], this patch > changes show_opcodes() to use snprintf(). By this change, the Code: line > will always be printed as one line even if multiple threads concurrently > called printk(). > > To save on-stack footprint, this patch shares opcodes[] and buf[] because > we sequentially reads from opcodes[] and sequentially writes to buf[]. > > When we start adding prefix to each line of printk() output, > we will be able to handle concurrent printk() messages. > > [1] https://syzkaller.appspot.com/text?tag=CrashReport&x=139d342c400000 > > Signed-off-by: Tetsuo Handa > Cc: Borislav Petkov > Cc: Thomas Gleixner > Cc: Peter Zijlstra > Cc: Josh Poimboeuf > Cc: Linus Torvalds > Cc: Andy Lutomirski > --- > arch/x86/kernel/dumpstack.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c > index 666a284..6408123 100644 > --- a/arch/x86/kernel/dumpstack.c > +++ b/arch/x86/kernel/dumpstack.c > @@ -94,25 +94,27 @@ static void printk_stack_address(unsigned long address, int reliable, > void show_opcodes(u8 *rip, const char *loglvl) > { > unsigned int code_prologue = OPCODE_BUFSIZE * 2 / 3; > - u8 opcodes[OPCODE_BUFSIZE]; > u8 *ip; > int i; > - > - printk("%sCode: ", loglvl); > + int pos = 0; > + char buf[(3 * OPCODE_BUFSIZE + 2) + 1]; > + u8 *opcodes = (u8 *) buf + sizeof(buf) - OPCODE_BUFSIZE; > > ip = (u8 *)rip - code_prologue; > if (probe_kernel_read(opcodes, ip, OPCODE_BUFSIZE)) { > - pr_cont("Bad RIP value.\n"); > + printk("%sCode: Bad RIP value.\n", loglvl); > return; > } > > for (i = 0; i < OPCODE_BUFSIZE; i++, ip++) { > if (ip == rip) > - pr_cont("<%02x> ", opcodes[i]); > + pos += snprintf(buf + pos, sizeof(buf) - pos, > + "<%02x> ", opcodes[i]); > else > - pr_cont("%02x ", opcodes[i]); > + pos += snprintf(buf + pos, sizeof(buf) - pos, > + "%02x ", opcodes[i]); > } > - pr_cont("\n"); > + printk("%sCode: %s\n", loglvl, buf); > } > > void show_ip(struct pt_regs *regs, const char *loglvl) >