mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 19:00:02 +01:00
Warn if block exceeds page size.
This commit is contained in:
@@ -76,6 +76,8 @@ ssize_t write_lseek_blockwise(int fd, char *buf, size_t count, off_t offset);
|
||||
int device_ready(struct crypt_device *cd, const char *device, int mode);
|
||||
int device_size(const char *device, uint64_t *size);
|
||||
|
||||
int crypt_getpagesize(void);
|
||||
|
||||
enum devcheck { DEV_OK = 0, DEV_EXCL = 1, DEV_SHARED = 2 };
|
||||
int device_check_and_adjust(struct crypt_device *cd,
|
||||
const char *device,
|
||||
|
||||
@@ -38,6 +38,11 @@
|
||||
#include "libcryptsetup.h"
|
||||
#include "internal.h"
|
||||
|
||||
int crypt_getpagesize(void)
|
||||
{
|
||||
return (int)sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
static int get_alignment(int fd)
|
||||
{
|
||||
int alignment = DEFAULT_MEM_ALIGNMENT;
|
||||
|
||||
@@ -346,9 +346,16 @@ int VERITY_create(struct crypt_device *cd,
|
||||
char *root_hash,
|
||||
size_t root_hash_size)
|
||||
{
|
||||
int pgsize = crypt_getpagesize();
|
||||
|
||||
if (verity_hdr->salt_size > VERITY_MAX_SALT_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
if (verity_hdr->hash_block_size > pgsize ||
|
||||
verity_hdr->data_block_size > pgsize)
|
||||
log_err(cd, _("WARNING: Kernel cannot activate device if block "
|
||||
"size exceeds page size (%u).\n"), pgsize);
|
||||
|
||||
return VERITY_create_or_verify_hash(cd, 0,
|
||||
verity_hdr->version,
|
||||
verity_hdr->hash_name,
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
* - audit alloc errors / error path
|
||||
* - change command names (cryptsetup style)
|
||||
* - extend superblock (UUID)
|
||||
* - warn if block_size > PAGE_SIZE
|
||||
* - configure.in/config.h defaults
|
||||
*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user