mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yichun Zhang (agentzh)" <yichun@openresty.com>
To: linux-fsdevel@vger.kernel.org
Cc: "Yichun Zhang (agentzh)" <yichun@openresty.com>,
	Colin Ian King <colin.i.king@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jens Axboe <axboe@kernel.dk>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] relay: replay_file_open(): NULL ptr deref in CPU hotplugs
Date: Thu,  8 Sep 2022 14:17:30 -0700	[thread overview]
Message-ID: <20220908211731.11534-1-yichun@openresty.com> (raw)

CPU hotplug may introduce race conditions. We reproduced kernel panics
due to this NULL ptr deref error when doing frequent random CPU hotplugs
in a KVM guest.

Signed-off-by: Yichun Zhang (agentzh) <yichun@openresty.com>
---
 kernel/relay.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/relay.c b/kernel/relay.c
index 6a611e779e95..2db69fd527d1 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -816,6 +816,9 @@ EXPORT_SYMBOL_GPL(relay_flush);
 static int relay_file_open(struct inode *inode, struct file *filp)
 {
 	struct rchan_buf *buf = inode->i_private;
+	if (unlikely(buf == NULL))
+		return -ENOENT;
+
 	kref_get(&buf->kref);
 	filp->private_data = buf;
 
-- 
2.17.2


             reply	other threads:[~2022-09-08 21:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-08 21:17 Yichun Zhang (agentzh) [this message]
2022-09-08 21:19 ` Jens Axboe

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=20220908211731.11534-1-yichun@openresty.com \
    --to=yichun@openresty.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=colin.i.king@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®