Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp393002imm; Fri, 6 Jul 2018 23:10:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd/jexyBLhtrKZEYBH1Mm69JdLRzYkrvbBFuijii/fF2Y2rHlScl+eOAKpMydhCUN3NYrAJ X-Received: by 2002:a62:8917:: with SMTP id v23-v6mr13321138pfd.127.1530943822589; Fri, 06 Jul 2018 23:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530943822; cv=none; d=google.com; s=arc-20160816; b=x4XRPwVIAF02/BXyuLKdy06+mdaeSW+gzHU8e3AtDjOJlnyUquJkayXElvafYiRQOK xtgtLHZXR7h+vJ55OR4/hfrm2yzoCIBpZRwNYxUsAYhkA5n8JZgCvJcwriSPkurHLvxk 3LvfD5qJ1G8jPc0pBmMQFLDbXa1STOhR9c8voqVjA3ai6rvUoim8k2ynovEGt8e/3IN4 LWvdAyDG3mHfEKgxdMGBDhyD3ETLJjCbIerFy7jJksVoyN/WG64j33cicTvoGPyXRpQJ HFF1OeJO+GlEfHLcO6DhFNqUOLreOzQYib+BqZ7rVfIm1njQru53zEgHVypgkbyDwrtI 4eaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=vHQTcxq93R8qeHoyRdAckO4z0i/t/5tsQhJ6YpqwM38=; b=Q6W5SQf+LeKdpAG0Fr0dbXC0Bn/SIduuEn7BSqKM1YUwr4IhyXCnwxU00FQrexHvwm WcFiwM8ZeJID2wq/K/ncDHMG+eH/e0gRgpBfBx+uRdnZxWP0TIDQe8bHa3yDSdez6bHx Kf9MBZtDkCOFWYG4R+kDZEU+iLArJX5c4v320lIdOHL4wIrqHqVJCrduOtPCyXl3qbwu Xq6rn5FUBFCCBa9BsiUcWXWd1fnFMu6mXgf5zQZmPoqHfFsYUJtCu6SDj30Xgq5IPmqd mQWqeu7lSsg1GOGDHo3mRvPF2AnOHMA4EyEHmC+TkiiiC/G7Uert3hJa06AuoHZSttYD C9Hg== 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 g131-v6si9317332pgc.204.2018.07.06.23.10.06; Fri, 06 Jul 2018 23:10:22 -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 S1751517AbeGGGJ3 (ORCPT + 99 others); Sat, 7 Jul 2018 02:09:29 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:52092 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750872AbeGGGJ2 (ORCPT ); Sat, 7 Jul 2018 02:09:28 -0400 Received: from fsav301.sakura.ne.jp (fsav301.sakura.ne.jp [153.120.85.132]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w6769QUZ034923; Sat, 7 Jul 2018 15:09:26 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav301.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp); Sat, 07 Jul 2018 15:09:26 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w67679db034201 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 7 Jul 2018 15:09:25 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: mingo@redhat.com Cc: linux-kernel@vger.kernel.org, Tetsuo Handa , Andy Lutomirski , Borislav Petkov , Josh Poimboeuf , Linus Torvalds , Peter Zijlstra , Thomas Gleixner Subject: [PATCH] x86: Avoid pr_cont() in show_opcodes() Date: Sat, 7 Jul 2018 15:07:05 +0900 Message-Id: <1530943625-3288-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tetsuo Handa Since syzbot is confused by concurrent printk() messages [1], this patch changes show_opcodes() to use snprintf(). 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c index 666a284..bb47426 100644 --- a/arch/x86/kernel/dumpstack.c +++ b/arch/x86/kernel/dumpstack.c @@ -97,22 +97,24 @@ void show_opcodes(u8 *rip, const char *loglvl) u8 opcodes[OPCODE_BUFSIZE]; u8 *ip; int i; - - printk("%sCode: ", loglvl); + int pos = 0; + char buf[(3 * OPCODE_BUFSIZE + 2) + 1]; 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) -- 2.7.4