Return-Path: Received: from mail.saout.de ([127.0.0.1]) by localhost (mail.saout.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e9HFAMjfI3Zq for ; Thu, 19 Jan 2012 17:45:48 +0100 (CET) Received: from nm25.bullet.mail.bf1.yahoo.com (nm25.bullet.mail.bf1.yahoo.com [98.139.212.184]) by mail.saout.de (Postfix) with SMTP for ; Thu, 19 Jan 2012 17:45:48 +0100 (CET) References: Message-ID: <1326991545.89265.YahooMailNeo@web161401.mail.bf1.yahoo.com> Date: Thu, 19 Jan 2012 08:45:45 -0800 (PST) From: FAN ZHANG In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-1131079492-767077611-1326991545=:89265" Subject: Re: [dm-crypt] dm-crypt Digest, Vol 31, Issue 17 Reply-To: FAN ZHANG List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "dm-crypt@saout.de" ---1131079492-767077611-1326991545=:89265 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Arno:=0A=A0We=A0need to do background SD card encryption. When encryption i= s enabled, we start to encrypt SD card and allow apps to access file system= at same time.=0A=A0=0ASince it may take hours to encrypt=A0entire SD card,= we need virtually partition SD card to two parts,=0A=A0=0AFirst partition = is encrypted by kernel encryption thread. When=A0bio request hits this part= , all read requests should be decrypted and write should encrypted.=0A=A0= =0ASecond partition is not encrypted yet. When=A0bio request hits this part= , all read/write=A0requests should be=A0redirected to underneath bio operat= ion directly.=0A=A0=0AThe most challenge part is=A0when=A0bio request cross= es both part, we need handle split bio request.=0A=A0=0AIf=A0a specific pag= e contained in bio crosses encrypted/unencrypted boundary, the first few se= ctors are located in encrypted area,=0A=A0=0AThe remaining sectors are loca= ted in unencrypted area.=0A=A0=0ATherefore we need to do decrypt/encrypt fo= r read/write associating with first few sectors and=A0pass through remainin= g sectors request to underneath block device directly.=0A=A0=0A=A0=0APlease= let me know if you need more explanations.=0A=A0=0A=A0=0AThanks=0A=A0=0AFa= n=A0=0A=A0=0A=A0=0A=A0=0A=A0=0A=0AFrom: "dm-crypt-request@saout.de" =0ATo: dm-crypt@saout.de =0ASent: Thursday, January 19,= 2012 5:00 AM=0ASubject: dm-crypt Digest, Vol 31, Issue 17=0A=0ASend dm-cry= pt mailing list submissions to=0A=A0=A0=A0 dm-crypt@saout.de=0A=0ATo subscr= ibe or unsubscribe via the World Wide Web, visit=0A=A0=A0=A0 http://www.sao= ut.de/mailman/listinfo/dm-crypt=0Aor, via email, send a message with subjec= t or body 'help' to=0A=A0=A0=A0 dm-crypt-request@saout.de=0A=0AYou can reac= h the person managing the list at=0A=A0=A0=A0 dm-crypt-owner@saout.de=0A=0A= When replying, please edit your Subject line so it is more specific=0Athan = "Re: Contents of dm-crypt digest..."=0A=0A=0AToday's Topics:=0A=0A=A0 1. By= pass encrypt and decrypt data in dm-crypt (FAN ZHANG)=0A=A0 2. Re: Bypass e= ncrypt and decrypt data in dm-crypt (Arno Wagner)=0A=A0 3. test mail list (= FAN ZHANG)=0A=A0 4. Re: Bypass encrypt and decrypt data in dm-crypt (Milan = Broz)=0A=0A=0A-------------------------------------------------------------= ---------=0A=0AMessage: 1=0ADate: Wed, 18 Jan 2012 07:56:38 -0800 (PST)=0AF= rom: FAN ZHANG =0ATo: "dm-crypt@saout.de" =0ASubject: [dm-crypt] Bypass encrypt and decrypt data in dm-crypt= =0AMessage-ID:=0A=A0=A0=A0 <1326902198.77527.YahooMailNeo@web161402.mail.bf= 1.yahoo.com>=0AContent-Type: text/plain; charset=3D"iso-8859-1"=0A=0AAll:= =0A?=0A?=0AWe are using dm-crypt for Android device encryption.? However, w= e need reserve some sectors in block device for status and integration chec= k and do not want to encrypt/decrypt some sectors when using dm-crypt.=0A?= =0ASo in crypt_convert_block()=0A?=0AWhen=0Aoffset sector of ctx +? sector = number of bio_in? is the range of bypass sector list.=0A?=0A?=0Ainstead cal= l=0Aif (bio_data_dir(ctx->bio_in) =3D=3D WRITE)=0A?r =3D crypt_copy_write_d= ata(bv_in, bv_out, offset, 1 << SECTOR_SHIFT); else? r =3D crypt_copy_read_= data(bv_in, bv_out, offset, 1 << SECTOR_SHIFT);=0A?=0AI want to call anothe= r function to copy data of a sector from =0Actx->bio_in to=0Actx->bio_out d= irectly.=0A?=0A?=0AI tried the following implementation =0A?=0Ain ps_copy_w= rite_data()=0A?=0A?=0Astruct bio_vec *bv_in =3D bio_iovec_idx(ctx->bio_in, = ctx->idx_in); =0Astruct bio_vec *bv_out =3D bio_iovec_idx(ctx->bio_out, ctx= ->idx_out); =0Astruct page * page_in =3D bv_in->bv_page; =0Astruct page * p= age_out =3D bv_out->bv_page;=0A?=0Avoid * addr1 =3D kmap_atomic(page_in, KM= _USER0); =0Avoid * addr2 =3D kmap_atomic(page_out, KM_USER1);=0A?=0Aunsigne= d int offset =3D ctx->offset_in;=0A?=0Amemcpy(addr2 + offset, addr1 + offse= t, 1 << SECTOR_SHIFT);=0A?=0Akunmap_atomic(addr2, KM_USER1);=0Akunmap_atomi= c(addr1, KM_USER0);=0A?=0Abut above implementation works for read (since bv= _in and bv_out are same for decryption) but does not work for write. =0A?= =0AIt seems that =0Amemcpy(addr2 + offset, addr1 + offset, 1 << SECTOR_SHIF= T);=0A?=0Afails to copy page associated with bv_in? to page associated with= bv_out =0A?=0A?=0A?=0ACould you give me a?hint to reslove this issue?=0A?= =0AThanks=0A?=0AFan=0A-------------- next part --------------=0AAn HTML att= achment was scrubbed...=0AURL: =0A=0A----------------------= --------=0A=0AMessage: 2=0ADate: Wed, 18 Jan 2012 17:24:19 +0100=0AFrom: Ar= no Wagner =0ATo: dm-crypt@saout.de=0ASubject: Re: [dm-cry= pt] Bypass encrypt and decrypt data in dm-crypt=0AMessage-ID: <201201181624= 19.GA27569@tansi.org>=0AContent-Type: text/plain; charset=3Dus-ascii=0A=0AH= i,=0A=0Awhile I do not know what the issue you encounter is,=0Ait would be = better to have your status block before the=0Aencrypted part and simply map= with an offset, e.g.=0A"-p 1" to skip the first sector. Thsi would not bre= ak=0Alayering, as your approach seems to do.=0A=0AIs there a specific reaso= n you want the non-encrypted =0Ablock somewhere in the middle? (if I unders= tand this correctly...)=0AI cannot see any security reason, as a non-encryp= ted block=0Awill allways stick out and can be found automatically =0Aanyway= s.=0A=0AArno=0A=0AOn Wed, Jan 18, 2012 at 07:56:38AM -0800, FAN ZHANG wrote= :=0A> All:=0A> ?=0A> ?=0A>=0A> We are using dm-crypt for Android device enc= ryption.? However, we need=0A> reserve some sectors in block device for sta= tus and integration check and=0A> do not want to encrypt/decrypt some secto= rs when using dm-crypt.=0A>=0A> ?=0A> So in crypt_convert_block()=0A> ?=0A>= When=0A> offset sector of ctx +? sector number of bio_in? is the range of = bypass sector list.=0A> ?=0A> ?=0A> instead call=0A> if (bio_data_dir(ctx->= bio_in) =3D=3D WRITE)=0A> ?r =3D crypt_copy_write_data(bv_in, bv_out, offse= t, 1 << SECTOR_SHIFT); else? r =3D crypt_copy_read_data(bv_in, bv_out, offs= et, 1 << SECTOR_SHIFT);=0A> ?=0A> I want to call another function to copy d= ata of a sector from =0A> ctx->bio_in to=0A> ctx->bio_out directly.=0A> ?= =0A> ?=0A> I tried the following implementation =0A> ?=0A> in ps_copy_write= _data()=0A> ?=0A> ?=0A> struct bio_vec *bv_in =3D bio_iovec_idx(ctx->bio_in= , ctx->idx_in); =0A> struct bio_vec *bv_out =3D bio_iovec_idx(ctx->bio_out,= ctx->idx_out); =0A> struct page * page_in =3D bv_in->bv_page; =0A> struct = page * page_out =3D bv_out->bv_page;=0A> ?=0A> void * addr1 =3D kmap_atomic= (page_in, KM_USER0); =0A> void * addr2 =3D kmap_atomic(page_out, KM_USER1);= =0A> ?=0A> unsigned int offset =3D ctx->offset_in;=0A> ?=0A> memcpy(addr2 += offset, addr1 + offset, 1 << SECTOR_SHIFT);=0A> ?=0A> kunmap_atomic(addr2,= KM_USER1);=0A> kunmap_atomic(addr1, KM_USER0);=0A> ?=0A> but above impleme= ntation works for read (since bv_in and bv_out are same for decryption) but= does not work for write. =0A> ?=0A> It seems that =0A> memcpy(addr2 + offs= et, addr1 + offset, 1 << SECTOR_SHIFT);=0A> ?=0A> fails to copy page associ= ated with bv_in? to page associated with bv_out =0A> ?=0A> ?=0A> ?=0A> Coul= d you give me a?hint to reslove this issue?=0A> ?=0A> Thanks=0A> ?=0A> Fan= =0A=0A> _______________________________________________=0A> dm-crypt mailin= g list=0A> dm-crypt@saout.de=0A> http://www.saout.de/mailman/listinfo/dm-cr= ypt=0A=0A=0A-- =0AArno Wagner, Dr. sc. techn., Dipl. Inform., CISSP -- Emai= l: arno@wagner.name =0AGnuPG:=A0 ID: 1E25338F=A0 FP: 0C30 5782 9D93 F785 E7= 9C=A0 0296 797F 6B50 1E25 338F=0A----=0AOne of the painful things about our= time is that those who feel certainty =0Aare stupid, and those with any im= agination and understanding are filled =0Awith doubt and indecision. -- Ber= trand Russell =0A=0A=0A------------------------------=0A=0AMessage: 3=0ADat= e: Wed, 18 Jan 2012 11:24:14 -0800 (PST)=0AFrom: FAN ZHANG =0ATo: "dm-crypt@saout.de" =0ACc: Fan Zhang =0ASubject: [dm-crypt] test mail list=0AMessage-ID:=0A=A0=A0= =A0 <1326914654.68613.YahooMailNeo@web161404.mail.bf1.yahoo.com>=0AContent-= Type: text/plain; charset=3D"us-ascii"=0A=0AMy previous mail did not go thr= ough, I just want to test this mail list again=0A-------------- next part -= -------------=0AAn HTML attachment was scrubbed...=0AURL: = =0A=0A------------------------------=0A=0AMessage: 4=0ADate: Wed, 18 Jan 20= 12 21:19:58 +0100=0AFrom: Milan Broz =0ATo: FAN ZHANG =0ACc: "dm-crypt@saout.de" =0ASubject:= Re: [dm-crypt] Bypass encrypt and decrypt data in dm-crypt=0AMessage-ID: <= 4F17296E.5050702@redhat.com>=0AContent-Type: text/plain; charset=3DISO-8859= -1; format=3Dflowed=0A=0AOn 01/18/2012 04:56 PM, FAN ZHANG wrote:=0A> All:= =0A> We are using dm-crypt for Android device encryption.However, we need= =0A> reserve some sectors in block device for status and integration check= =0A> and do not want to encrypt/decrypt some sectors when using dm-crypt.= =0A=0APlease can you describe exactly what you need?=0A=0AI will not accept= any patch in dmcrypt which bypass encryption,=0Abut I think the problem is= solvable using combination=0Aof dm targets, or=A0 using some trick.=0A=0AB= ut I still have no idea what problem you are trying to solve...=0A(Please d= o not describe implementation, describe the problem.)=0A=0AThanks,=0AMilan= =0A=0A=0A=0A------------------------------=0A=0A___________________________= ____________________=0Adm-crypt mailing list=0Adm-crypt@saout.de=0Ahttp://w= ww.saout.de/mailman/listinfo/dm-crypt=0A=0A=0AEnd of dm-crypt Digest, Vol 3= 1, Issue 17=0A**************************************** ---1131079492-767077611-1326991545=:89265 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Arno:
 
<= SPAN style=3D"RIGHT: auto">
We&nbs= p;need to do background SD card encryption. When encryption is enabled, we = start to encrypt SD card and allow apps to access file system at same time.=
 
Since it may take hours to encrypt e= ntire SD card, we need virtually partition SD card to two parts,=
 
First partition is encrypted by kernel en= cryption thread. When bio request hits this part, all read requests sh= ould be decrypted and write should encrypted.
 
Second partition is not encrypted yet. Wh= en bio request hits this part, all read/write requests should be&= nbsp;redirected to underneath bio operation directly.
 
The most challenge part is when bio request crosses both= part, we need handle split bio request.
 
If a specific page contained in bio crosses encr= ypted/unencrypted boundary, the first few sectors are located in encrypted = area,
 
The remaining sectors are located in unencrypted area= .
 
Therefore we need to do decrypt/encrypt for read/write associating= with first few sectors and pass through remaining sectors request to = underneath block device directly.
 
 
Please let me know if you need more explanations.
 
 
Thanks=
 
Fan&nb= sp;
 
 
 
 

From:= "dm-crypt-request@saout.de" <dm-crypt-request@saout.de>To: dm-crypt@saout.de Sent: Thursday, January 19= , 2012 5:00 AM
Subject: = dm-crypt Digest, Vol 31, Issue 17

Send dm-crypt mailing= list submissions to
    dm-crypt@saout.de

To s= ubscribe or unsubscribe via the World Wide Web, visit
    http://www.saout.de/mailman/listinfo/dm-crypt
or, via email, send a mes= sage with subject or body 'help' to
    dm= -crypt-request@saout.de

You can reach the person managing the li= st at
    dm-crypt-owner@saout.de

W= hen replying, please edit your Subject line so it is more specific
than = "Re: Contents of dm-crypt digest..."


Today's Topics:

&nbs= p; 1. Bypass encrypt and decrypt data in dm-crypt (FAN ZHANG)
  2. = Re: Bypass encrypt and decrypt data in dm-crypt (Arno Wagner)
  3. = test mail list (FAN ZHANG)
  4. Re: Bypass encrypt and decrypt data= in dm-crypt (Milan Broz)


--------------------------------------= --------------------------------

Message: 1
Date: Wed, 18 Jan 201= 2 07:56:38 -0800 (PST)
From: FAN ZHANG <fzhangcsc@yahoo.com>=
To: "dm-crypt@saout.de" <dm-crypt@saout.de>
Subject: [dm= -crypt] Bypass encrypt and decrypt data in dm-crypt
Message-ID:
 = ;   <1326902198.77527.YahooMailNeo@web161402.mail.bf1.ya= hoo.com>
Content-Type: text/plain; charset=3D"iso-8859-1"

= All:
?
?
We are using dm-crypt for Android device encryption.? How= ever, we need reserve some sectors in block device for status and integrati= on check and do not want to encrypt/decrypt some sectors when using dm-crypt.
?
So in crypt_convert_block()
?
When
offset secto= r of ctx +? sector number of bio_in? is the range of bypass sector list.?
?
instead call
if (bio_data_dir(ctx->bio_in) =3D=3D WRITE)?r =3D crypt_copy_write_data(bv_in, bv_out, offset, 1 << SECTOR_SHI= FT); else? r =3D crypt_copy_read_data(bv_in, bv_out, offset, 1 << SEC= TOR_SHIFT);
?
I want to call another function to copy data of a secto= r from
ctx->bio_in to
ctx->bio_out directly.
?
?
I tr= ied the following implementation
?
in ps_copy_write_data()
?
?=
struct bio_vec *bv_in =3D bio_iovec_idx(ctx->bio_in, ctx->idx_in)= ;
struct bio_vec *bv_out =3D bio_iovec_idx(ctx->bio_out, ctx->idx= _out);
struct page * page_in =3D bv_in->bv_page;
struct page * p= age_out =3D bv_out->bv_page;
?
void * addr1 =3D kmap_atomic(page_i= n, KM_USER0);
void * addr2 =3D kmap_atomic(page_out, KM_USER1);
?unsigned int offset =3D ctx->offset_in;
?
memcpy(addr2 + offset, addr1 + offse= t, 1 << SECTOR_SHIFT);
?
kunmap_atomic(addr2, KM_USER1);
kun= map_atomic(addr1, KM_USER0);
?
but above implementation works for rea= d (since bv_in and bv_out are same for decryption) but does not work for wr= ite.
?
It seems that
memcpy(addr2 + offset, addr1 + offset, 1 &l= t;< SECTOR_SHIFT);
?
fails to copy page associated with bv_in? to = page associated with bv_out
?
?
?
Could you give me a?hint to = reslove this issue?
?
Thanks
?
Fan
-------------- next part = --------------
An HTML attachment was scrubbed...
URL: <http://www= .saout.de/pipermail/dm-crypt/attachments/20120118/5b77916d/attachment-0001.= html>

------------------------------

Message: 2
Date: W= ed, 18 Jan 2012 17:24:19 +0100
From: Arno Wagner <arno@wagner.name>
To: dm-cryp= t@saout.de
Subject: Re: [dm-crypt] Bypass encrypt and decrypt data i= n dm-crypt
Message-ID: <20120118162419.G= A27569@tansi.org>
Content-Type: text/plain; charset=3Dus-ascii
Hi,

while I do not know what the issue you encounter is,
it = would be better to have your status block before the
encrypted part and = simply map with an offset, e.g.
"-p 1" to skip the first sector. Thsi wo= uld not break
layering, as your approach seems to do.

Is there a = specific reason you want the non-encrypted
block somewhere in the middl= e? (if I understand this correctly...)
I cannot see any security reason,= as a non-encrypted block
will allways stick out and can be found automatically
anyways.

Arno

On Wed, Jan 18, 2012 at 07:5= 6:38AM -0800, FAN ZHANG wrote:
> All:
> ?
> ?
>
= > We are using dm-crypt for Android device encryption.? However, we need=
> reserve some sectors in block device for status and integration ch= eck and
> do not want to encrypt/decrypt some sectors when using dm-c= rypt.
>
> ?
> So in crypt_convert_block()
> ?
&g= t; When
> offset sector of ctx +? sector number of bio_in? is the ran= ge of bypass sector list.
> ?
> ?
> instead call
> = if (bio_data_dir(ctx->bio_in) =3D=3D WRITE)
> ?r =3D crypt_copy_wr= ite_data(bv_in, bv_out, offset, 1 << SECTOR_SHIFT); else? r =3D crypt= _copy_read_data(bv_in, bv_out, offset, 1 << SECTOR_SHIFT);
> ?<= BR>> I want to call another function to copy data of a sector from
&= gt; ctx->bio_in to
> ctx->bio_out directly.
> ?
> ?
> I tried the following implementation
> ?
> in ps_co= py_write_data()
> ?
> ?
> struct bio_vec *bv_in =3D bio_i= ovec_idx(ctx->bio_in, ctx->idx_in);
> struct bio_vec *bv_out = =3D bio_iovec_idx(ctx->bio_out, ctx->idx_out);
> struct page *= page_in =3D bv_in->bv_page;
> struct page * page_out =3D bv_out-= >bv_page;
> ?
> void * addr1 =3D kmap_atomic(page_in, KM_USE= R0);
> void * addr2 =3D kmap_atomic(page_out, KM_USER1);
> ?> unsigned int offset =3D ctx->offset_in;
> ?
> memcpy(= addr2 + offset, addr1 + offset, 1 << SECTOR_SHIFT);
> ?
>= kunmap_atomic(addr2, KM_USER1);
> kunmap_atomic(addr1, KM_USER0);> ?
> but above implementation works for read (since bv_in and bv= _out are same for decryption) but does not work for write.
> ?
&g= t; It seems that
> memcpy(addr2 + offset, addr1 + offset, 1 << SECTOR_SHIFT);
> ?
> fails to copy page associated with bv_in?= to page associated with bv_out
> ?
> ?
> ?
> Coul= d you give me a?hint to reslove this issue?
> ?
> Thanks
>= ; ?
> Fan

> _______________________________________________=
> dm-crypt mailing list
> dm-crypt@saout.de
> http://w= ww.saout.de/mailman/listinfo/dm-crypt


--
Arno Wagner, Dr= . sc. techn., Dipl. Inform., CISSP -- Email: arno@wagner.name
GnuPG:&n= bsp; ID: 1E25338F  FP: 0C30 5782 9D93 F785 E79C  0296 797F 6B50 1= E25 338F
----
One of the painful things about our time is that those = who feel certainty
are stupid, and those with any imagination and understanding are filled
with doubt and indecision. -- Bertrand Russel= l


------------------------------

Message: 3
Date: Wed= , 18 Jan 2012 11:24:14 -0800 (PST)
From: FAN ZHANG <fzhangcsc@yaho= o.com>
To: "dm-crypt@saout.de" <dm-crypt@saout.de>Cc: Fan Zhang <fzhangcsc@yahoo.com>
Subject: [dm-crypt] te= st mail list
Message-ID:
    <1326914654.6861= 3.YahooMailNeo@web161404.mail.bf1.yahoo.com>
Content-Type: text/p= lain; charset=3D"us-ascii"

My previous mail did not go through, I just wa= nt to test this mail list again
-------------- next part --------------<= BR>An HTML attachment was scrubbed...
URL: <mbroz@redhat.com>
To: FAN ZHANG <fzhangcsc@yahoo.c= om>
Cc: "dm-crypt@saout.de" <dm-crypt@saout.de>
Su= bject: Re: [dm-crypt] Bypass encrypt and decrypt data in dm-crypt
Message-ID: <= 4F17296E.5050702@redhat.com>
Content-Type: tex= t/plain; charset=3DISO-8859-1; format=3Dflowed

On 01/18/2012 04:56 P= M, FAN ZHANG wrote:
> All:
> We are using dm-crypt for Android = device encryption.However, we need
> reserve some sectors in block de= vice for status and integration check
> and do not want to encrypt/de= crypt some sectors when using dm-crypt.

Please can you describe exac= tly what you need?

I will not accept any patch in dmcrypt which bypa= ss encryption,
but I think the problem is solvable using combination
= of dm targets, or  using some trick.

But I still have no idea w= hat problem you are trying to solve...
(Please do not describe implement= ation, describe the problem.)

Thanks,
Milan



-------------------------= -----

_______________________________________________
dm-crypt ma= iling list
dm-crypt@saout.de
http://www.saout.de/mailman/listinfo/d= m-crypt


End of dm-crypt Digest, Vol 31, Issue 17
********= ********************************


---1131079492-767077611-1326991545=:89265--