From: Namhyung Kim <namhyung@kernel.org>
To: Kees Cook <keescook@chromium.org>
Cc: Anton Vorontsov <anton@enomsg.org>,
Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
LKML <linux-kernel@vger.kernel.org>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [RFC/PATCH 1/2] pstore: Protect unlink with read_mutex
Date: Wed, 19 Oct 2016 10:23:40 +0900 [thread overview]
Message-ID: <20161019012341.8032-1-namhyung@kernel.org> (raw)
When update_ms is set, pstore_get_records() will be called when there's
a new entry. But unlink can be called at the same time and might
contend with the open-read-close loop. Depending on the implementation
of platform driver, it may be safe or not. But I think it'd be better
to protect those race in the first place.
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
fs/pstore/inode.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c
index 1781dc50762e..75728dfae0a6 100644
--- a/fs/pstore/inode.c
+++ b/fs/pstore/inode.c
@@ -197,11 +197,14 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
if (err)
return err;
- if (p->psi->erase)
+ if (p->psi->erase) {
+ mutex_lock(&p->psi->read_mutex);
p->psi->erase(p->type, p->id, p->count,
d_inode(dentry)->i_ctime, p->psi);
- else
+ mutex_unlock(&p->psi->read_mutex);
+ } else {
return -EPERM;
+ }
return simple_unlink(dir, dentry);
}
--
2.9.3
next reply other threads:[~2016-10-19 1:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-19 1:23 Namhyung Kim [this message]
2016-10-19 1:23 ` [RFC/PATCH 2/2] pstore: Convert console write to use ->write_buf Namhyung Kim
2016-11-15 23:21 ` Kees Cook
2016-11-15 23:20 ` [RFC/PATCH 1/2] pstore: Protect unlink with read_mutex 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=20161019012341.8032-1-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stefanha@redhat.com \
--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
Powered by JetHome