From nobody Sun May 19 13:36:47 2024 X-Original-To: dev-commits-src-main@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 4Vj1vM2my2z5K3DR; Sun, 19 May 2024 13:36:47 +0000 (UTC) (envelope-from git@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 4Vj1vM1vBYz4JB4; Sun, 19 May 2024 13:36:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716125807; 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; bh=TEwVL2L37lKYGxYA6JUZqez5t2k+2pyuJi90edqPC48=; b=PFX9THTv2Z/Jru2F/rVCUgR2kg+IKCdPdkxrSGtLk8fUYzlm9bOQHi+lGEgGWRJ7v+M3uz tl+gp6NleAzW+XJDoktSsK0FPDhZfjtHnvfM8OKmrcRt6IvYUCGWfwY02de5awmX7sr0w9 /rNlljB8imotR83mmM6h07Foxlmjiq8TCH+vsTLjUcRU7/65wPC/WyU+FQcV7vp3Ig8f2K VwbW6Xp/wyOkXQaCJA33YanbGJmTTXu1/NuicxUN+R1snUb2/PmmxxMVBfKs3WSNBLAM/7 jEU6t0HI517tuEEPASzWU+Z80xNhOz7jPsttakZUCtqtY5UeznNElMdXtJXYjA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716125807; a=rsa-sha256; cv=none; b=YMnIaHCDsEzk1kXAWPdN+YDKhgaMdoLWWflGO31LsA/xRDJwl1QBDJ1C180856Fq/G+73z +DWFV9XCfICmGe9sL25F6fEYl6HLCYbZ4CYfCIBkiurj0T9BQiBkC1jl6Bb4hkegKDQzS0 imwNWspkx4nIcviRnyd0aF0YtJdcYIM8aMq2ijFYdwZVPQJ80g3A/g7LQd83otGJKi37w3 zqWTAyDlxmPYSeLJHnfeiwdoOEeylNc2Wzx2Q26zerKl2gd++XkFECyNyDPxxqcOUEiTi4 ebK1uZbmNI/nzAdk2TWE5ctRzVwxDs7cAyyz0sodNjl+jgIl512DAHRttgW2DA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716125807; 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; bh=TEwVL2L37lKYGxYA6JUZqez5t2k+2pyuJi90edqPC48=; b=HXxtvjpMLpOip38/seRcWHgLDCPTxzxRdAWQqXlciiLl/z7pHpwVsOpib4jclEfsGxUX5z nFJsBBnrhMObUh8dqz44grh3jAqs8+v7YAwryn2tD06xynqRBRBs6p0EwnJhmexDF5yOci bfY7Gwi7eBpmqM6yWJHHWDrek8/AY7xdj5cQU2EBjryd2IojuA9hV6NPT0dUcBbVdYyzA9 uBs/h+vsBWpVVi9X1mxA5e0FFj3KK3favaYSrS6wCyxb8seWahVs/ENZKGPxrgPYAY5eiS FaqiqyYLHkaA+v3gl+t9MlbF9mf0K/rK0yTZxTzMjkt0IdNRLHFsoPWjFHUTzg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4Vj1vM1VW7z1BD1; Sun, 19 May 2024 13:36:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44JDalnD063366; Sun, 19 May 2024 13:36:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44JDalVj063363; Sun, 19 May 2024 13:36:47 GMT (envelope-from git) Date: Sun, 19 May 2024 13:36:47 GMT Message-Id: <202405191336.44JDalVj063363@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mariusz Zaborski Subject: git: 838d5ae6d82a - main - geli: fix indentation List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: oshogbo X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 838d5ae6d82a604e3f3338273b24e476a4eabb39 Auto-Submitted: auto-generated The branch main has been updated by oshogbo: URL: https://cgit.FreeBSD.org/src/commit/?id=838d5ae6d82a604e3f3338273b24e476a4eabb39 commit 838d5ae6d82a604e3f3338273b24e476a4eabb39 Author: Mariusz Zaborski AuthorDate: 2024-05-19 13:37:07 +0000 Commit: Mariusz Zaborski CommitDate: 2024-05-19 13:37:07 +0000 geli: fix indentation no functional changes --- sys/geom/eli/g_eli.c | 252 +++++++++++++++++++++++++-------------------------- 1 file changed, 126 insertions(+), 126 deletions(-) diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c index ddb148ebd5db..a9f356299a8d 100644 --- a/sys/geom/eli/g_eli.c +++ b/sys/geom/eli/g_eli.c @@ -172,32 +172,32 @@ static void zero_boot_passcache(void) { - explicit_bzero(cached_passphrase, sizeof(cached_passphrase)); + explicit_bzero(cached_passphrase, sizeof(cached_passphrase)); } static void zero_geli_intake_keys(void) { - struct keybuf *keybuf; - int i; - - if ((keybuf = get_keybuf()) != NULL) { - /* Scan the key buffer, clear all GELI keys. */ - for (i = 0; i < keybuf->kb_nents; i++) { - if (keybuf->kb_ents[i].ke_type == KEYBUF_TYPE_GELI) { - explicit_bzero(keybuf->kb_ents[i].ke_data, - sizeof(keybuf->kb_ents[i].ke_data)); - keybuf->kb_ents[i].ke_type = KEYBUF_TYPE_NONE; - } - } - } + struct keybuf *keybuf; + int i; + + if ((keybuf = get_keybuf()) != NULL) { + /* Scan the key buffer, clear all GELI keys. */ + for (i = 0; i < keybuf->kb_nents; i++) { + if (keybuf->kb_ents[i].ke_type == KEYBUF_TYPE_GELI) { + explicit_bzero(keybuf->kb_ents[i].ke_data, + sizeof(keybuf->kb_ents[i].ke_data)); + keybuf->kb_ents[i].ke_type = KEYBUF_TYPE_NONE; + } + } + } } static void zero_intake_passcache(void *dummy) { - zero_boot_passcache(); - zero_geli_intake_keys(); + zero_boot_passcache(); + zero_geli_intake_keys(); } EVENTHANDLER_DEFINE(mountroot, zero_intake_passcache, NULL, 0); @@ -269,7 +269,7 @@ g_eli_crypto_rerun(struct cryptop *crp) static void g_eli_getattr_done(struct bio *bp) { - if (bp->bio_error == 0 && + if (bp->bio_error == 0 && !strcmp(bp->bio_attribute, "GEOM::physpath")) { strlcat(bp->bio_data, "/eli", bp->bio_length); } @@ -891,8 +891,8 @@ g_eli_init_uma(void) * likely to see. */ g_eli_alloc_sz = roundup2((PAGE_SIZE + sizeof(int) + - G_ELI_AUTH_SECKEYLEN) * nsw_cluster_max + - sizeof(uintptr_t), PAGE_SIZE); + G_ELI_AUTH_SECKEYLEN) * nsw_cluster_max + + sizeof(uintptr_t), PAGE_SIZE); g_eli_uma = uma_zcreate("GELI buffers", g_eli_alloc_sz, NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); @@ -1327,7 +1327,7 @@ g_eli_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) u_char key[G_ELI_USERKEYLEN], mkey[G_ELI_DATAIVKEYLEN]; u_int i, nkey, nkeyfiles, tries, showpass; int error; - struct keybuf *keybuf; + struct keybuf *keybuf; g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name); g_topology_assert(); @@ -1372,116 +1372,116 @@ g_eli_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) tries = g_eli_tries; } - if ((keybuf = get_keybuf()) != NULL) { - /* Scan the key buffer, try all GELI keys. */ - for (i = 0; i < keybuf->kb_nents; i++) { - if (keybuf->kb_ents[i].ke_type == KEYBUF_TYPE_GELI) { - memcpy(key, keybuf->kb_ents[i].ke_data, - sizeof(key)); - - if (g_eli_mkey_decrypt_any(&md, key, - mkey, &nkey) == 0 ) { - explicit_bzero(key, sizeof(key)); - goto have_key; - } - } - } - } - - for (i = 0; i <= tries; i++) { - g_eli_crypto_hmac_init(&ctx, NULL, 0); - - /* - * Load all key files. - */ - nkeyfiles = g_eli_keyfiles_load(&ctx, pp->name); - - if (nkeyfiles == 0 && md.md_iterations == -1) { - /* - * No key files and no passphrase, something is - * definitely wrong here. - * geli(8) doesn't allow for such situation, so assume - * that there was really no passphrase and in that case - * key files are no properly defined in loader.conf. - */ - G_ELI_DEBUG(0, - "Found no key files in loader.conf for %s.", - pp->name); - return (NULL); - } - - /* Ask for the passphrase if defined. */ - if (md.md_iterations >= 0) { - /* Try first with cached passphrase. */ - if (i == 0) { - if (!g_eli_boot_passcache) - continue; - memcpy(passphrase, cached_passphrase, - sizeof(passphrase)); - } else { - printf("Enter passphrase for %s: ", pp->name); + if ((keybuf = get_keybuf()) != NULL) { + /* Scan the key buffer, try all GELI keys. */ + for (i = 0; i < keybuf->kb_nents; i++) { + if (keybuf->kb_ents[i].ke_type == KEYBUF_TYPE_GELI) { + memcpy(key, keybuf->kb_ents[i].ke_data, + sizeof(key)); + + if (g_eli_mkey_decrypt_any(&md, key, + mkey, &nkey) == 0 ) { + explicit_bzero(key, sizeof(key)); + goto have_key; + } + } + } + } + + for (i = 0; i <= tries; i++) { + g_eli_crypto_hmac_init(&ctx, NULL, 0); + + /* + * Load all key files. + */ + nkeyfiles = g_eli_keyfiles_load(&ctx, pp->name); + + if (nkeyfiles == 0 && md.md_iterations == -1) { + /* + * No key files and no passphrase, something is + * definitely wrong here. + * geli(8) doesn't allow for such situation, so assume + * that there was really no passphrase and in that case + * key files are no properly defined in loader.conf. + */ + G_ELI_DEBUG(0, + "Found no key files in loader.conf for %s.", + pp->name); + return (NULL); + } + + /* Ask for the passphrase if defined. */ + if (md.md_iterations >= 0) { + /* Try first with cached passphrase. */ + if (i == 0) { + if (!g_eli_boot_passcache) + continue; + memcpy(passphrase, cached_passphrase, + sizeof(passphrase)); + } else { + printf("Enter passphrase for %s: ", pp->name); showpass = g_eli_visible_passphrase; if ((md.md_flags & G_ELI_FLAG_GELIDISPLAYPASS) != 0) showpass = GETS_ECHOPASS; - cngets(passphrase, sizeof(passphrase), + cngets(passphrase, sizeof(passphrase), showpass); - memcpy(cached_passphrase, passphrase, - sizeof(passphrase)); - } - } - - /* - * Prepare Derived-Key from the user passphrase. - */ - if (md.md_iterations == 0) { - g_eli_crypto_hmac_update(&ctx, md.md_salt, - sizeof(md.md_salt)); - g_eli_crypto_hmac_update(&ctx, passphrase, - strlen(passphrase)); - explicit_bzero(passphrase, sizeof(passphrase)); - } else if (md.md_iterations > 0) { - u_char dkey[G_ELI_USERKEYLEN]; - - pkcs5v2_genkey(dkey, sizeof(dkey), md.md_salt, - sizeof(md.md_salt), passphrase, md.md_iterations); - explicit_bzero(passphrase, sizeof(passphrase)); - g_eli_crypto_hmac_update(&ctx, dkey, sizeof(dkey)); - explicit_bzero(dkey, sizeof(dkey)); - } - - g_eli_crypto_hmac_final(&ctx, key, 0); - - /* - * Decrypt Master-Key. - */ - error = g_eli_mkey_decrypt_any(&md, key, mkey, &nkey); - explicit_bzero(key, sizeof(key)); - if (error == -1) { - if (i == tries) { - G_ELI_DEBUG(0, - "Wrong key for %s. No tries left.", - pp->name); - g_eli_keyfiles_clear(pp->name); - return (NULL); - } - if (i > 0) { - G_ELI_DEBUG(0, - "Wrong key for %s. Tries left: %u.", - pp->name, tries - i); - } - /* Try again. */ - continue; - } else if (error > 0) { - G_ELI_DEBUG(0, - "Cannot decrypt Master Key for %s (error=%d).", - pp->name, error); - g_eli_keyfiles_clear(pp->name); - return (NULL); - } - g_eli_keyfiles_clear(pp->name); - G_ELI_DEBUG(1, "Using Master Key %u for %s.", nkey, pp->name); - break; - } + memcpy(cached_passphrase, passphrase, + sizeof(passphrase)); + } + } + + /* + * Prepare Derived-Key from the user passphrase. + */ + if (md.md_iterations == 0) { + g_eli_crypto_hmac_update(&ctx, md.md_salt, + sizeof(md.md_salt)); + g_eli_crypto_hmac_update(&ctx, passphrase, + strlen(passphrase)); + explicit_bzero(passphrase, sizeof(passphrase)); + } else if (md.md_iterations > 0) { + u_char dkey[G_ELI_USERKEYLEN]; + + pkcs5v2_genkey(dkey, sizeof(dkey), md.md_salt, + sizeof(md.md_salt), passphrase, md.md_iterations); + explicit_bzero(passphrase, sizeof(passphrase)); + g_eli_crypto_hmac_update(&ctx, dkey, sizeof(dkey)); + explicit_bzero(dkey, sizeof(dkey)); + } + + g_eli_crypto_hmac_final(&ctx, key, 0); + + /* + * Decrypt Master-Key. + */ + error = g_eli_mkey_decrypt_any(&md, key, mkey, &nkey); + explicit_bzero(key, sizeof(key)); + if (error == -1) { + if (i == tries) { + G_ELI_DEBUG(0, + "Wrong key for %s. No tries left.", + pp->name); + g_eli_keyfiles_clear(pp->name); + return (NULL); + } + if (i > 0) { + G_ELI_DEBUG(0, + "Wrong key for %s. Tries left: %u.", + pp->name, tries - i); + } + /* Try again. */ + continue; + } else if (error > 0) { + G_ELI_DEBUG(0, + "Cannot decrypt Master Key for %s (error=%d).", + pp->name, error); + g_eli_keyfiles_clear(pp->name); + return (NULL); + } + g_eli_keyfiles_clear(pp->name); + G_ELI_DEBUG(1, "Using Master Key %u for %s.", nkey, pp->name); + break; + } have_key: /*