nbdkit-protect-filter(1)

πŸ’– nbdkit-protect-filter(1) πŸ’–

okay bestie, welcome to the NBDKIT manual, this one's all about nbdkit-protect-filter, and honestly? it's giving bodyguard energy. let's get into it 🫢


✨ NAME ✨

nbdkit-protect-filter β€” write-protect parts of a plugin πŸ›‘οΈ


✨ SYNOPSIS ✨

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

✨ DESCRIPTION ✨

so nbdkit-protect-filter is a filter for nbdkit(1) and what it does is let you write-protect parts of the underlying plugin. like, clients can't modify certain ranges of the plugin, but the NBD connection as a whole can still be writable. best of both worlds, no cap πŸ’…

one use for this? keeping clients from slapping a phony header onto the data so it looks like a non-raw disk format (think: adding a qcow2 header). because apparently that can be used in some exploits. not today, babes πŸ’€

if you want the whole plugin to be readonly, use the nbdkit -r option on the command line, or nbdkit-readonly-filter(1). if you want to give selective access to the server, that's nbdkit-ip-filter(1). and if you only wanna serve a subset of the plugin, go hang out with nbdkit-offset-filter(1) or nbdkit-partition-filter(1). pick your fighter ✨


✨ EXAMPLES ✨

πŸŽ€ Protect the boot sector

protect the first part of the boot sector from writes, but let the MBR partition table still get updated. iconic:

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

πŸŽ€ Protect everything except a single partition

let clients write to one partition on the disk, but block modifications to the partition table, boot sector, other partitions, or literally any other metadata outside that 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, bestie, don't skip these:

  • data in other partitions and other parts of the disk is still readable. reading is free, writing is not πŸ“
  • the ~ character complements the range protected. you might need to escape it from the shell using quotes or a backslash. the shell is dramatic like that 😭
  • this is different from nbdkit-partition-filter(1) β€” that filter exposes the partition as a whole device. two different vibes, two different filters πŸ’œ

✨ PARAMETERS ✨

  • protect=START-END β€” protects the bytes starting at offset START through to offset END (inclusive). reads are permitted. writes to the protected range are only permitted if they don't change the content. if an attempt is made to change the content, then the error NBD_EPERM (Operation not permitted) gets returned to the client. periodt, no touching πŸ™ˆ

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. so chill of them ✨

this parameter can be given multiple times to protect several ranges. stack 'em up, queen πŸ‘‘

  • protect=~START-END β€” this protects the complement of the range START to END. everything except that range, basically the inverse slay πŸ¦‹

✨ FILES ✨

  • $filterdir/nbdkit-protect-filter.so β€” the filter itself. the whole moment.

use nbdkit --dump-config to find the location of $filterdir. it's right there, go look πŸ”


✨ VERSION ✨

nbdkit-protect-filter first appeared in nbdkit 1.30. a true icon of its era πŸ‘‘


✨ SEE ALSO ✨

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

the whole friend group, fr fr πŸ’–


✨ AUTHORS ✨

Richard W.M. Jones 🌸


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:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
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.

k bye bestie, this page came from nbdkit-1.48.1 and it was dated 2026-08-29. go protect those ranges πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from