Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp591957imm; Sat, 7 Jul 2018 04:13:09 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdf55kA1tXp1pihVY1psHezWURYLC0npERxUI8ytJnj884I6ATo7YYnZrZGHN8ngvSrvnQ9 X-Received: by 2002:a62:283:: with SMTP id 125-v6mr13961174pfc.51.1530961989056; Sat, 07 Jul 2018 04:13:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530961989; cv=none; d=google.com; s=arc-20160816; b=JTpyASP8wglw3pUBeE0ax3NUs1tkFL5qistjPJbnxJc/E+9Mq3hEoLjNq2HybJvlp6 zb/NK9HNnS3KG7ti75ilyBWvnBVRJwTtt+Um4gje3K046ZLSl+adoeGWKYn74pSIXw6B hcSRYgu+oe3p7s6jRQccfleUxXmeRQ3kvZ1sQwVLCZTr7BEy9AwXm6j8lf6KmGLMa6IU rshT+eIsfqwOu5FYVEc2uhFQxTX2CqLx/2revu+KS/0/S2nNJxY8Dm7f2CG5HgsWwEzs 9FFVvw/VeTabmcPNP3PS0KsVFisFmuVzy03Sghlb0lU79XnO4H96JWm4B5lmsjRb8IUS A/fA== 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=kdg4a+WsVPAtqFCPEukRpYFeGHjPlr8YWjCZLrKI2BE=; b=T1ZcwDRqR5qqKysSa+92V/WLKS4H4FOmWSr9iCvc2qZWxdjnxuohPT15eWEG8KaJ1U 1H5byVlMo7wgAjpYh2zwJX4a6ZGKOtIm3zqxN37za0bwkJISpkS6UkpaYx3lKRaEGRwK jaTZd+T/Il2QGENfsGZLmzUHsdY5I983JH90VhGjJZKBwFHcFOoiGMj+cwiOdY53dkej 0FLL3iyO5LLfVRtx1/LoNUWyY30BiC0P799nJTxoylVVXL7B2fQvPUuYuxl+GuDyGjJ/ 4UQVN6Fey+wjgBjy/D+0G4X+rfuSW1/AQ9pnNB+wpLNC8UK0iMgOiLOjDutUQUOEuysb prvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=HRrzGfuz; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e36-v6si9815027pge.507.2018.07.07.04.12.54; Sat, 07 Jul 2018 04:13:09 -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=fail header.i=@gmail.com header.s=20161025 header.b=HRrzGfuz; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753864AbeGGLMP (ORCPT + 99 others); Sat, 7 Jul 2018 07:12:15 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35629 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752825AbeGGLMO (ORCPT ); Sat, 7 Jul 2018 07:12:14 -0400 Received: by mail-wm0-f68.google.com with SMTP id v3-v6so12939401wmh.0 for ; Sat, 07 Jul 2018 04:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kdg4a+WsVPAtqFCPEukRpYFeGHjPlr8YWjCZLrKI2BE=; b=HRrzGfuzuSgU60/RfyblRHO3zcuLDlGsQVoYG4V+sM6zAP4rfTinFYlfqW3bfH8ebt PHHnQdF+A5L0A+AkZ7wyBHret5QWaIjFYKYGDmWZklLU25LEgJu2flncfHML+5kJwHTA ELLtTyHlXV+HyfWBuqsfMC8JBFxqi/rv+sU+GbrZ2jA1HBEXVAfPrGSlBP/U+eEazpAM YdTpZAlU8WhzQmKbZr4ehZLx6i+Qn9Se0eEdOPMxE+mq5iyrph9GUSmdY5qeRlYTRmA4 jc0pNi//Ect811LtBJJfiS0hNAj6cGttDtgRgIEkUOvj32K9uX2T1HYyQNxLFV01U8fY ySkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=kdg4a+WsVPAtqFCPEukRpYFeGHjPlr8YWjCZLrKI2BE=; b=jwHcvJh2L0ZLOz3z8TwqRFZPXXGmJAcrWzHplt7l5uFXC7QwuIMeX9zRC6WuIzr3W1 O4UMjNXsRVevLvXR0k5LlV5FQsaj9wD6TTa3+We3XQAqA//iJNdM4zYqzJ70kINcc6YS WP6lMeseTqzXsdqnBpUVzKg4zaPeKJ9KsazJZGJ+MX2xfkj72ztiXaKz4RQdove/ad1X vklutV2ZQBSSucpjohcAx+gHlZCfTrKYr7+6wEmyOOcbhEUb4k/ve5/kNSzHCNkOGRq1 kqSz0D898whpQGRqWzbQiul0u6JqdXc8xXZrQy3WLD5lYAx8KeaXd80Hzc1O+miRhhY/ 8VQg== X-Gm-Message-State: APt69E3jUTzA8NNOcb/vIdan7pjjHVIagaXXSohAjwuYXELLl49MZ26g KynbXInrlLl6G8nqiO3Oq98= X-Received: by 2002:a1c:228b:: with SMTP id i133-v6mr8923033wmi.69.1530961932864; Sat, 07 Jul 2018 04:12:12 -0700 (PDT) Received: from gmail.com (2E8B0CD5.catv.pool.telekom.hu. [46.139.12.213]) by smtp.gmail.com with ESMTPSA id 14-v6sm18254481wmo.37.2018.07.07.04.12.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 07 Jul 2018 04:12:11 -0700 (PDT) Date: Sat, 7 Jul 2018 13:12:09 +0200 From: Ingo Molnar To: Tetsuo Handa Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, Tetsuo Handa , Andy Lutomirski , Borislav Petkov , Josh Poimboeuf , Linus Torvalds , Peter Zijlstra , Thomas Gleixner Subject: Re: [PATCH] x86: Avoid pr_cont() in show_opcodes() Message-ID: <20180707111209.GA27768@gmail.com> References: <1530943625-3288-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1530943625-3288-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Tetsuo Handa wrote: > 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); Does this change the output? - If yes, could you show the before/after output in the changelog, - If not (i.e. if only the number of printk calls is changed, the output is the same), could you say so in the changelog? Also, 3*OPCODE_BUFSIZE+2+1 is 195 bytes - isn't that a bit too much on-stack footprint? Thanks, Ingo