Received: from list by lists.gnu.org with archive (Exim 4.71) id 1e4vT5-0002K6-AX for mharc-grub-devel@gnu.org; Wed, 18 Oct 2017 17:01:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50428) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4vT2-0002IC-HW for grub-devel@gnu.org; Wed, 18 Oct 2017 17:01:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4vSz-00061z-Fv for grub-devel@gnu.org; Wed, 18 Oct 2017 17:01:32 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:29954) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4vSz-00060P-8V for grub-devel@gnu.org; Wed, 18 Oct 2017 17:01:29 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9IL1Q0o002617 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Oct 2017 21:01:27 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9IL1Q1v027168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Oct 2017 21:01:26 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v9IL1Qif016890; Wed, 18 Oct 2017 21:01:26 GMT Received: from dhcp-adc-twvpn-3-vpnpool-10-154-116-84.vpn.oracle.com (/10.154.116.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 18 Oct 2017 14:01:26 -0700 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: [PATCH] ls: prevent double open From: Eric Snowberg In-Reply-To: Date: Wed, 18 Oct 2017 15:01:20 -0600 Cc: Daniel Kiper , "Vladimir 'phcoder' Serbinenko" Content-Transfer-Encoding: quoted-printable Message-Id: References: <1508184672-164532-1-git-send-email-eric.snowberg@oracle.com> To: The development of GNU GRUB X-Mailer: Apple Mail (2.3124) X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Oct 2017 21:01:33 -0000 > On Oct 18, 2017, at 11:03 AM, Vladimir 'phcoder' Serbinenko = wrote: >=20 >=20 >=20 > On Wed, Oct 18, 2017, 19:02 Eric Snowberg = wrote: >=20 > > On Oct 18, 2017, at 10:32 AM, Vladimir 'phcoder' Serbinenko = wrote: > > > > > > > > On Mon, Oct 16, 2017, 22:11 Eric Snowberg = wrote: > > Prevent a double open. This can cause problems with some ieee1275 > > devices, causing the system to hang. The double open can occur > > as follows: > > Why does it? Underlying firmware device should not be aware of how = many times grub device is open. If it is and it causes bugs, then it's a = bug in device driver >=20 > Which device driver are you referring to? The one in GRUB or Open = Firmware? > In GRUB >=20 >=20 I would agree with that. There are many problems with the ofdisk driver = in GRUB. One being the memory corruption issues that prevents new code = from being added to it, which is what I believe you are recommending. I = submitted a fix for the memory corruption problems years ago, but the = patch was ignored. memory corruption example: devpath created in grub_ofdisk_open it then calls ofdisk_hash_add with devpath it then calls ofdisk_hash_add_real with devpath ofdisk_hash_add_real saves pointer of devpath return return free devpath dangling pointer/memory corruption with what is stored in = ofdisk_hash_add_real, any new memory allocation corrupts devpath As I recall, just trying to add a grub_printf in the wrong place can = corrupt the devpath. I never understood why this bug was too risky to = fix for 2.02 or why it still exists today.=20 I ended up writing a new driver which we use instead. = https://github.com/esnowberg/grub2-sparc/commit/d802909bc614980dcf6dc2f448= 4bfa8c2448adf1 This driver would take care of this double open problem making this = patch unnecessary. It will also solve many other problems that currently = exist in ofdisk. If you would consider this driver in upstream, let me = know and I=E2=80=99ll start submitting it.