Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2003372imu; Fri, 14 Dec 2018 04:20:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wq0DD9K+JREX/qKk/r1RiE9I26BsWL5S7caVImOAeuT7EHOA/bIFUM/NfmAfi3Te/6au3m X-Received: by 2002:a63:d547:: with SMTP id v7mr2468078pgi.339.1544790049205; Fri, 14 Dec 2018 04:20:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544790049; cv=none; d=google.com; s=arc-20160816; b=yuM3dtfbcxQ3azlSiFzUFg98Su/VnBEApcWiAdn1kx3GcS5fupBnFWblKe3nXBhAhu TJhS9cdXmYHn4oJOgkQLGJQu5BMhkC09m6ZGziY9tpSig4KFCbMVK3U28jHEYqcSJCh2 ISaDJMS9Ob6n4fCb9Xkspg5YVdxUiDODHKUl/xSTdxYzsTicjHeQ+OiwMC93bKfPBQCR UeBRm+6F30dgG11byxz0Wt5afdnp0Ae+yUogIx4X7Yvm+BcXsY54Dt+IjafI0m16hpxg 7SAfXX8l6wO6rNMSLBtLameSCNQZ/FZTADUz3eO8KrTvLM6owwahu/gMZWWLO7bI6bOR QZcA== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5hW8JcvN+l0M+uxX+5zo2iSbw9MT01QvgrirOVk1ONM=; b=JNb2YOeR++zEpoipk+OHXKeKCTR4/9WK7SFimhxUyRcko44eHvCfQ1LDwbQDpCYAp8 x9OASPuDEMykIK/MTHL7VX27fqWZ+lZ/8Iwrbb+cxKIocngTd4TjPkU44rljaYJxU5Kv xpfKBa4g28Mc9+OAzBYrYdoYFBaiQn3ln+97zflDzWb4E44Su7uUAKiQ7v/v2ESuCeHs okG3481rdDFwks2EBMqfEQG/ExGRTvoRkLm2Hk3Wc2O+eYDkEi7HC6DxQQP+G+vwaYiq IESOLy1D9XQ8XaqVZ93PfM5CicSsn4Y19Azm0CWqhA9cInQsCgE4BSrx8n7hj+Fzo3Lz d3oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KSb+XT0c; 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 62si3800569pgi.314.2018.12.14.04.20.29; Fri, 14 Dec 2018 04:20:49 -0800 (PST) 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=@kernel.org header.s=default header.b=KSb+XT0c; 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 S1730818AbeLNMTn (ORCPT + 99 others); Fri, 14 Dec 2018 07:19:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:35718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732612AbeLNMPl (ORCPT ); Fri, 14 Dec 2018 07:15:41 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4553D214AE; Fri, 14 Dec 2018 12:15:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789740; bh=t75Jcd4Wz8tnb2tPUBT/NfzroOV0f4XScYArbR+riSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KSb+XT0ciZjCZM6/nV6K15CJnz5H9tjZ5ELX4IUfL+xCzFT6K5cb4/K492vFSCAGr BEw4WqKzbpzZcAwbepqVzUwOR8+owzz8RcT8pPRNqvWDdSfq6SXPpTKuTmQVA6qUyF /KGeZkHAtuFRusqNIEgE+ml/28JzLvJcHcnj3DOo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stefan Hajnoczi , Namhyung Kim , Kees Cook , Sasha Levin Subject: [PATCH 4.4 39/88] pstore: Convert console write to use ->write_buf Date: Fri, 14 Dec 2018 13:00:13 +0100 Message-Id: <20181214115705.420157175@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115702.151309521@linuxfoundation.org> References: <20181214115702.151309521@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 70ad35db3321a6d129245979de4ac9d06eed897c ] Maybe I'm missing something, but I don't know why it needs to copy the input buffer to psinfo->buf and then write. Instead we can write the input buffer directly. The only implementation that supports console message (i.e. ramoops) already does it for ftrace messages. For the upcoming virtio backend driver, it needs to protect psinfo->buf overwritten from console messages. If it could use ->write_buf method instead of ->write, the problem will be solved easily. Cc: Stefan Hajnoczi Signed-off-by: Namhyung Kim Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- fs/pstore/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 588461bb2dd4..e97e7d74e134 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -392,8 +392,8 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c) } else { spin_lock_irqsave(&psinfo->buf_lock, flags); } - memcpy(psinfo->buf, s, c); - psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, 0, 0, c, psinfo); + psinfo->write_buf(PSTORE_TYPE_CONSOLE, 0, &id, 0, + s, 0, c, psinfo); spin_unlock_irqrestore(&psinfo->buf_lock, flags); s += c; c = e - s; -- 2.19.1