Re: [Question] Editing a bio write request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 18, 2022 at 01:56:31PM +0300, Jasper Surmont wrote:
> I'm writing a device-mapper which has to edit incoming writes, for
> example: Incoming bio request contains a biovec with a page full of 0
> bytes, and I want to change it to all 0xFF bytes.
> 
> I tried using bvec_kmap_local() to get the page address, to then read
> the data and if needed adjust it using memcpy or similar. Initial
> tests seemed to work, but if I execute things like mkfs on the created
> dm, I get a lot of segmentation faults. I narrowed down the problem
> that this only happens if I actually write something to the mapped
> page. However, I see no reason why it should cause this fault as I
> (after checking probably 100 times) don't access invalid memory. I'm
> wondering whether my method of editing the write is actually correct,
> or if I am doing something else very stupid.
 
Data in bios can't be modified in-place, as submitters of writes (e.g.,
filesystems) expect that their data buffers aren't modified.  To modify the data
you'd need to allocate a new bio with new pages and submit that instead.  See
dm-crypt for an example of a device-mapper target which does this.

What sort of device-mapper target are you trying to implement, anyway?  If
you're trying to do encryption, dm-crypt already solves that problem.

- Eric



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux