From: Dan Carpenter <dan.carpenter@oracle.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sun Peng <sun_peng@topsec.com.cn>
Cc: Jiri Slaby <jslaby@suse.com>,
linux-kernel@vger.kernel.org, security@kernel.org,
Tony Lindgren <tony@atomide.com>,
Lars Poeschel <poeschel@lemonage.de>,
Sascha Hauer <s.hauer@pengutronix.de>
Subject: [PATCH 2/4] tty: n_gsm: Prevent a potential use after free
Date: Thu, 26 Apr 2018 08:53:21 +0300 [thread overview]
Message-ID: <20180426055321.GA15363@mwanda> (raw)
In-Reply-To: <20180420083028.7fq3hw2mjjd7nrra@mwanda>
We're freeing the gsm->dlci[] array elements but leaving the freed
pointers hanging around.
My concern here is if we use the ioctl to change the config, it triggers
a restart in gsmld_config(). In that case, we would only reset the
first ->dlci[0] element and not the others so it does look to me like a
possible use after free.
Reported-by: Sun Peng <sun_peng@topsec.com.cn>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index cc7f68814200..1f2fd9e76fe0 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -2075,9 +2075,11 @@ static void gsm_cleanup_mux(struct gsm_mux *gsm)
/* Free up any link layer users */
mutex_lock(&gsm->mutex);
- for (i = 0; i < NUM_DLCI; i++)
+ for (i = 0; i < NUM_DLCI; i++) {
if (gsm->dlci[i])
gsm_dlci_release(gsm->dlci[i]);
+ gsm->dlci[i] = NULL;
+ }
mutex_unlock(&gsm->mutex);
/* Now wipe the queues */
list_for_each_entry_safe(txq, ntxq, &gsm->tx_list, list)
next prev parent reply other threads:[~2018-04-26 5:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180420083028.7fq3hw2mjjd7nrra@mwanda>
2018-04-26 5:52 ` [PATCH 1/4] tty: n_gsm: add some locking around gsm_mux[] Dan Carpenter
2018-04-26 9:27 ` Dan Carpenter
2018-04-26 5:53 ` Dan Carpenter [this message]
2018-04-27 18:50 ` [PATCH 2/4] tty: n_gsm: Prevent a potential use after free Tony Lindgren
2018-04-26 5:53 ` [PATCH 3/4] tty: n_gsm: Remove an unused lock Dan Carpenter
2018-04-26 5:54 ` [PATCH 4/4] tty: n_gsm: Fix the test for if DLCI0 is open Dan Carpenter
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=20180426055321.GA15363@mwanda \
--to=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=poeschel@lemonage.de \
--cc=s.hauer@pengutronix.de \
--cc=security@kernel.org \
--cc=sun_peng@topsec.com.cn \
--cc=tony@atomide.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.