Commit graph

27 commits

Author SHA1 Message Date
Warner Losh 3e15b01d69 libsa: Remove redundant sys/cdefs.h
Sponsored by:		Netflix
2024-02-22 09:31:57 -07:00
Warner Losh fd577b59b2 libsa: Move hash functions up a level
This should have no functional change. Move compiling the sha256, sha512
and md5 hash functions up into libsa to allow them to be used elsewhere
in the boot loader when geli isn't configured. Since libsa is a .a, these
won't wind up in any boot loader that doesn't reference them, so should
be a nop.

Sponsored by:		Netflix
2024-02-02 14:01:03 -07:00
Warner Losh 6e28a6bc2e stand: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:29 -07:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Warner Losh 8337ab69ba stand: For all disk drivers, connect dv_parsedev to disk_parsedev
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D37339
2022-11-30 15:30:32 -07:00
Warner Losh bb3230e40b geli: Move check for DEVT_DISK into geli_probe_and_attach
We only work on DEVT_DISK disks, so move that into the probe to drive
the point home better.

Sponsored by:		Netflix
2022-10-22 19:47:24 -06:00
Warner Losh 787df454c8 stabd/geli: Bail out if you can't get the disks size
If the DIOCGMEDIASIZE ioctl fails, assume the disk doesn't have geli
encryption. While all disks should implement this, fail safe for disks /
partitions that do not.

Sponsored by:		Netflix
2022-10-21 17:39:34 -06:00
Warner Losh ad759c7352 stand: Add disk_fmtdev for dv_fmtdev for all the disk devices
All of the archsw fmtdev functions treat DEVT_DISK as a call to
disk_fmtdev. Set all disks' dv_fmtdev to disk_fmtdev so devformat
will return the same thing.

Sponsored by:		Netflix
Reviewed by:		tsoome (prior version)
Differential Revision:	https://reviews.freebsd.org/D35917
2022-08-11 10:27:16 -06:00
Warner Losh c32dde3166 stand: Change disk_fmtdev to take a struct devdesc *
We do a number of games with ploymorphism for different types struct
*devdesc. Adjust one place that this affects to take the address of the
base class (most others have void * at the moment). This is more type
safe than a bare void *.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D35914
2022-08-11 10:27:15 -06:00
Warner Losh f863970a82 stand: Reduce number of files that need -I${LDRSRC}
geliboot.c and geliboot_crypto.c don't need anything from stand/common,
so remove them from the list of things to add it.

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D35921
2022-08-03 11:24:38 -06:00
Warner Losh 4333168b1d stand: Remove unneeded include from geli
bootstrap.h isn't needed at all by geil, so remove it.

Sponsored by:		Netflix
Reviewed by:		tsoome (earlier version)
Differential Revision:	https://reviews.freebsd.org/D35920
2022-08-03 11:24:38 -06:00
John Baldwin bb7ddd077c stand geli: Restore include path to LDRSRC.
Various GELI sources need bootstrap.h and disk.h. In theory they
shouldn't need anything outside of libsa, but disk.h and bootstrap.h are
currently required.

This fixes the build with MK_LOADER_ZFS=no.

Obtained from: CheriBSD
Fixes: eaf7aabddc stand: geli CFLAGS tightening
Sponsored by: DARPA
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D35861
2022-07-22 10:08:46 -06:00
Warner Losh eaf7aabddc stand: geli CFLAGS tightening
Only add -DWEAK_REFS to sha256.c and sha512.c instead of
everything. Remove redundant include that's not needed.
Minor formatting tweak.

Sponsored by:		Netflix
2022-07-08 11:47:36 -06:00
Toomas Soome e417249016 loader: GELI encrypted disk should still use device name disk
geli_probe_and_attach() does pick geli_devsw structure for
encrypted disks, the implementation depends on device
name "disk" when device type is DEVT_DISK, but geli_devsw is
setting name field "gelidisk".

