nbdkit-protect-filter(1) | NBDKIT | nbdkit-protect-filter(1) |
nbdkit-protect-filter - write-protect parts of a plugin
nbdkit --filter=protect plugin protect=START-END [protect=...]
"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. 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).
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
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:
"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.
Use "nbdkit --dump-config" to find the location of $filterdir.
"nbdkit-offset-filter" first appeared in nbdkit 1.30.
nbdkit(1), nbdkit-file-plugin(1), nbdkit-ip-filter(1), nbdkit-offset-filter(1), nbdkit-partition-filter(1), nbdkit-filter(3).
Richard W.M. Jones
Copyright (C) 2021 Red Hat Inc.
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.
2023-01-04 | nbdkit-1.32.5 |