Commit 0b60be16 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Mikulas Patocka
Browse files

dm: Constify struct dm_block_validator



'struct dm_block_validator' are not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig, as an example:

Before:
======
   text	   data	    bss	    dec	    hex	filename
  32047	    920	     16	  32983	   80d7	drivers/md/dm-cache-metadata.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  32075	    896	     16	  32987	   80db	drivers/md/dm-cache-metadata.o

Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
parent fb098768
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -170,7 +170,7 @@ struct dm_cache_metadata {
 */
#define SUPERBLOCK_CSUM_XOR 9031977

static void sb_prepare_for_write(struct dm_block_validator *v,
static void sb_prepare_for_write(const struct dm_block_validator *v,
				 struct dm_block *b,
				 size_t sb_block_size)
{
@@ -195,7 +195,7 @@ static int check_metadata_version(struct cache_disk_superblock *disk_super)
	return 0;
}

static int sb_check(struct dm_block_validator *v,
static int sb_check(const struct dm_block_validator *v,
		    struct dm_block *b,
		    size_t sb_block_size)
{
@@ -228,7 +228,7 @@ static int sb_check(struct dm_block_validator *v,
	return check_metadata_version(disk_super);
}

static struct dm_block_validator sb_validator = {
static const struct dm_block_validator sb_validator = {
	.name = "superblock",
	.prepare_for_write = sb_prepare_for_write,
	.check = sb_check
+3 −3
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ struct dm_clone_metadata {
/*
 * Superblock validation.
 */
static void sb_prepare_for_write(struct dm_block_validator *v,
static void sb_prepare_for_write(const struct dm_block_validator *v,
				 struct dm_block *b, size_t sb_block_size)
{
	struct superblock_disk *sb;
@@ -177,7 +177,7 @@ static void sb_prepare_for_write(struct dm_block_validator *v,
	sb->csum = cpu_to_le32(csum);
}

static int sb_check(struct dm_block_validator *v, struct dm_block *b,
static int sb_check(const struct dm_block_validator *v, struct dm_block *b,
		    size_t sb_block_size)
{
	struct superblock_disk *sb;
@@ -220,7 +220,7 @@ static int sb_check(struct dm_block_validator *v, struct dm_block *b,
	return 0;
}

static struct dm_block_validator sb_validator = {
static const struct dm_block_validator sb_validator = {
	.name = "superblock",
	.prepare_for_write = sb_prepare_for_write,
	.check = sb_check
+3 −3
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ struct superblock_disk {
 * Superblock validation
 *--------------------------------------------------------------
 */
static void sb_prepare_for_write(struct dm_block_validator *v,
static void sb_prepare_for_write(const struct dm_block_validator *v,
				 struct dm_block *b,
				 size_t sb_block_size)
{
@@ -221,7 +221,7 @@ static int check_metadata_version(struct superblock_disk *disk)
	return 0;
}

static int sb_check(struct dm_block_validator *v,
static int sb_check(const struct dm_block_validator *v,
		    struct dm_block *b,
		    size_t sb_block_size)
{
@@ -254,7 +254,7 @@ static int sb_check(struct dm_block_validator *v,
	return check_metadata_version(disk);
}

static struct dm_block_validator sb_validator = {
static const struct dm_block_validator sb_validator = {
	.name = "superblock",
	.prepare_for_write = sb_prepare_for_write,
	.check = sb_check
+3 −3
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ struct dm_thin_device {
 */
#define SUPERBLOCK_CSUM_XOR 160774

static void sb_prepare_for_write(struct dm_block_validator *v,
static void sb_prepare_for_write(const struct dm_block_validator *v,
				 struct dm_block *b,
				 size_t block_size)
{
@@ -261,7 +261,7 @@ static void sb_prepare_for_write(struct dm_block_validator *v,
						      SUPERBLOCK_CSUM_XOR));
}

static int sb_check(struct dm_block_validator *v,
static int sb_check(const struct dm_block_validator *v,
		    struct dm_block *b,
		    size_t block_size)
{
@@ -294,7 +294,7 @@ static int sb_check(struct dm_block_validator *v,
	return 0;
}

static struct dm_block_validator sb_validator = {
static const struct dm_block_validator sb_validator = {
	.name = "superblock",
	.prepare_for_write = sb_prepare_for_write,
	.check = sb_check
+3 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ struct array_block {
 */
#define CSUM_XOR 595846735

static void array_block_prepare_for_write(struct dm_block_validator *v,
static void array_block_prepare_for_write(const struct dm_block_validator *v,
					  struct dm_block *b,
					  size_t size_of_block)
{
@@ -50,7 +50,7 @@ static void array_block_prepare_for_write(struct dm_block_validator *v,
						 CSUM_XOR));
}

static int array_block_check(struct dm_block_validator *v,
static int array_block_check(const struct dm_block_validator *v,
			     struct dm_block *b,
			     size_t size_of_block)
{
@@ -77,7 +77,7 @@ static int array_block_check(struct dm_block_validator *v,
	return 0;
}

static struct dm_block_validator array_validator = {
static const struct dm_block_validator array_validator = {
	.name = "array",
	.prepare_for_write = array_block_prepare_for_write,
	.check = array_block_check
Loading