linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] tty: n_gsm: fix buffer over-read in gsm_dlci_data()
@ 2022-05-04  8:17 D. Starke
  2022-05-04  8:17 ` [PATCH 2/3] tty: n_gsm: fix mux activation issues in gsm_config() D. Starke
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: D. Starke @ 2022-05-04  8:17 UTC (permalink / raw)
  To: linux-serial, gregkh, jirislaby; +Cc: linux-kernel, Daniel Starke

From: Daniel Starke <daniel.starke@siemens.com>

'len' is decreased after each octet that has its EA bit set to 0, which
means that the value is encoded with additional octets. However, the final
octet does not decreases 'len' which results in 'len' being one byte too
long. A buffer over-read may occur in tty_insert_flip_string() as it tries
to read one byte more than the passed content size of 'data'.
Decrease 'len' also for the final octet which has the EA bit set to 1 to
write the correct number of bytes from the internal receive buffer to the
virtual tty.

Fixes: 2e124b4a390c ("TTY: switch tty_flip_buffer_push")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
---
 drivers/tty/n_gsm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index a38b922bcbc1..9b0b435cf26e 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1658,6 +1658,7 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, const u8 *data, int clen)
 			if (len == 0)
 				return;
 		}
+		len--;
 		slen++;
 		tty = tty_port_tty_get(port);
 		if (tty) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* RE: [PATCH 3/3] tty: n_gsm: fix invalid gsmtty_write_room() result
@ 2022-05-09 11:10 Starke, Daniel
  0 siblings, 0 replies; 7+ messages in thread
From: Starke, Daniel @ 2022-05-09 11:10 UTC (permalink / raw)
  To: Jiri Slaby, linux-serial@vger.kernel.org,
	gregkh@linuxfoundation.org
  Cc: linux-kernel@vger.kernel.org

> > +#define TX_SIZE		4096    /* Must be power of 2. */
> 
> Only that I'd not put the macro definition here. But outside the structure.
> 
> >   	struct kfifo fifo;	/* Queue fifo for the DLCI */

I have placed it at the field which it affects the same way as the original
author placed TX_THRESH_HI and TX_THRESH_LO at tx_list within struct gsm_mux.
I can resubmit this patch, but it was already included in the tty-linux
branch. Please let me know your opinion on this.

Best regards,
Daniel Starke

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-05-09 11:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-04  8:17 [PATCH 1/3] tty: n_gsm: fix buffer over-read in gsm_dlci_data() D. Starke
2022-05-04  8:17 ` [PATCH 2/3] tty: n_gsm: fix mux activation issues in gsm_config() D. Starke
2022-05-09 10:28   ` Jiri Slaby
2022-05-04  8:17 ` [PATCH 3/3] tty: n_gsm: fix invalid gsmtty_write_room() result D. Starke
2022-05-09 10:31   ` Jiri Slaby
2022-05-09 10:41 ` [PATCH 1/3] tty: n_gsm: fix buffer over-read in gsm_dlci_data() Jiri Slaby
  -- strict thread matches above, loose matches on Subject: below --
2022-05-09 11:10 [PATCH 3/3] tty: n_gsm: fix invalid gsmtty_write_room() result Starke, Daniel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).