Received: from list by lists.gnu.org with archive (Exim 4.71) id 1SrtmU-0008BS-4o for mharc-grub-devel@gnu.org; Thu, 19 Jul 2012 12:40:50 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrtmK-0008Ah-0W for grub-devel@gnu.org; Thu, 19 Jul 2012 12:40:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrtmC-0006yj-LW for grub-devel@gnu.org; Thu, 19 Jul 2012 12:40:39 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:37037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrtmC-0006xH-8E for grub-devel@gnu.org; Thu, 19 Jul 2012 12:40:32 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Jul 2012 17:40:29 +0100 Received: from d06nrmr1307.portsmouth.uk.ibm.com (9.149.38.129) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Jul 2012 17:40:27 +0100 Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6JGeQbv1646732 for ; Thu, 19 Jul 2012 17:40:26 +0100 Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6JGKnqg026637 for ; Thu, 19 Jul 2012 12:20:49 -0400 Received: from BR8GGW75.de.ibm.com (dyn-9-152-221-174.boeblingen.de.ibm.com [9.152.221.174]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6JGKn5Z026630 for ; Thu, 19 Jul 2012 12:20:49 -0400 Date: Thu, 19 Jul 2012 18:40:23 +0200 From: Thomas Huth To: grub-devel@gnu.org Subject: Problem when calling non-existing functions on Open Firmware Message-ID: <20120719184023.49814c75@BR8GGW75.de.ibm.com> Organization: IBM X-Mailer: Claws Mail 3.7.4 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit x-cbid: 12071916-0542-0000-0000-00000282F62C X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.113 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Jul 2012 16:40:49 -0000 Hi all! There is a problem in Grub on IEEE1275 when it tries to call certain functions via "call-method" - it does not check the "catch_result" in some places to test whether the target function really exists, continues with bad data, finally leading to some obscure crashes. We've hit this problen with the the code in the scan() function in the file grub-core/disk/ieee1275/ofdisk.c: INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); args.method = (grub_ieee1275_cell_t) "vscsi-report-luns"; args.ihandle = ihandle; args.table = 0; args.nentries = 0; if (IEEE1275_CALL_ENTRY_FN (&args) == -1) { grub_ieee1275_close (ihandle); return 0; } We've got an implementation of Open Firmware that features vscsi, but does not offer the vscsi-report-luns method (yet). Grub2 does not abort after trying to call the method, but continues with bad results and finally crashes. The fix for the crash is quite easy: Simply test the "catch_result" in the args structure. If it is non-zero, the call failed and the function should abort here, ie. the if-statement should rather look like this: if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result != 0) { grub_ieee1275_close (ihandle); return 0; } Beside the code in ofdisk.c there are some other places in the code where Grub ignores the catch_result (simply search for "call-method" and have a look whether catch_result is being used or not). I guess these other spots should be fixed, too. Regards, Thomas Huth