Date: Mon, 6 Jul 2009 00:01:28 +0400 (MSD) From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> To: FreeBSD-gnats-submit@FreeBSD.org Cc: ariff@FreeBSD.org, thompsa@FreeBSD.org Subject: kern/136361: [patch] fix regression (kernel panic) in uaudio.c Message-ID: <20090705200128.E2CE117076@amnesiac.at.no.dns> Resent-Message-ID: <200907052040.n65Ke1PS083072@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 136361 >Category: kern >Synopsis: [patch] fix regression (kernel panic) in uaudio.c >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Jul 05 20:40:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Eygene Ryabinkin >Release: FreeBSD 8.0-CURRENT amd64 >Organization: Code Labs >Environment: System: FreeBSD 8.0-CURRENT amd64 >Description: r194677 introduced a regression into uaudio.c: USB transfers for recording will result in a kernel panics due to the read of non-present memory page. This is perfectly reproducible with at least my Creative X-Fi USB card, but should trigger the panic almost with any USB sound card. The following path lines are responsible for the bug: ----- + pc = usbd_xfer_get_frame(xfer, n); + len = usbd_xfer_get_framelen(xfer, n); [...] - usbd_copy_out(xfer->frbuffers, offset1, ch->cur, m); + usbd_copy_out(pc, offset1, ch->cur, m); ----- One can easily see that before the patch, offset1 was counted from xfer->frbuffers on each iteration and after the patch it is counted from xfer->frbuffers[n] (this is what usbd_xfer_get_frame does). >How-To-Repeat: Plug the USB sound card and try to record something, for example, ----- dd if=/dev/dspX of=snd.dump bs=64k count=1 ----- >Fix: The following patch reverts the logics to the old one, but uses new xfer structure accessors. Variables were slightly renamed to better reflect the things that are done. --- fix-buffer-overflow-record-callback.diff begins here --- begin 644 fix-buffer-overflow-record-callback.diff M1G)O;2`T,6,U-#!C.&4U-F0R,#(T838Q9F(Y,S!F93@Q.#0S,6,Y,#<P-61C M($UO;B!397`@,3<@,#`Z,#`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T[ M"BL)"0D);V9F<V5T("L](&T["B`)"0D)8V@M/F-U<B`K/2!M.PH@"B`)"0D) M:68@*&-H+3YC=7(@/CT@8V@M/F5N9"D@>PH@"0D)"0EC:"T^8W5R(#T@8V@M M/G-T87)T.PH@"0D)"7T*(`D)"7T*+0HM"0D);V9F<V5T,"`K/2!C:"T^8GET M97-?<&5R7V9R86UE.PH@"0E]"B`*(`D)8VAN7VEN='(H8V@M/G!C;5]C:"D[ ."BTM(`HQ+C8N,RXQ"@H` ` end --- fix-buffer-overflow-record-callback.diff ends here --- I have another patch that isn't directly related to the panic, but just cleans up the code duplication at the beginning of both play and record callbacks. Not an emergency, but a Good Thing (tm). --- unduplicate-size-calculations.diff begins here --- begin 644 unduplicate-size-calculations.diff M1G)O;2`T-#9A9#`P93-B-#(W8F5C83%C9C4S.#<P,F0X-6$T8S$P83@P-6-F M($UO;B!397`@,3<@,#`Z,#`Z,#`@,C`P,0I&<F]M.B!%>6=E;F4@4GEA8FEN M:VEN(#QR96$M9F)S9$!C;V1E;&%B<RYR=3X*1&%T93H@4W5N+"`U($IU;"`R M,#`Y(#(S.C,P.C4W("LP-#`P"E-U8FIE8W0Z(%M0051#2%T@=6%U9&EO.B!R M96UO=F4@9'5P;&EC871E9"!S:7IE(&-A;&-U;&%T:6]N<R!A;F0@<VQI9VAT M;'D@;W!T:6UI>F4@=&AE;0H*=&]T86PO8FQO8VMS:7IE(&-A;&-U;&%T:6]N M<R!F;W(@<F5C;W)D(&%N9"!P;&%Y(&-A;&QB86-K<R!A<F4@:G5S="!T:&4* M<V%M92P@<V\@22!H860@;6]V960@=&AE('1O('1H92!S:6YG;&4@:6YL:6YE M(&9U;F-T:6]N+B`@22!H860@86QS;PIS;&EG:'1L>2!O<'1I;6EZ960@=&AE M(&%L:6=N(')O=71I;F4@=&\@=7-E('1H92!F86-T('1H870@=&AE(&-U<G)E M;G0*;6EN:6UA;"!N=6UB97(@;V8@9G)A;65S(&ES(&$@<&]W97(@;V8@='=O M+@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@@*B\*+0ET;W1A;"`] M(&)L;V-K8V]U;G0@*B!C:"T^8GET97-?<&5R7V9R86UE.PHK"75A=61I;U]S M971U<%]B;&]C:V-O=6YT*&-H+"!U<V)D7WAF97)?;6%X7V9R86UE<RAX9F5R M*2P**PD@("`@)G1O=&%L+"`F8FQO8VMC;W5N="D["B`*(`ES=VET8V@@*%53 M0E]'151?4U1!5$4H>&9E<BDI('L*(`EC87-E(%530E]35%]44D%.4T9%4E)% 01#H*+2T@"C$N-BXS+C$*"@`` ` end --- unduplicate-size-calculations.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090705200128.E2CE117076>