From nobody Fri Jun 03 11:55:14 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7D17F1803353 for ; Fri, 3 Jun 2022 11:55:21 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LF1Xl2Nd1z4hv9 for ; Fri, 3 Jun 2022 11:55:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C5B91B18 for ; Fri, 3 Jun 2022 11:55:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 253BtF42018826 for ; Fri, 3 Jun 2022 11:55:15 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 253BtFPa018825 for bugs@FreeBSD.org; Fri, 3 Jun 2022 11:55:15 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 264282] BIOS boot from GELI encrypted broken / 'currdev' set to wrong string Date: Fri, 03 Jun 2022 11:55:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: yamagi@yamagi.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1654257319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N1+Gy3EQ9VjfS0nW+i+tXjZY7SiCc5vO77BDkEPsfPc=; b=mJ/ZDl0MfICiuZayX+7tzOelQLxXdg5/RrIfQyRlMGU9Xdr3VyFVW3HfH0Pjv5FI/SDpz1 rQXyUqPtlvB+h181pV1mvZJjCNU0ZMeSMKl03SKKIt+kzmE9GIyACCpkYOvR0J3U7zXaJ3 uc3htCqAsRwuda1cO5a6NkPtgGeWAaqiELoOEkZka+kgeIH5LvVSHrsSuktWPEaLNPozJR 3vnVMXgtORMii1ne+mrtfj/nhR2QNP7DI20e7PAanPUpJFalFqd5lHXn6o7DKsAf0gQ95I FHJny5FqGc3umL21QQnLTMFfRtRZYWt+iSaWB4P8JZ/yrCByL4U2QK1nca+OPA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1654257319; a=rsa-sha256; cv=none; b=hWpOMHs5b11RL/Qb/4ecTKlaCYFfOVrLvzyk7BzvDOtEo0g2mt7kxnUAgUMjKDoAN4dauh X3oMBkpMS3cBtVhRzn1joMclUAc0tqWV+la7pUkyKhZaa6vX03239kZ2usBgPfw2pf5nsL pB6nTQi1qPpFI+eWjG3DH2DOLbOI4ckNaPh2rbJ2S1kDqlWKJ+ADxtgM1c6mnApXvmdydP IJdrZkhjuBCpU0F0defAQqe07EjvY8gtv0Vx6k61R//Z3od7hG5C8hg0VmuJ+0vBZJ5ivV gdngMoefhwxow8r+FtuTyMcPJAc3TlKOSzCNyZJ7PH/V9kylFNY+DHFyzX2gdw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D264282 --- Comment #2 from yamagi@yamagi.org --- I had a deeper look. This is a long standing bug, it's been there since forever. bc9154a208248 exposed it and broke the BIOS bootloader on UFS on G= ELI encrypted devices. ZFS is not broken, because it uses another code path. The bootloader tracks devices in `devsw` structs. These structs have a field `dv_name`, storing the name of the device type. For everything which qualif= ies as a harddisk the string is just "disk". The BIOS loader (i386 loader in t= he code) derives the actual devicename from `dv_name` and some unit number mag= ic, drive C: ends up as unit 0. That happens in `i386_fmtdev()`. GELI employs a hack: GELI devices are treated like disks, the GELI initialisation code hijacks the `devsw` struct of the given disk and overwr= ites it with a specialized version. The hack is explained in stand/libsa/geli/gelidev.c:46. All lines are against 14-CURRENT as of 1326017849ee. This specialized version sets `dv_name` to "gelidisk". That's were the wrong string comes from. Until bc9154a208248 the `currdev` variable got set before GELI was initaliz= ed. `dv_name` was still set to "disk". But with bc9154a208248 `currdev` is set after GELI was initialized and `dv_name` is already "gelidisk". The code doesn't take that into account and we end up with a wrong string. I don't know enough about the bootloader to decide what the best fix is. We could add logic to handle "gelidisk", since GELI disks are just disks that looks overly complicated and error prone. We can introduce a new device type `DEVT_GELI` or something like that. That would require a lot of code handli= ng that type, most of it would be a copy of the generic disk code. The easiest= way is to change "gelidisk" to just "disk". That should be okay, because there'= s no code which handles "gelidisk" and GELI disks are disks. The attached patch does exactly that. A oneliner, tested on my VM. I'm also attaching a prebuild loader with the patch applied. It can be used to recov= er bricked system, just replace /boot/loader with it. --=20 You are receiving this mail because: You are the assignee for the bug.=