From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1Zm8VS-00052J-Ty for mharc-grub-devel@gnu.org; Tue, 13 Oct 2015 18:57:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46961) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zm8UA-0003U5-Jt for grub-devel@gnu.org; Tue, 13 Oct 2015 18:55:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zm8U9-0000p5-9J for grub-devel@gnu.org; Tue, 13 Oct 2015 18:55:58 -0400 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]:38624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zm8U9-0000ok-2W for grub-devel@gnu.org; Tue, 13 Oct 2015 18:55:57 -0400 Received: by wieq12 with SMTP id q12so55410195wie.1 for ; Tue, 13 Oct 2015 15:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=z+YAsvCv2Yii8ytHIgPujTgraKge24K9y60S1n6GqQk=; b=yQD+L+34UfQA591cMiPUYbsMFvxBb/iP2WIv0FXUhwOgeaekFMJP8Npc8vYq/o3YjO kALlFP/vzcounUFSFQcXqTD5ak7SRb9vZFG85pdQT6rWyB1Tv8zmarY1xzWtUypp6LOc GqqOMikSiIrzYFQmbA14pmRF6vSIfz9QgVROUHS/SKqC4Dv+pY85XQQxbTuOpdVKZUE1 NpdvcFtjWCYXw2tP2KQuWmKp5ezB8nh/pxAScF9R/7nAp876Ef4/tKECAmlomCOslSLt uaBrZ0pkqXY2OHifr2i705Wi0HaQpFkdurg+ZkFb4OIRs3wZfShAUn2UZ/Ywr9KTPlgG ME1w== X-Received: by 10.194.94.99 with SMTP id db3mr15231948wjb.141.1444776956096; Tue, 13 Oct 2015 15:55:56 -0700 (PDT) Received: from ?IPv6:2a02:1205:34c8:dc00:863a:4bff:fe50:abc4? ([2a02:1205:34c8:dc00:863a:4bff:fe50:abc4]) by smtp.gmail.com with ESMTPSA id xt1sm6246003wjb.32.2015.10.13.15.55.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Oct 2015 15:55:54 -0700 (PDT) Subject: Re: Add check when store disk cache To: The development of GNU GRUB References: <55FB8D15.40604@gmail.com> <55FD0810.30703@gmail.com> From: =?UTF-8?Q?Vladimir_'=cf=86-coder/phcoder'_Serbinenko?= X-Enigmail-Draft-Status: N1110 Message-ID: <561D8BD8.50707@gmail.com> Date: Wed, 14 Oct 2015 00:55:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.2.0 MIME-Version: 1.0 In-Reply-To: <55FD0810.30703@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="v0vtkRi6MBveP5vSK08MaJS0O0tvVEEoB" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::231 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: Tue, 13 Oct 2015 22:56:00 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --v0vtkRi6MBveP5vSK08MaJS0O0tvVEEoB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 19.09.2015 09:00, Andrei Borzenkov wrote: > 18.09.2015 12:07, Arch Stack =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >> I want to use the part of the filesystem codes in GRUB to read differe= nt >> filesystems on Windows. I have almost completed it and I will release >> it in >> a few days. >> But it crash sometimes because of the write of zero pointer.I debug it= >> and >> find why it crashed. >=20 > Please show stack trace of crash. GRUB does not run multithreaded so > something different must happen. >=20 Most likely he has just run the grub code multithreaded in his fuse-like driver. It's probably a bad idea since GRUB is not designed for this and in fact this lock is more for the cases when one disk code calls another disk code. I'm not sure it actually can happen i n current code. Moreover current way of handling ->lock isn't thread-safe= as we first check it and then set rather than using a lock primitive. If = you want to go into making parts of GRUB multi-threaded I suggest going with giant lock first and then breaking it down progressively. The locks should fully disappear when compiling for real GRUB. This will probably require preprocessor magic which makes variables disappear when GRUB_UTIL is not defined. >> When I apply this patch, it won't crash because of this >> reason. >> >> On Fri, Sep 18, 2015 at 12:03 PM, Andrei Borzenkov >> wrote: >> >>> 18.09.2015 03:15, Arch Stack =D0=BF=D0=B8=D1=88=D0=B5=D1=82: >>> >>>> I found that the function *grub_disk_cache_store* didn't check for >>>> *cache->lock* before free *cache->data*, and didn't set *cache->lock= * >>>> before memcpy something to *cache->data*. If multi thread handle >>>> with the >>>> same cache at the same time, it will cause a fault. >>>> >>> >>> Do you actually observe a problem or it is pure hypothesis? GRUB does= >>> not >>> run multi-threaded and probably never will. >>> >>> I have created a patch >>>> for it. >>>> >>>> >>>> >>>> _______________________________________________ >>>> Grub-devel mailing list >>>> Grub-devel@gnu.org >>>> https://lists.gnu.org/mailman/listinfo/grub-devel >>>> >>>> >>> >>> _______________________________________________ >>> Grub-devel mailing list >>> Grub-devel@gnu.org >>> https://lists.gnu.org/mailman/listinfo/grub-devel >>> >> >> >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel >> >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel --v0vtkRi6MBveP5vSK08MaJS0O0tvVEEoB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iF4EAREKAAYFAlYdi/oACgkQmBXlbbo5nOtxtQEArZ43OC4q0RhxpqqA7mYQ7Wkm 0SZX/tbhpKBQDkl/Y+EA/3rqpV4MYcRVLHq8rqeD03ZtUETLPvbyPjUOERaPGTfh =5SAp -----END PGP SIGNATURE----- --v0vtkRi6MBveP5vSK08MaJS0O0tvVEEoB--