Commit Graph

1540 Commits

Author SHA1 Message Date
Andrey V. Elsukov
799eac8c3d Limit maximum number of GPT entries to 4k. It is most realistic value
and can prevent kernel memory exhausting when big value is specified
from command line.

Split reading and writing operation to several iteration to do not
trigger KASSERT when data length is greater than MAXPHYS.

PR:             kern/144962, kern/147851
MFC after:      2 weeks
2011-01-18 09:52:53 +00:00
Matthew D Fleming
0c2b0e03f7 sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.
Commit the geom piece.
2011-01-12 19:54:07 +00:00
Andrey V. Elsukov
95959703e1 Sector size can not be greater than MAXPHYS. Since GRAID3 calculates
sector size from user-specified block size, report to user about
big blocksize.

PR:		kern/147851
MFC after:	1 week
2011-01-12 13:55:01 +00:00
Andrey V. Elsukov
e76dc5129a Sector size can not be greater than MAXPHYS.
MFC after:	1 week
2011-01-12 12:26:10 +00:00
Andrey V. Elsukov
eaaef50811 Remove redundant check.
MFC after:	1 week
2011-01-11 13:22:20 +00:00
Andrey V. Elsukov
f2b3e9e870 Round GNOP provider's mediasize to its sectorsize. This prevents KASSERT
in g_io_request when geom classes doing tasting.

PR:		kern/147852
MFC after:	1 week
2011-01-11 11:42:22 +00:00
Matthew D Fleming
ed7beddc48 Fix a memory overflow where the input length to g_gpt_utf8_to_utf16()
was specified incorrectly, causing the bzero to run past the end of a
malloc(9)'d object.

Submitted by:	Eric Youngblut < eyoungblut AT isilon DOT com >
MFC after:	3 days
2011-01-07 16:46:20 +00:00
Nathan Whitehorn
e76b061420 Add an entry to the gpart XML to determine if the geom has pending changes
that need to be committed (or undone).

MFC after:	2 weeks
2011-01-06 03:36:04 +00:00
Konstantin Belousov
23b70c1ae2 Finish r210923, 210926. Mark some devices as eternal.
MFC after:	2 weeks
2011-01-04 10:59:38 +00:00
Konstantin Belousov
d91e813c7b Add reporting of GEOM::candelete BIO_GETATTR for md(4) and geom_disk(4).
Non-zero value of attribute means that device supports BIO_DELETE.

Suggested and reviewed by:	pjd
Tested by:	pho
MFC after:	1 week
2010-12-29 12:11:07 +00:00
Andrey V. Elsukov
f25481193e Allow destroying EBR in COMPAT (default) mode.
MFC after:	2 week
2010-12-28 08:42:12 +00:00
Andrey V. Elsukov
d3507dff37 Make EBR probe method less strictly to be able detect EBRs with
small non fatal inconsistency. EBR may contain boot loader and sometimes
it just has some garbage data. Now this does not prevent FreeBSD to use
extended partitions. But since we do not support bootcode for EBR we mark
tables which have non empty boot area as corrupt. This does make them
readonly and we can not damage this data.

PR:		kern/141235
MFC after:	1 month
2010-12-28 08:36:44 +00:00
Rebecca Cran
fa5f3816c4 Don't warn if a partition appears not to be aligned on a track boundary.
Modern disks use LBA and create a fake CHS geometry that doesn't have any
relation to the on-disk layout of data.
2010-12-07 20:46:11 +00:00
Ivan Voras
e5c723f123 Add a note about the magic number 20. Actually, 22.75 entries fit in
a 512 byte sector but when choosing magic numbers, 20 looks nicer.

Discussed with:	marcel
2010-12-02 19:47:27 +00:00
Jaakko Heinonen
e5a2338118 - Report an error when a label with invalid name is attempted to be
created with glabel(8).
- Fix a typo in an error message.
- Fix comment typos.

Approved by:	pjd
2010-12-01 19:24:07 +00:00
Jaakko Heinonen
f7842e00f5 Use g_eventlock to protect against losing wakeups in the g_event process
and replace tsleep(9) with msleep(9) which doesn't use a timeout. The
previously used timeout caused the event process to wake up ten times
per second on an idle system.

one_event() is now called with the topology lock held and it returns
with both the topology and event locks held when there are no more
events in the queue.

Reported by:	mav, Marius Nünnerich
Reviewed by:	freebsd-geom
2010-11-22 16:47:53 +00:00
Ed Schouten
eb4c31fd41 Add support for asterisk characters when filling in the GELI password
during boot.

Change the last argument of gets() to indicate a visibility flag and add
definitions for the numerical constants. Except for the value 2, gets()
will behave exactly the same, so existing consumers shouldn't break. We
only use it in two places, though.

