NAME

nbdkit-protect-filter - write-protect parts of a plugin

SYNOPSIS

 nbdkit --filter=protect plugin protect=START-END [protect=...]

DESCRIPTION

nbdkit-protect-filter is a filter for nbdkit(1) that lets you write-protect parts of the underlying plugin. This prevents clients from modifying ranges of the plugin, while still allowing the NBD connection to be writable in general.

One use for this is to prevent clients from adding a phony header to the data to make it look like a non-raw disk format (like adding a qcow2 header), since that can be used in some exploits.

To make the whole plugin readonly, use the nbdkit -r option on the command line, or nbdkit-readonly-filter(1). To give selective access to the server, use nbdkit-ip-filter(1). To serve only a subset of the plugin use nbdkit-offset-filter(1) or nbdkit-partition-filter(1).

EXAMPLES

Protect the boot sector

Protect the first part of the boot sector from writes, but allow the MBR partition table to be updated:

 nbdkit --filter=protect file disk.img protect=0-0x1bd

Protect everything except a single partition

Allow clients to write to a single partition on the disk, but prevent modifications to the partition table, boot sector, other partitions, or any other metadata outside the partition:

 $ fdisk -l disk.img
 Device    Boot  Start       End  Sectors Size Id Type
 disk.img1 *      2048  12580863 12578816   6G 83 Linux
 $ start=$((2048*512))
 $ end=$((12580863*512+511))
 $ nbdkit --filter=protect file disk.img protect=~$start-$end

Notes:

PARAMETERS

protect=START-END

Protect the bytes starting at offset START through to offset END (inclusive). Reads are permitted. Writes to the protected range are only permitted if they do not change the content. If an attempt is made to change the content, then the error NBD_EPERM (Operation not permitted) is returned to the client.

START and END can be expressed in decimal, octal (0NN) or hexadecimal (0xNN). If omitted then they default to the start and end of the underlying plugin respectively.

This parameter can be given multiple times to protect several ranges.

protect=~START-END

This protects the complement of the range START to END.

FILES

$filterdir/nbdkit-protect-filter.so

The filter.

Use nbdkit --dump-config to find the location of $filterdir.

VERSION

nbdkit-protect-filter first appeared in nbdkit 1.30.

SEE ALSO

nbdkit(1), nbdkit-file-plugin(1), nbdkit-ip-filter(1), nbdkit-offset-filter(1), nbdkit-partition-filter(1), nbdkit-readonly-filter(1), nbdkit-filter(3).

AUTHORS

Richard W.M. Jones

COPYRIGHT

Copyright Red Hat

LICENSE

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.