9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] crashing plan9 source boot CD with key combination (buffer overflow)
@ 2014-06-20 10:22 Yoann Padioleau
  2014-06-20 12:10 ` erik quanstrom
  0 siblings, 1 reply; 2+ messages in thread
From: Yoann Padioleau @ 2014-06-20 10:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hi,

There is another buffer overflow somewhere I think.

The code in kbdputsc() in kbd.c does not look very safe:

		kbscan->kc[kbscan->nk++] = c; <--------- no bound checking, can overflow.
		c = latin1(kbscan->kc, kbscan->nk);
		if(c < -1)	/* need more keystrokes */
			return;
		if(c != -1)	/* valid sequence */
			kbdputc(kbdq, c);
		else	/* dump characters */
			for(i=0; i<kbscan->nk; i++)
				kbdputc(kbdq, kbscan->kc[i]);
		kbscan->nk = 0;
		kbscan->collecting = 0;

Actually with the plan9 actual iso, when I boot from the CD
and in rio I open a new terminal and type

<Alt> x ddddddddddddddddddddddddddd <Alt> lc
then I crash the cpu.




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

* Re: [9fans] crashing plan9 source boot CD with key combination (buffer overflow)
  2014-06-20 10:22 [9fans] crashing plan9 source boot CD with key combination (buffer overflow) Yoann Padioleau
@ 2014-06-20 12:10 ` erik quanstrom
  0 siblings, 0 replies; 2+ messages in thread
From: erik quanstrom @ 2014-06-20 12:10 UTC (permalink / raw)
  To: 9fans

On Fri Jun 20 06:24:25 EDT 2014, pad@fb.com wrote:
good catch, but...

> The code in kbdputsc() in kbd.c does not look very safe:
>
> 		kbscan->kc[kbscan->nk++] = c; <--------- no bound checking, can overflow.

this behavior depends entirely on what latin1() does.  if
latin1() will always consume the array before kbscan->nk reaches
some bound, then extra checking here wouldn't change anything.

and that's the case.  (read port/latin1.c for details).

the real problem is that kc should be strlen("x10ffff") = 7.
(sources is wrong here, too, UTFmax*2+1 = 9, which would
allow for x1000ffff, which is not a rune)

- erik

ps: the bug was introduced here

Apr 30 16:05:23 EDT 2013 /n/sourcesdump/2014/0620/plan9/sys/src/9/port/latin1.c 1570

pps: 9atom patch applied /n/atom/patch/applied/collectlen



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

end of thread, other threads:[~2014-06-20 12:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-20 10:22 [9fans] crashing plan9 source boot CD with key combination (buffer overflow) Yoann Padioleau
2014-06-20 12:10 ` erik quanstrom

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).