linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Adding a field to ext2_dir_entry_2
  2005-04-05  0:08 Adding a field to ext2_dir_entry_2 Vineet Joglekar
@ 2005-04-04 22:10 ` Christopher Li
  2005-04-05  1:12 ` Andreas Dilger
  1 sibling, 0 replies; 6+ messages in thread
From: Christopher Li @ 2005-04-04 22:10 UTC (permalink / raw)
  To: Vineet Joglekar; +Cc: linux-kernel, linux-c-programming, adilger

That design sounds bad.

Anyway, I guess the error you are getting might have some thing to do with
the "." and ".." entry. Your current directory need to in the same
format as well. That is the price you pay for breaking the compatibility.

Chris


On Mon, Apr 04, 2005 at 08:08:57PM -0400, Vineet Joglekar wrote:
> 
> Hi Andreas,
> 
> I have created another file system - copied everything from ext2, renaming it as some different file system and doing some experiments on that.
> 
> Let me be more clear about what I am trying to do. In my masters project, I am encrypting inodes along with the data part of the file. Keys of different users are different. In the same directory, if there are 2 files stored by different users, their inodes will be encrypted with different keys. If user1 is doing "ls" on that directory, the inode of the other file - which is encrypted by user2, will be decrypted by using user1's key, resulting into garbage. To avoid this, I am trying to store the uid in the directry entry, so that  I can match it with current->fsuid and skip decrypting the inode if the file doesn't belong to the current user. (assuming user1 doesnt want to share that file and different users can store different files under same directory.)
> 
> Thanks and regards,
> 
> Vineet
> 
>  --- On Mon 04/04, Andreas Dilger < adilger@clusterfs.com > wrote:
> From: Andreas Dilger [mailto: adilger@clusterfs.com]
> To: vintya@excite.com
>      Cc: linux-kernel@vger.kernel.org, linux-c-programming@vger.kernel.org
> Date: Mon, 4 Apr 2005 17:17:59 -0600
> Subject: Re: Adding a field to ext2_dir_entry_2
> 
> On Apr 04, 2005  18:54 -0400, Vineet Joglekar wrote:<br>> I working with linux kernel 2.4.28. I want to add 1 more field to<br>> ext2_dir_entry_2 - the new version of directory entry for ext2fs.<br>> <br>> I did add the __u32 field to the struct ext2_dir_entry_2 defined in<br>> ext2_fs.h I also modified the EXT2_DIR_REC_LEN macro to:<br>> <br>> (((name_len) + 12 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND)<br>> <br>> (+12 instead of +8) to incorporate newly added 4 bytes field.<br>> <br>> I made the similar changes to the mke2fs utility also.<br><br>This means your filesystem will not be mountable by any other version of<br>Linux.  What is more important is why you want to do this - there are<br>other mechanisms that may be more appropriate depending on what you are<br>doing.<br><br>Cheers, Andreas<br>--<br>Andreas Dilger<br>Principal Software Engineer<br>Cluster File Systems, Inc.<br><br>Attachment: Attachment  (0.19KB)<br>
> 
> _______________________________________________
> Join Excite! - http://www.excite.com
> The most personalized portal on the Web!
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding a field to ext2_dir_entry_2
@ 2005-04-05  0:08 Vineet Joglekar
  2005-04-04 22:10 ` Christopher Li
  2005-04-05  1:12 ` Andreas Dilger
  0 siblings, 2 replies; 6+ messages in thread
From: Vineet Joglekar @ 2005-04-05  0:08 UTC (permalink / raw)
  To: linux-kernel, linux-c-programming; +Cc: adilger


Hi Andreas,

I have created another file system - copied everything from ext2, renaming it as some different file system and doing some experiments on that.

Let me be more clear about what I am trying to do. In my masters project, I am encrypting inodes along with the data part of the file. Keys of different users are different. In the same directory, if there are 2 files stored by different users, their inodes will be encrypted with different keys. If user1 is doing "ls" on that directory, the inode of the other file - which is encrypted by user2, will be decrypted by using user1's key, resulting into garbage. To avoid this, I am trying to store the uid in the directry entry, so that  I can match it with current->fsuid and skip decrypting the inode if the file doesn't belong to the current user. (assuming user1 doesnt want to share that file and different users can store different files under same directory.)

Thanks and regards,

Vineet

 --- On Mon 04/04, Andreas Dilger < adilger@clusterfs.com > wrote:
From: Andreas Dilger [mailto: adilger@clusterfs.com]
To: vintya@excite.com
     Cc: linux-kernel@vger.kernel.org, linux-c-programming@vger.kernel.org
Date: Mon, 4 Apr 2005 17:17:59 -0600
Subject: Re: Adding a field to ext2_dir_entry_2

On Apr 04, 2005  18:54 -0400, Vineet Joglekar wrote:<br>> I working with linux kernel 2.4.28. I want to add 1 more field to<br>> ext2_dir_entry_2 - the new version of directory entry for ext2fs.<br>> <br>> I did add the __u32 field to the struct ext2_dir_entry_2 defined in<br>> ext2_fs.h I also modified the EXT2_DIR_REC_LEN macro to:<br>> <br>> (((name_len) + 12 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND)<br>> <br>> (+12 instead of +8) to incorporate newly added 4 bytes field.<br>> <br>> I made the similar changes to the mke2fs utility also.<br><br>This means your filesystem will not be mountable by any other version of<br>Linux.  What is more important is why you want to do this - there are<br>other mechanisms that may be more appropriate depending on what you are<br>doing.<br><br>Cheers, Andreas<br>--<br>Andreas Dilger<br>Principal Software Engineer<br>Cluster File Systems, Inc.<br><br>Attachment: Attachment  (0.19KB)<br>

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding a field to ext2_dir_entry_2
  2005-04-05  0:08 Adding a field to ext2_dir_entry_2 Vineet Joglekar
  2005-04-04 22:10 ` Christopher Li
@ 2005-04-05  1:12 ` Andreas Dilger
  2005-04-05  3:53   ` Theodore Ts'o
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Dilger @ 2005-04-05  1:12 UTC (permalink / raw)
  To: Vineet Joglekar; +Cc: linux-kernel, linux-c-programming

[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]

On Apr 04, 2005  20:08 -0400, Vineet Joglekar wrote:
> I have created another file system - copied everything from ext2,
> renaming it as some different file system and doing some experiments on that.
> 
> Let me be more clear about what I am trying to do. In my masters
> project, I am encrypting inodes along with the data part of the file. Keys
> of different users are different. In the same directory, if there are
> 2 files stored by different users, their inodes will be encrypted with
> different keys. If user1 is doing "ls" on that directory, the inode
> of the other file - which is encrypted by user2, will be decrypted by
> using user1's key, resulting into garbage. To avoid this, I am trying
> to store the uid in the directry entry, so that  I can match it with
> current->fsuid and skip decrypting the inode if the file doesn't belong
> to the current user. (assuming user1 doesnt want to share that file and
> different users can store different files under same directory.)

This is broken by design.  What happens if you chown a file?  The UID will
change in the inode, but nothing will be updated in the directory.  This
key must be stored in the inode along with the ownership info (it can be
an EA, and possibly a fast EA or fixed inode field in a large inode).

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding a field to ext2_dir_entry_2
  2005-04-05  1:12 ` Andreas Dilger
@ 2005-04-05  3:53   ` Theodore Ts'o
  0 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2005-04-05  3:53 UTC (permalink / raw)
  To: Vineet Joglekar, linux-kernel, linux-c-programming

On Mon, Apr 04, 2005 at 07:12:51PM -0600, Andreas Dilger wrote:
> > Let me be more clear about what I am trying to do. In my masters
> > project, I am encrypting inodes along with the data part of the file. Keys
> > of different users are different. In the same directory, if there are
> > 2 files stored by different users, their inodes will be encrypted with
> > different keys. If user1 is doing "ls" on that directory, the inode
> > of the other file - which is encrypted by user2, will be decrypted by
> > using user1's key, resulting into garbage. To avoid this, I am trying
> > to store the uid in the directry entry, so that  I can match it with
> > current->fsuid and skip decrypting the inode if the file doesn't belong
> > to the current user. (assuming user1 doesnt want to share that file and
> > different users can store different files under same directory.)
> 
> This is broken by design.  What happens if you chown a file?  The UID will
> change in the inode, but nothing will be updated in the directory.  This
> key must be stored in the inode along with the ownership info (it can be
> an EA, and possibly a fast EA or fixed inode field in a large inode).

What else is broken about this design.  Let me count the ways...

1)  What about group access to files?

2)  It means that you can't do a filesystem consistency check without
knowing all of the keys, since the block pointers in the inode would
also be encrypted.

3) If user1 has previously accessed the file, the encrypted inode
information will already be cached, and visible when user2 accesses
the file; stat() doesn't result in a call into filesystem code if the
information is already cached.  

What's the point of encrypting the inode?  What problem are you trying
to solve?

As to why you're having problems:

"ext2-fs error (device fd(2,0)): ext2_check_page: bad entry in directory #2:
unaligned directory entry - offset=0, inode=2, rec_len=46, name_len=0"

46 is ascii for '.'.  You missed a spot in mke2fs where you changed
the directory entry structure.  Specifically, in libext2fs, and note
that some portions of the ext2fs library which still use
ext2_dir_entry as well as ext2_dir_entry_2, for historical / ABI
backwards compatibility reasons.

						- Ted


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Adding a field to ext2_dir_entry_2
  2005-04-04 22:54 Vineet Joglekar
@ 2005-04-04 23:17 ` Andreas Dilger
  0 siblings, 0 replies; 6+ messages in thread
From: Andreas Dilger @ 2005-04-04 23:17 UTC (permalink / raw)
  To: Vineet Joglekar; +Cc: linux-kernel, linux-c-programming

[-- Attachment #1: Type: text/plain, Size: 846 bytes --]

On Apr 04, 2005  18:54 -0400, Vineet Joglekar wrote:
> I working with linux kernel 2.4.28. I want to add 1 more field to
> ext2_dir_entry_2 - the new version of directory entry for ext2fs.
> 
> I did add the __u32 field to the struct ext2_dir_entry_2 defined in
> ext2_fs.h I also modified the EXT2_DIR_REC_LEN macro to:
> 
> (((name_len) + 12 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND)
> 
> (+12 instead of +8) to incorporate newly added 4 bytes field.
> 
> I made the similar changes to the mke2fs utility also.

This means your filesystem will not be mountable by any other version of
Linux.  What is more important is why you want to do this - there are
other mechanisms that may be more appropriate depending on what you are
doing.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Adding a field to ext2_dir_entry_2
@ 2005-04-04 22:54 Vineet Joglekar
  2005-04-04 23:17 ` Andreas Dilger
  0 siblings, 1 reply; 6+ messages in thread
From: Vineet Joglekar @ 2005-04-04 22:54 UTC (permalink / raw)
  To: linux-kernel, linux-c-programming



Hi All,

I working with linux kernel 2.4.28. I want to add 1 more field to ext2_dir_entry_2 - the new version of directory entry for ext2fs.

I did add the __u32 field to the struct ext2_dir_entry_2 defined in  ext2_fs.h I also modified the EXT2_DIR_REC_LEN macro to:

(((name_len) + 12 + EXT2_DIR_ROUND) & ~EXT2_DIR_ROUND)

(+12 instead of +8) to incorporate newly added 4 bytes field.

I made the similar changes to the mke2fs utility also.

When I try to copy a file on that file system, I am getting the following error:

"ext2-fs error (device fd(2,0)): ext2_check_page: bad entry in directory #2: unaligned directory entry - offset=0, inode=2, rec_len=46, name_len=0"

Can someone please tell me where am I going wrong or what other changes do I need to do to add the field I want?

Thanks and regards,

Vineet Joglekar

_______________________________________________
Join Excite! - http://www.excite.com
The most personalized portal on the Web!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-04-05  3:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-05  0:08 Adding a field to ext2_dir_entry_2 Vineet Joglekar
2005-04-04 22:10 ` Christopher Li
2005-04-05  1:12 ` Andreas Dilger
2005-04-05  3:53   ` Theodore Ts'o
  -- strict thread matches above, loose matches on Subject: below --
2005-04-04 22:54 Vineet Joglekar
2005-04-04 23:17 ` Andreas Dilger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).