* [PATCH 0/2] N_GSM bugfix patchset : June 14, 2011
[not found] <[PATCH 0/2] N_GSM bugfix patchset : June 14, 2011>
@ 2011-06-14 20:23 ` Russ Gorby
2011-06-14 20:23 ` [PATCH 1/2] tty: n_gsm: Fixed logic to decode break signal from modem status Russ Gorby
2011-06-14 20:23 ` [PATCH 2/2] tty: n_gsm: improper skb_pull() use was leaking framed data Russ Gorby
2 siblings, 0 replies; 3+ messages in thread
From: Russ Gorby @ 2011-06-14 20:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel; +Cc: suhail.ahmed, russ.gorby
Hello N_GSM Maintainers,
I'm sending this patchset
[PATCH 0/2] N_GSM bugfix patchset : June 14, 2011
for inclusion in the linux kernel.
This contains the 2 bugfixes separated from the patchset
N_GSM patchset : 06/03/2011: v2
as requested by GregH
[PATCH 1/2] tty: n_gsm: Fixed logic to decode break signal from modem status
[PATCH 2/2] tty: n_gsm: improper skb_pull() use was leaking framed data
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] tty: n_gsm: Fixed logic to decode break signal from modem status
[not found] <[PATCH 0/2] N_GSM bugfix patchset : June 14, 2011>
2011-06-14 20:23 ` [PATCH 0/2] N_GSM bugfix patchset : June 14, 2011 Russ Gorby
@ 2011-06-14 20:23 ` Russ Gorby
2011-06-14 20:23 ` [PATCH 2/2] tty: n_gsm: improper skb_pull() use was leaking framed data Russ Gorby
2 siblings, 0 replies; 3+ messages in thread
From: Russ Gorby @ 2011-06-14 20:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel; +Cc: suhail.ahmed, russ.gorby
The modem status can be one or 2 octets and contains the V.24 signals
and in the 2 octet case also the break signal.
We were improperly decoding the break signal from the modem in the
2 octet case.
Signed-off-by: Russ Gorby <russ.gorby@intel.com>
---
drivers/tty/n_gsm.c | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index a4c42a7..16af6cf 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -984,10 +984,22 @@ static void gsm_control_reply(struct gsm_mux *gsm, int cmd, u8 *data,
*/
static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
- u32 modem)
+ u32 modem, int clen)
{
int mlines = 0;
- u8 brk = modem >> 6;
+ u8 brk = 0;
+
+ /* The modem status command can either contain one octet (v.24 signals)
+ or two octets (v.24 signals + break signals). The length field will
+ either be 2 or 3 respectively. This is specified in section
+ 5.4.6.3.7 of the 27.010 mux spec. */
+
+ if (clen == 2)
+ modem = modem & 0x7f;
+ else {
+ brk = modem & 0x7f;
+ modem = (modem >> 7) & 0x7f;
+ };
/* Flow control/ready to communicate */
if (modem & MDM_FC) {
@@ -1061,7 +1073,7 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen)
return;
}
tty = tty_port_tty_get(&dlci->port);
- gsm_process_modem(tty, dlci, modem);
+ gsm_process_modem(tty, dlci, modem, clen);
if (tty) {
tty_wakeup(tty);
tty_kref_put(tty);
@@ -1482,12 +1494,13 @@ static void gsm_dlci_begin_close(struct gsm_dlci *dlci)
* open we shovel the bits down it, if not we drop them.
*/
-static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int len)
+static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen)
{
/* krefs .. */
struct tty_port *port = &dlci->port;
struct tty_struct *tty = tty_port_tty_get(port);
unsigned int modem = 0;
+ int len = clen;
if (debug & 16)
pr_debug("%d bytes for tty %p\n", len, tty);
@@ -1507,7 +1520,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int len)
if (len == 0)
return;
}
- gsm_process_modem(tty, dlci, modem);
+ gsm_process_modem(tty, dlci, modem, clen);
/* Line state will go via DLCI 0 controls only */
case 1:
default:
--
1.7.0.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] tty: n_gsm: improper skb_pull() use was leaking framed data
[not found] <[PATCH 0/2] N_GSM bugfix patchset : June 14, 2011>
2011-06-14 20:23 ` [PATCH 0/2] N_GSM bugfix patchset : June 14, 2011 Russ Gorby
2011-06-14 20:23 ` [PATCH 1/2] tty: n_gsm: Fixed logic to decode break signal from modem status Russ Gorby
@ 2011-06-14 20:23 ` Russ Gorby
2 siblings, 0 replies; 3+ messages in thread
From: Russ Gorby @ 2011-06-14 20:23 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel; +Cc: suhail.ahmed, russ.gorby
gsm_dlci_data_output_framed() was doing:
memcpy(dp, skb_pull(dlci->skb, len), len);
The problem is skb_pull() returns the post-increment data ptr
so the first chunk of dlci->skb->data is leaked.
Signed-off-by: Russ Gorby <russ.gorby@intel.com>
---
drivers/tty/n_gsm.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 16af6cf..20dd6b9 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -875,7 +875,8 @@ static int gsm_dlci_data_output_framed(struct gsm_mux *gsm,
*dp++ = last << 7 | first << 6 | 1; /* EA */
len--;
}
- memcpy(dp, skb_pull(dlci->skb, len), len);
+ memcpy(dp, dlci->skb->data, len);
+ skb_pull(dlci->skb, len);
__gsm_data_queue(dlci, msg);
if (last)
dlci->skb = NULL;
--
1.7.0.4
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-06-14 20:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <[PATCH 0/2] N_GSM bugfix patchset : June 14, 2011>
2011-06-14 20:23 ` [PATCH 0/2] N_GSM bugfix patchset : June 14, 2011 Russ Gorby
2011-06-14 20:23 ` [PATCH 1/2] tty: n_gsm: Fixed logic to decode break signal from modem status Russ Gorby
2011-06-14 20:23 ` [PATCH 2/2] tty: n_gsm: improper skb_pull() use was leaking framed data Russ Gorby
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