CINXE.COM
LKML: Stefan Richter: Re: [PATCH] sbp2: fix panic when ejecting an ipod
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>LKML: Stefan Richter: Re: [PATCH] sbp2: fix panic when ejecting an ipod</title><link href="/css/message.css" rel="stylesheet" type="text/css" /><link href="/css/wrap.css" rel="alternate stylesheet" type="text/css" title="wrap" /><link href="/css/nowrap.css" rel="stylesheet" type="text/css" title="nowrap" /><link href="/favicon.ico" rel="shortcut icon" /><script src="/js/simple-calendar.js" type="text/javascript"></script><script src="/js/styleswitcher.js" type="text/javascript"></script><link rel="alternate" type="application/rss+xml" title="lkml.org : last 100 messages" href="/rss.php" /><link rel="alternate" type="application/rss+xml" title="lkml.org : last messages by Stefan Richter" href="/groupie.php?aid=25067" /><!--Matomo--><script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(["setDoNotTrack", true]); _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { var u="//m.lkml.org/"; _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script><!--End Matomo Code--></head><body onload="es.jasper.simpleCalendar.init();" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"><table border="0" cellpadding="0" cellspacing="0"><tr><td width="180" align="center"><a href="/"><img style="border:0;width:135px;height:32px" src="/images/toprowlk.gif" alt="lkml.org" /></a></td><td width="32">聽</td><td class="nb"><div><a class="nb" href="/lkml"> [lkml]</a> 聽 <a class="nb" href="/lkml/2005"> [2005]</a> 聽 <a class="nb" href="/lkml/2005/12"> [Dec]</a> 聽 <a class="nb" href="/lkml/2005/12/10"> [10]</a> 聽 <a class="nb" href="/lkml/last100"> [last100]</a> 聽 <a href="/rss.php"><img src="/images/rss-or.gif" border="0" alt="RSS Feed" /></a></div><div>Views: <a href="#" class="nowrap" onclick="setActiveStyleSheet('wrap');return false;">[wrap]</a><a href="#" class="wrap" onclick="setActiveStyleSheet('nowrap');return false;">[no wrap]</a> 聽 <a class="nb" href="/lkml/mheaders/2005/12/10/87" onclick="this.href='/lkml/headers'+'/2005/12/10/87';">[headers]</a>聽 <a href="/lkml/bounce/2005/12/10/87">[forward]</a>聽 </div></td><td width="32">聽</td></tr><tr><td valign="top"><div class="es-jasper-simpleCalendar" baseurl="/lkml/"></div><div class="threadlist">Messages in this thread</div><ul class="threadlist"><li class="root"><a href="/lkml/2005/12/10/80">First message in thread</a></li><li><a href="/lkml/2005/12/10/80">Jody McIntyre</a><ul><li class="origin"><a href="">Stefan Richter</a></li></ul></li></ul></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerl.gif" width="32" height="32" alt="/" /></td><td class="c" rowspan="2" valign="top" style="padding-top: 1em"><table><tr><td><table><tr><td class="lp">Date</td><td class="rp" itemprop="datePublished">Sat, 10 Dec 2005 19:25:29 +0100</td></tr><tr><td class="lp">From</td><td class="rp" itemprop="author">Stefan Richter <></td></tr><tr><td class="lp">Subject</td><td class="rp" itemprop="name">Re: [PATCH] sbp2: fix panic when ejecting an ipod</td></tr></table></td><td></td></tr></table><pre itemprop="articleBody">Jody McIntyre wrote:<br />> On Sat, Dec 10, 2005 at 12:24:59PM +0100, Stefan Richter wrote:<br />> <br />>>sbp2: fix panic when ejecting an ipod<br />>><br />>>Sbp2 did not catch some bogus transfer directions in requests from upper<br />>>layers. Problem became apparent when iPods were to be ejected:<br />>>http://marc.theaimsgroup.com/?l=linux1394-devel&m=113399994920181<br />>>http://marc.theaimsgroup.com/?l=linux1394-user&m=112152701817435<br />>>Debugging and original variant of the patch by Andrew de Quincey.<br />> <br />> <br />> NAK. James has a patch to fix this in the SCSI layer, which is his<br />> preference.<br /><br />The fix for SCSI mid/high layer is to send the proper transfer <br />direction. (BTW, note that there are _many_ places where the transfer <br />direction is generated, not just where Jeff's and James' patches correct <br />things. The code which generates transfer directions will keep changing. <br />Userspace can set transfer directions.)<br /><br />The fix for sbp2 is to not cause a kernel panic should an improper <br />transfer direction be send. All SCSI low level drivers have to handle <br />the transfer direction one way or another. Most chose not to panic.<br /><br />My patch is not the fix for the wrong direction. It is solely meant not <br />to crash the whole machine after a minor mistake. Also, my patch is not <br />meant to hide mistakes that occurred in higer levels --- and it doesn't <br />do so.<br /><br />I absolutely agree with you et al that bugs must be fixed in the layer <br />where they occur. However I also strongly believe that a bug in one <br />layer should not trickle down two or more layers and increase the damage <br />up to a catastrophe --- *if this can be avoided by simple means*, i.e. <br />without bloat. (Note the diffstat. I am basically moving existing code <br />up in an if/else cascade. Also, another cleanup for <br />sbp2_create_command_orb will follow next week.)<br /><br />Please apply.<br /><br />>>Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de><br />>>Cc: Andrew de Quincey <adq@lidskialf.net><br />>><br />>>---<br />>><br />>>Corresponding fix of the places where transfer direction is actually set and<br />>>how to clean sbp2_create_command_orb() up after this fix is being discussed.<br />>>A patch for SCSI mid and high level has been submitted.<br />>>http://marc.theaimsgroup.com/?t=113400010000001<br />>>Please apply the following patch to prevent kernel panics as the first step.<br />>><br />>> drivers/ieee1394/sbp2.c | 16 ++++++----------<br />>> 1 files changed, 6 insertions(+), 10 deletions(-)<br />>><br />>>--- linux/drivers/ieee1394.orig/sbp2.c 2005-11-24 23:10:21.000000000 +0100<br />>>+++ linux/drivers/ieee1394/sbp2.c 2005-12-10 11:57:41.000000000 +0100<br />>>@@ -1784,6 +1784,12 @@ static int sbp2_create_command_orb(struc<br />>> break;<br />>> }<br />>> <br />>>+ if (orb_direction != ORB_DIRECTION_NO_DATA_TRANSFER &&<br />>>+ scsi_request_bufflen == 0) {<br />>>+ SBP2_WARN("Enforcing transfer direction DMA_NONE");<br />>>+ orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;<br />>>+ }<br />>>+<br />>> /*<br />>> * Set-up our pagetable stuff... unfortunately, this has become<br />>> * messier than I'd like. Need to clean this up a bit. ;-)<br />>>@@ -1900,16 +1906,6 @@ static int sbp2_create_command_orb(struc<br />>> command_orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen);<br />>> command_orb->misc |= ORB_SET_DIRECTION(orb_direction);<br />>> <br />>>- /*<br />>>- * Sanity, in case our direction table is not<br />>>- * up-to-date<br />>>- */<br />>>- if (!scsi_request_bufflen) {<br />>>- command_orb->data_descriptor_hi = 0x0;<br />>>- command_orb->data_descriptor_lo = 0x0;<br />>>- command_orb->misc |= ORB_SET_DIRECTION(1);<br />>>- }<br />>>-<br />>> } else {<br />>> /*<br />>> * Need to turn this into page tables, since the<br />>><br />> <br />> <br /><br /><br />-- <br />Stefan Richter<br />-=====-=-=-= ==-- -=-=-<br /><a href="http://arcgraph.de/sr/">http://arcgraph.de/sr/</a><br />-<br />To unsubscribe from this list: send the line "unsubscribe linux-kernel" in<br />the body of a message to majordomo@vger.kernel.org<br />More majordomo info at <a href="http://vger.kernel.org/majordomo-info.html">http://vger.kernel.org/majordomo-info.html</a><br />Please read the FAQ at <a href="http://www.tux.org/lkml/">http://www.tux.org/lkml/</a><br /><br /></pre></td><td width="32" rowspan="2" class="c" valign="top"><img src="/images/icornerr.gif" width="32" height="32" alt="\" /></td></tr><tr><td align="right" valign="bottom"> 聽 </td></tr><tr><td align="right" valign="bottom">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerl.gif" width="32" height="32" alt="\" /></td><td class="c">聽</td><td class="c" valign="bottom" style="padding-bottom: 0px"><img src="/images/bcornerr.gif" width="32" height="32" alt="/" /></td></tr><tr><td align="right" valign="top" colspan="2"> 聽 </td><td class="lm">Last update: 2005-12-10 19:29 聽聽 [from the cache]<br />漏2003-2020 <a href="http://blog.jasper.es/"><span itemprop="editor">Jasper Spaans</span></a>|hosted at <a href="https://www.digitalocean.com/?refcode=9a8e99d24cf9">Digital Ocean</a> and my Meterkast|<a href="http://blog.jasper.es/categories.html#lkml-ref">Read the blog</a></td><td>聽</td></tr></table><script language="javascript" src="/js/styleswitcher.js" type="text/javascript"></script></body></html>