Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2972479imm; Sun, 1 Jul 2018 09:27:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJAoHEXlXenl3Eama1lDuqT+wVKX9hSFaAv0pMadSsqXpnpu8sH5wq9rDSLqdzMCZdFqjQ X-Received: by 2002:a63:3c4a:: with SMTP id i10-v6mr18790716pgn.415.1530462441105; Sun, 01 Jul 2018 09:27:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530462441; cv=none; d=google.com; s=arc-20160816; b=VLrlEUqmm5fYOTq9SkJpl/THmkdcODSKZGmJ0S2aL4ayTLcnjxc1AQWgMKJuSTmw4X uLfKSRtbMbc3RlgLLwreaZJDTuViC0ddvPhw2MG8tHG7olyJr8gM3Z0ZHD1mbgmDlFGo gIP2U6P9iqct8gSfuZnNUFC2A76acHDt5tXvjsmbw0uTXQlYYWtEGyf1m/Ju0YZ9QT3O iEtImtyxslzLhnQ6+Ru4yX22pAiKHtpbOnVgO7S3I5HFA2uvzUnWY8381ftSoJihnMrY bVbX03jRfwsedHQ6/KLy8TgiEy4wesdMPNodovFruxbSbEBqwvK9SapKl8flGyGPyxMO LPdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=py8uHv72NC+Q2I5jAyl6JTGZSiilww0n+UCBk4ABlQA=; b=R5ToRLRkrfdUSzm66LdWZHi4AONhoYiEW7RvCSzL4gieW6kTDauM/OcAPZchCsxWzF L2kyQxTlKzYZWrM/8qoXiwmyfinhRPgvpjesxnafaGOYDr/4rtkia6vfOP75gvJEuG6Y edAKHeSgW9WCB9KIBFisVoa8bJGQ1Ieip0/tmpKnHsvEWVgst1M7z+oQmBbjE3okuoSv rIr48dm1WNW7azO7t/Dj3/xFuaOuklvPE5g2xWCXyMNR7DnjV+evpMKUweWIw0Rlkfkh dt+E8aChVMu8oUQ9euzKk6w0W6EchLLU10sWSSXkomTIxdS7xCBxeZDzVeM+4EI72oxm C0DQ== 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 n24-v6si3176606pgb.665.2018.07.01.09.27.07; Sun, 01 Jul 2018 09:27:21 -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 S965344AbeGAQ0a (ORCPT + 99 others); Sun, 1 Jul 2018 12:26:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33852 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932678AbeGAQ0V (ORCPT ); Sun, 1 Jul 2018 12:26:21 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 80A64ACD; Sun, 1 Jul 2018 16:26:20 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Steven Rostedt , dvyukov@google.com, syzkaller@googlegroups.com, fengguang.wu@intel.com, Tetsuo Handa , Sergey Senozhatsky , Petr Mladek Subject: [PATCH 4.9 049/101] printk: fix possible reuse of va_list variable Date: Sun, 1 Jul 2018 18:21:35 +0200 Message-Id: <20180701160759.111046056@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa commit 988a35f8da1dec5a8cd2788054d1e717be61bf25 upstream. I noticed that there is a possibility that printk_safe_log_store() causes kernel oops because "args" parameter is passed to vsnprintf() again when atomic_cmpxchg() detected that we raced. Fix this by using va_copy(). Link: http://lkml.kernel.org/r/201805112002.GIF21216.OFVHFOMLJtQFSO@I-love.SAKURA.ne.jp Cc: Peter Zijlstra Cc: Steven Rostedt Cc: dvyukov@google.com Cc: syzkaller@googlegroups.com Cc: fengguang.wu@intel.com Cc: linux-kernel@vger.kernel.org Signed-off-by: Tetsuo Handa Fixes: 42a0bb3f71383b45 ("printk/nmi: generic solution for safe printk in NMI") Cc: 4.7+ # v4.7+ Reviewed-by: Sergey Senozhatsky Signed-off-by: Petr Mladek Signed-off-by: Greg Kroah-Hartman --- kernel/printk/nmi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/kernel/printk/nmi.c +++ b/kernel/printk/nmi.c @@ -63,6 +63,7 @@ static int vprintk_nmi(const char *fmt, struct nmi_seq_buf *s = this_cpu_ptr(&nmi_print_seq); int add = 0; size_t len; + va_list ap; again: len = atomic_read(&s->len); @@ -79,7 +80,9 @@ again: if (!len) smp_rmb(); - add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, args); + va_copy(ap, args); + add = vsnprintf(s->buffer + len, sizeof(s->buffer) - len, fmt, ap); + va_end(ap); /* * Do it once again if the buffer has been flushed in the meantime.