From: Ninad Palsule <ninad@linux.ibm.com>
To: jk@ozlabs.org, joel@jms.id.au, alistair@popple.id.au,
eajames@linux.ibm.com, linux-fsi@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Cc: Ninad Palsule <ninad@linux.ibm.com>
Subject: [PATCH v1 2/2] fsi: sbefifo: Validate pending user write
Date: Thu, 7 Sep 2023 17:10:16 -0500 [thread overview]
Message-ID: <20230907221016.2978802-3-ninad@linux.ibm.com> (raw)
In-Reply-To: <20230907221016.2978802-1-ninad@linux.ibm.com>
This commit fails user write operation if previous write operation is
still pending.
As per the driver design write operation only prepares the buffer, the
actual FSI write is performed on next read operation. so if buggy
application sends two back to back writes or two parallel writes then
that could cause memory leak.
Signed-off-by: Ninad Palsule <ninad@linux.ibm.com>
---
drivers/fsi/fsi-sbefifo.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c
index b771dff27f7f..824e2a921a25 100644
--- a/drivers/fsi/fsi-sbefifo.c
+++ b/drivers/fsi/fsi-sbefifo.c
@@ -874,6 +874,12 @@ static ssize_t sbefifo_user_write(struct file *file, const char __user *buf,
mutex_lock(&user->file_lock);
+ /* Previous write is still in progress */
+ if (user->pending_cmd) {
+ mutex_unlock(&user->file_lock);
+ return -EALREADY;
+ }
+
/* Can we use the pre-allocate buffer ? If not, allocate */
if (len <= PAGE_SIZE)
user->pending_cmd = user->cmd_page;
--
2.39.2
next prev parent reply other threads:[~2023-09-07 22:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 22:10 [PATCH v1 0/2] fsi: sbefifo: fixes Ninad Palsule
2023-09-07 22:10 ` [PATCH v1 1/2] fsi: sbefifo: Remove write's max command length Ninad Palsule
2023-09-11 6:03 ` Joel Stanley
2023-09-11 22:42 ` Ninad Palsule
2023-09-07 22:10 ` Ninad Palsule [this message]
2023-09-11 5:52 ` [PATCH v1 2/2] fsi: sbefifo: Validate pending user write Joel Stanley
2023-09-11 22:40 ` Ninad Palsule
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=20230907221016.2978802-3-ninad@linux.ibm.com \
--to=ninad@linux.ibm.com \
--cc=alistair@popple.id.au \
--cc=eajames@linux.ibm.com \
--cc=jk@ozlabs.org \
--cc=joel@jms.id.au \
--cc=linux-fsi@lists.ozlabs.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