linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mukesh Ojha <mojha@codeaurora.org>
To: linux-kernel@vger.kernel.org
Cc: keescook@chromium.org, anton@enomsg.org, ccross@android.com,
	tony.luck@intel.com, Huang Yiwei <hyiwei@codeaurora.org>,
	Mukesh Ojha <mojha@codeaurora.org>
Subject: [RESEND PATCH v2 2/2] pstore: Add buffer start check during init
Date: Thu, 25 Feb 2021 21:30:17 +0530	[thread overview]
Message-ID: <1614268817-7596-2-git-send-email-mojha@codeaurora.org> (raw)
In-Reply-To: <1614268817-7596-1-git-send-email-mojha@codeaurora.org>

From: Huang Yiwei <hyiwei@codeaurora.org>

In a scenario of panic, when we use DRAM to store log instead
of persistant storage and during warm reset when we copy these
data outside of ram. Missing check on prz->start(write position)
can cause crash because it can be any value and can point outside
the mapped region. So add the start check to avoid.

Signed-off-by: Huang Yiwei <hyiwei@codeaurora.org>
Signed-off-by: Mukesh Ojha <mojha@codeaurora.org>
---
change in v2:
 - this is on top of first patchset.

 fs/pstore/ram_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index 0da012f..a15748a 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -514,7 +514,7 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig,
 	sig ^= PERSISTENT_RAM_SIG;
 
 	if (prz->buffer->sig == sig) {
-		if (buffer_size(prz) == 0) {
+		if (buffer_size(prz) == 0 && buffer_start(prz) == 0) {
 			pr_debug("found existing empty buffer\n");
 			return 0;
 		}
-- 
Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center,
Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project


  reply	other threads:[~2021-02-25 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-25 16:00 [RESEND PATCH v2 1/2] pstore: Add mem_type property DT parsing support Mukesh Ojha
2021-02-25 16:00 ` Mukesh Ojha [this message]
2021-03-17 22:20   ` [RESEND PATCH v2 2/2] pstore: Add buffer start check during init Kees Cook
2021-03-02  8:29 ` [RESEND PATCH v2 1/2] pstore: Add mem_type property DT parsing support Mukesh Ojha
2021-03-17 19:21   ` Mukesh Ojha
2021-03-17 22:31 ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1614268817-7596-2-git-send-email-mojha@codeaurora.org \
    --to=mojha@codeaurora.org \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=hyiwei@codeaurora.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).