Submitted by:	lme (older version)
2010-11-14 14:12:43 +00:00
Andrey V. Elsukov
55514bdfc0 Fix regression introduced in r215088: gpart(8) reports
"arg0 'provider': Invalid argument" after creating new partition
table.
Move code for search of existing geom into g_part_find_geom
function and use this function instead of g_part_parm_geom
in g_part_ctl_create.

Approved by:	kib (mentor)
2010-11-11 12:13:41 +00:00
Andrey V. Elsukov
7085c3bc98 In r212554 name of G_PART_PARM_GEOM and G_PART_PARM_PROVIDER
ctlreq parameters was changed to "arg0". Fix the last place where
it is used.

Approved by:	kib (mentor)
2010-11-10 14:38:51 +00:00
Jaakko Heinonen
9d142a6ee6 Extend the g_eventlock mutex coverage in one_event() to include setting
of the EV_DONE flag and use the mutex to protect against losing wakeups
in g_waitfor_event().

Reported by:	davidxu
Tested by:	davidxu
Discussed on:	freebsd-current
2010-11-03 16:19:35 +00:00
Andrey V. Elsukov
e7926a3703 Reimplemented "gpart destroy -F". Now it does all work in kernel.
This was needed for recover implementation.

Implement the recover command for GPT. Now GPT will marked as
corrupt when any of three types of corruption will be detected:
1. Damaged primary GPT header or table
2. Damaged secondary GPT header or table
3. Secondary header is not located in the last LBA
Marked GPT becomes read-only. Any changes with corrupt table
are prohibited. Only "destroy" and "recover" commands are allowed.

Discussed with:	geom@ (mostly silence)
Tested by:	Ilya A. Arhipov
Approved by:	mav (mentor)
MFC after:	2 weeks
2010-10-25 16:23:35 +00:00
Pawel Jakub Dawidek
0d2f5a4eaa - Improve error messages, so instead of 'Not fully done', the user will get
information that device is already suspended or that device is using
  one-time key and suspend is not supported.
- 'geli suspend -a' silently skips devices that use one-time key, this is fine,
  but because we log which device were suspended on the console, log also which
  devices were skipped.
2010-10-22 22:58:00 +00:00
Pawel Jakub Dawidek
2f2d7830b5 Close a race between checking if device is already suspended and suspending it. 2010-10-22 22:54:26 +00:00
Pawel Jakub Dawidek
d8d61ef8fc Add State tag, so 'geli status' will report active/suspended status, eg:
# geli status
	   Name     Status  Components
	da0.eli  SUSPENDED  da0
	da1.eli     ACTIVE  da1
2010-10-22 22:45:26 +00:00
Pawel Jakub Dawidek
4f294e1289 Encryption keys array might be NULL if device is suspended. Check for this, so
we don't panic when we detach suspended device.
2010-10-22 22:44:09 +00:00
Pawel Jakub Dawidek
1d0214411e Move sc_akeyctx and sc_ivctx initialization to the g_eli_mkey_propagate()
function which eliminates code duplication and will ensure proper order
of operation.
2010-10-22 22:13:11 +00:00
Pawel Jakub Dawidek
3ac01bc2ae Free opencrypto sessions on suspend, as they also might keep encryption keys. 2010-10-21 19:44:28 +00:00
Pawel Jakub Dawidek
738ffa9780 Fix a bug introduced in r213067 where we use authentication key before
initializing it.
2010-10-21 12:58:26 +00:00
Pawel Jakub Dawidek
5ad4a7c74a Bring in geli suspend/resume functionality (finally).
Before this change if you wanted to suspend your laptop and be sure that your
encryption keys are safe, you had to stop all processes that use file system
stored on encrypted device, unmount the file system and detach geli provider.

