From owner-freebsd-geom@FreeBSD.ORG Wed Dec 4 16:20:39 2013 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2968D9D2 for ; Wed, 4 Dec 2013 16:20:39 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B16DE1D59 for ; Wed, 4 Dec 2013 16:20:38 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.7/8.14.7) with ESMTP id rB4GKTYa096328; Wed, 4 Dec 2013 18:20:29 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua rB4GKTYa096328 Received: (from kostik@localhost) by tom.home (8.14.7/8.14.7/Submit) id rB4GKTnQ096326; Wed, 4 Dec 2013 18:20:29 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 4 Dec 2013 18:20:29 +0200 From: Konstantin Belousov To: Paolo Pinto Subject: Re: geom_uzip, panic: bio_length in mdstart_vnode() Message-ID: <20131204162029.GV59496@kib.kiev.ua> References: <529F2748.2060900@netasq.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0hQvwEBO51ZK2gOw" Content-Disposition: inline In-Reply-To: <529F2748.2060900@netasq.com> User-Agent: Mutt/1.5.22 (2013-10-16) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: nicolas dumont , freebsd-geom@freebsd.org X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Dec 2013 16:20:39 -0000 --0hQvwEBO51ZK2gOw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 04, 2013 at 01:59:52PM +0100, Paolo Pinto wrote: > Hi list! >=20 > My kernel is compiled with option INVARIANTS and I get a reproducible > kernel panic when trying to read data from a GEOM based compressed > memory disk: >=20 > Unread portion of the kernel message buffer: > panic: bio_length 140288 > cpuid =3D 3 > KDB: stack backtrace: > #0 0xffffffff80909726 at kdb_backtrace+0x66 > #1 0xffffffff808d0fa8 at panic+0x1d8 > #2 0xffffffff80595949 at mdstart_vnode+0x619 The issue is that geom_uzip creates bios which are larger than MAXPHYS. As a workaround, the following patch should be enough. It only fires assert when md really uses pbuf, and since geom_uzip knows nothing about unmapped bio, the assertion must not trigger. diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 8ae51d1..639677e 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -746,12 +746,12 @@ mdstart_vnode(struct md_s *sc, struct bio *bp) return (error); } =20 - KASSERT(bp->bio_length <=3D MAXPHYS, ("bio_length %jd", - (uintmax_t)bp->bio_length)); if ((bp->bio_flags & BIO_UNMAPPED) =3D=3D 0) { pb =3D NULL; aiov.iov_base =3D bp->bio_data; } else { + KASSERT(bp->bio_length <=3D MAXPHYS, ("bio_length %jd", + (uintmax_t)bp->bio_length)); pb =3D getpbuf(&md_vnode_pbuf_freecnt); pmap_qenter((vm_offset_t)pb->b_data, bp->bio_ma, bp->bio_ma_n); aiov.iov_base =3D (void *)((vm_offset_t)pb->b_data + --0hQvwEBO51ZK2gOw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJSn1ZMAAoJEJDCuSvBvK1BrigQAJQpfjM4ycTdVKcJ7WgE4Nwt oIos29ut4baVWhD9Va0irsFo8FnzzX78EVSiNrmFtdsVHo017oP/bijqeBZfQMmd 0hmnDBXubN1wsbN/xSJ8yOyCEuZ1t/XziwlviaZlYzs/14nY8KNweDfE8fNEPfoC nPs9EICfqHn8XNmUAN0gRQ6oKfWxPFUHHeYGSNhwHWospUHimb4F4TzAb2OK+7XL AwLuVterXL1XAV7+hZfMrRvKKVRW8NL1DFLtmzHrQzvT6+M/VwdHLOYt3+m0UTYL L7AvHkgAJDGBF5jgqlsoQXA8pVz2kE3RWnFh0jxi8uQjtFm22vt5gvzQ2A6XT2QU 4K4nEzVPRLmJ98RDjAxwleWgJztOfhl2z9BBwjwJ+v4gAFoHrurwQc9PbQ1lX4BF 0MmN5HVe1kq755MMKSef2TKZyHfjrJROqWKKewYkaXWZGckBJVT5WjnRwDGBGz0Y l3+AznXY/1K80XHV5nFbjZvIxEAiBNuMkyDXb4Y953DhI9oKXDK0virnlgy2CU2g C1iTI+HiHaexbv4eLd9g04QOYrmXOBwtvfa6LLNaqAz/OKYDFYauBLsqmAJ5Y31s LXknyzdRpMOdN3kCxNpv8eCR/RcgLzrkN8KIIv72H9xElO0vaF+/p6mnzLzThOn/ pBH8/mQxiP9SI+BEFl8L =1ztn -----END PGP SIGNATURE----- --0hQvwEBO51ZK2gOw--