PR:		264282
Submitted by:	yamagi@yamagi.org
Reported by:	yamagi@yamagi.org
MFC after:	2 weeks
2022-06-20 10:10:14 +03:00
Gordon Bergling 9cd75b5588 stand: Fix a common typo in source code comments
- s/existance/existence/

MFC after:	3 days
2022-03-28 19:34:30 +02:00
John Baldwin c7721958ff geliboot: Use the correct IV length for AES-XTS.
- Use AES_XTS_IV_LEN instead of the key length as the IV length.
- Use G_ELI_IVKEYLEN as the size of the zeroed iv[] array in
  g_eli_crypto_cipher() to match geli_io().

PR:		261172
Reported by:	Malcolm Matalka <mmatalka@gmail.com>, mikael
Reviewed by:	markj
Sponsored by:	FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33884
2022-01-13 17:19:54 -08:00
John Baldwin b156362338 geliboot: Use the multi-block functions for AES-XTS.
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33530
2022-01-11 14:18:12 -08:00
Kyle Evans d586c978b9 stand: fix build after recent opencrypto changes
Pass the ivlen along through, and just drop this KASSERT() if we're
building _STANDALONE for the time being.

Fixes:	1833d6042c ("crypto: Permit variable-sized IVs ...")
2021-10-06 20:23:44 -05:00
Toomas Soome de776da323 loader: implement GELI writes
Bug: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247482

This patch is based on initial work from allanjude.

PR:		247482
Obtained from:	https://reviews.freebsd.org/D10236
Differential Revision:	https://reviews.freebsd.org/D25605
2020-07-11 06:51:42 +00:00
Toomas Soome 0d1a620681 loader: geli_dev_ioctl does return huge mediasize
The DIOCGMEDIASIZE is calculated md->md_sectorsize * md->md_provsize, and
for boot disk, the md_sectorsize is 4k. However, the md_provsize is already
in units of bytes.

Sponsored by:	Netflix, Klara Inc.
2020-07-07 12:24:40 +00:00
John Baldwin 4f98ffdd1d Fix libstand build breakage after r361298.
- Use enc_xform_aes_xts.setkey() directly instead of duplicating the code
  now that it no longer calls malloc().
- Rather than bringing back all of xform_userland.h, add a conditional
  #include of <stand.h> to xform_enc.h.
- Update calls to encrypt/decrypt callbacks in enc_xform_aes_xts for
  separate input/output pointers.

Pointy hat to:	jhb
2020-05-20 22:25:41 +00:00
Warner Losh 47bec71dd0 Use if rather than case for a simple boolean. gcc thinks blks is
undefined sometimes with the case, but enc is always 0 or 1, so
and if / else is better anyway.
2018-07-13 18:19:33 +00:00
Ian Lepore c1418270b2 Extend loader(8) geli support to all architectures and all disk-like devices.
This moves the bulk of the geli support from lib386/biosdisk.c into a new
geli/gelidev.c which implements a devsw-type device whose dv_strategy()
function handles geli decryption. Support for all arches comes from moving
the taste-and-attach code to the devopen() function in libsa.

After opening any DEVT_DISK device, devopen() calls the new function
geli_probe_and_attach(), which will "attach" the geli code to the open_file
struct by creating a geli_devdesc instance to replace the disk_devdesc
instance in the open_file. That routes all IO for the device through the
geli code.

A new public geli_add_key() function is added, to allow arch/vendor-specific
code to add keys obtained from custom hardware or other sources.

With these changes, geli support will be compiled into all variations of
loader(8) on all arches because the default is WITH_LOADER_GELI.

Relnotes:	yes
Sponsored by:	Microchip Technology Inc
Differential Revision:	https://reviews.freebsd.org/D15743
2018-07-13 17:50:25 +00:00
Warner Losh 62bd02cee5 stand: move libgeliboot into libsa.
Reduce by 1 the number of crazy libraries we need in stand by moving
geli into libsa (where architecturally it belonged all along). This
just moves things around without any code changes.
2018-06-18 16:24:42 +00:00