This isn't very handy. If you are a lucky user of a laptop where suspend/resume
actually works with FreeBSD (I'm not!) you most likely want to suspend your
laptop, because you don't want to start everything over again when you turn
your laptop back on.

And this is where geli suspend/resume steps in. When you execute:

	# geli suspend -a

geli will wait for all in-flight I/O requests, suspend new I/O requests, remove
all geli sensitive data from the kernel memory (like encryption keys) and will
wait for either 'geli resume' or 'geli detach'.

Now with no keys in memory you can suspend your laptop without stopping any
processes or unmounting any file systems.

When you resume your laptop you have to resume geli devices using 'geli resume'
command. You need to provide your passphrase, etc. again so the keys can be
restored and suspended I/O requests released.

Of course you need to remember that 'geli suspend' won't clear file system
cache and other places where data from your geli-encrypted file system might be
present. But to get rid of those stopping processes and unmounting file system
won't help either - you have to turn your laptop off. Be warned.

Also note, that suspending geli device which contains file system with geli
utility (or anything used by 'geli resume') is not very good idea, as you won't
be able to resume it - when you execute geli(8), the kernel will try to read it
and this read I/O request will be suspended.
2010-10-20 20:50:55 +00:00
Pawel Jakub Dawidek
056638c469 - Add missing comments.
- Make a comment consistent with others.
2010-10-20 20:01:45 +00:00
Jaakko Heinonen
bc2589f5b7 Use make_dev_p(9) with the MAKEDEV_CHECKNAME flag instead of make_dev(9)
and print a diagnostic if the call fails.

This avoids a panic when a device with an invalid name is attempted to
be registered. For example the label class gets device names from
untrusted input.

Reviewed by:	freebsd-geom
2010-10-19 16:48:49 +00:00
Rui Paulo
42a783c16a The canonical way to print __func__ when using KASSERT() is to write
("%s", __func__). This avoids clang's -Wformat-string warnings.
2010-10-13 11:35:59 +00:00
Andrey V. Elsukov
21bf062e7e Replace strlen(_PATH_DEV) with sizeof(_PATH_DEV) - 1.
Suggested by:	kib
Approved by:	kib (mentor)
MFC after:	5 days
2010-10-09 20:20:27 +00:00
Ulf Lilleengen
de02b15928 - Check flag with the bitwise operator, not the logical operator.
Submitted by:	arundel
MFC after:	1 week
2010-10-01 06:12:13 +00:00
Andrey V. Elsukov
b1da166ef1 Some schemes can allocate memory for internal purposes but when
GEOM does withering this memory doesn't freed. Add G_PART_DESTROY
call to g_part_wither. Also add missed g_free() call to G_PART_READ
method for MBR and PC98 schemes.

Submitted by:	jh (previous version)
Reviewed by:	pjd
Approved by:	kib (mentor)
2010-09-25 18:27:29 +00:00
Pawel Jakub Dawidek
f95168e08d Change g_eli_debug to int, so one can turn off any GELI output by setting
kern.geom.eli.debug sysctl to -1.

MFC after:	2 weeks
2010-09-25 10:32:04 +00:00
Pawel Jakub Dawidek
350e8df8de Ignore errors from BIO_FLUSH. It might confuse users that provider wasn't
really killed. What we really care about are write errors only.

MFC after:	2 weeks
2010-09-25 10:31:05 +00:00
Pawel Jakub Dawidek
cec283baf4 Allow to configure GPT attributes. It shouldn't be allowed to set bootfailed
attribute (it should be allowed only to unset it), but for test purposes it
might be useful, so the current code allows it.

Reviewed by:	arch@ (Message-ID: <20100917234542.GE1902@garage.freebsd.pl>)
MFC after:	2 weeks
2010-09-24 19:33:47 +00:00
Pawel Jakub Dawidek
9839c97b4d Update copyright years.
MFC after:	1 week
2010-09-23 12:02:08 +00:00
Pawel Jakub Dawidek
9a5a1d1e1e Add support for AES-XTS. This will be the default now.
MFC after:	1 week
2010-09-23 11:58:36 +00:00
Pawel Jakub Dawidek
c6a26d4c88 Implement switching of data encryption key every 2^20 blocks.
This ensures the same encryption key won't be used for more than
2^20 blocks (sectors). This will be the default now.

MFC after:	1 week
2010-09-23 11:49:47 +00:00
Pawel Jakub Dawidek
1f0fb66f30 Make the code similar to the code in g_eli_integrity.c.
MFC after:	1 week
2010-09-23 11:23:10 +00:00
Pawel Jakub Dawidek
b35bfe7e10 Define default overwrite count, so that userland can use it.
MFC after:	1 week
2010-09-23 11:19:48 +00:00
Pawel Jakub Dawidek
5e6dce4bf0 When trashing metadata, flush after each write.
MFC after:	1 week
2010-09-23 10:43:37 +00:00
Brian Somers
0f81f3046d Support attaching version 4 metadata
Reviewed by:	pjd
2010-09-19 10:45:53 +00:00
Alexander Motin
659f684ea0 Add support for dumping kernel to gconcat.
Dumping goes to the component, where dump partition begins.
2010-09-16 17:24:25 +00:00
Pawel Jakub Dawidek
2738b715ea Change message when setting or unsetting attribute less confusing.
Before:

	ada0 has <attrib> set

After:

	<attrib> set on ada0

MFC after:	2 weeks
2010-09-15 21:15:00 +00:00
Pawel Jakub Dawidek
2f4e9a099b Make the message that informs about bootcode being written to disk less
confusing.

Note there is still no information about 'partcode' being written to disk
(gpart bootcode -p <partcode> <disk>).

Maybe in the future all the messages printed by gpart(8) on success could be
hidden under -v?

PR:		bin/150239
Reported by:	Roddi <roddi@me.com>
Submitted by:	arundel
MFC after:	2 weeks
2010-09-15 20:59:13 +00:00
Pawel Jakub Dawidek
8107ecf892 - Change all places where G_TYPE_ASCNUM is used to G_TYPE_NUMBER.
It turns out the new type wasn't really needed.
- Reorganize code a little bit.
2010-09-14 16:21:13 +00:00
Pawel Jakub Dawidek
b312136354 Simplify the code a bit. 2010-09-14 11:42:07 +00:00