LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 08-28-2018, 06:57 AM   #1
dr.SysMan
LQ Newbie
 
Registered: Dec 2017
Location: Sain-Petersburg
Distribution: Ubuntu
Posts: 13

Rep: Reputation: Disabled
Transparent encryption/decryption on top of block device


Hi All!

Need help!

I have tried to implement a block layered device driver which performs transparent encryption/decryption of data by interception WRITE/READ request ...
Now I have tried to resolve problem with incorrect data buffers content when more then one process performs I/O on block device like /dev/sda.

A part of driver is placed for review at :
http://codepad.org/IEqHY9er


Code:
static	void	__dua_bio_endio	(
			struct bio *	iob
				)
{
IOB_ARGS *iob_args = NULL;
struct bio *orig_bio = NULL;

	iob_args = iob->bi_private;

	if ( bio_data_dir(iob) == READ )
		{
		/* Restore has been replaced fields ... */
		iob->bi_end_io = iob_args->bi_end_io;
		iob->bi_private = iob_args->bi_private;
		iob->bi_iter = iob_args->bi_iter;

		/*
		 * In case of READ request - we getting original READ BIO,
		 * so we should decrypt data buffer right now at the place
		 */
		__dua_bio_enc_dec(iob, iob_args->bi_sector, DUDRV$K_DECRYPT);

		/* Decrement reference count to original BIO	*/
		bio_put(iob);

		/* Call Complete I/O for original BIO */
		bio_endio (iob);
		}
...
}
As u can see data decrypted on the place.

Last edited by dr.SysMan; 08-28-2018 at 07:02 AM.
 
Old 09-01-2018, 08:24 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,149

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
Why can't you add a flag to indicate whether the block has already been processed?
 
Old 11-13-2018, 08:24 AM   #3
dr.SysMan
LQ Newbie
 
Registered: Dec 2017
Location: Sain-Petersburg
Distribution: Ubuntu
Posts: 13

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by smallpond View Post
Why can't you add a flag to indicate whether the block has already been processed?
It will not help because a single BIO can carry a huge number of disk blocks, more over bottom level device driver can call make_request_fn() routine to splitting big BIO to several small ...
 
  


Reply

Tags
driver, linux kernels



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Learning cryptsetup-LUKS for block device encryption: boot problem fanoflq Linux - Newbie 1 04-19-2016 02:26 AM
Encryption and Decryption at the application layer ArunkumarRavi Linux - Newbie 1 03-03-2015 09:14 AM
Encryption/Decryption in NS2.35 sumegha13 Linux - Software 1 01-30-2014 03:58 AM
Encryption and Decryption of file krounak Programming 2 06-24-2009 11:48 PM
Encryption/decryption bacula testing tqz Linux - General 1 02-02-2009 03:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration