lkml.org 
[lkml]   [2024]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 4/5] evm: Use the real inode's metadata to calculate metadata hash
From


On 2/2/24 10:51, Amir Goldstein wrote:
> On Fri, Feb 2, 2024 at 4:59 PM Stefan Berger <stefanb@linux.ibm.com> wrote:
>>
>>
>>
>> On 2/2/24 04:24, Amir Goldstein wrote:
>>> On Thu, Feb 1, 2024 at 10:35 PM Stefan Berger <stefanb@linux.ibm.com> wrote:
>>
>>>
>>>>
>>>> and your suggested change to this patch :
>>>>
>>>> - struct inode *inode = d_real_inode(dentry);
>>>> + struct inode *inode = d_inode(d_real(dentry, false));;
>>>>
>>>
>>> In the new version I change the API to use an enum instead of bool, e.g.:
>>>
>>> struct inode *inode = d_inode(d_real(dentry, D_REAL_METADATA));
>>
>> Thanks. I will use it.
>>
>>>
>>> This catches in build time and in run time, callers that were not converted
>>> to the new API.
>>>
>>>> The test cases are now passing with and without metacopy enabled. Yay!
>>>
>>> Too soon to be happy.
>>> I guess you are missing a test for the following case:
>>> 1. file was meta copied up (change is detected)
>>> 2. the lower file that contains the data is being changed (change is
>>> not detected)
>>
>> Right. Though it seems there's something wrong with overlayfs as well
>> after appending a byte to the file on the lower.
>>
>> -rwxr-xr-x 1 0 0 25 Feb 2 14:55
>> /ext4.mount/lower/test_rsa_portable2
>> -rwxr-xr-x 1 0 0 24 Feb 2 14:55
>> /ext4.mount/overlay/test_rsa_portable2
>> bb16aa5350bcc8863da1a873c846fec9281842d9
>> /ext4.mount/lower/test_rsa_portable2
>> bb16aa5350bcc8863da1a873c846fec9281842d9
>> /ext4.mount/overlay/test_rsa_portable2
>>
>> We have a hash collision on a file with 24 bytes and the underlying one
>> with 25 byte. (-; :-)
>
> https://docs.kernel.org/filesystems/overlayfs.html#changes-to-underlying-filesystems
>
> If you modify the lower file underneath overlayfs, you get no
> guarantee from overlayfs about expected results.
>
> This makes your work more challenging.
The odd thing is my updated test case '2' seems to indicate that
everything already works as expected with CONFIG_OVERLAY_FS_METACOPY=y.
After causing copy-up of metadata changes to the file content on the
lower layer still cause permission error to file execution on the
overlay layer and after restoring the file content on the lower the file
on the overlay again runs as expected. The file content change + copy-up
of file content also has completely decoupled the lower file from the
file on the overlay and changes to the file on the lower cause no more
file execution rejections on the overlay.

Stefan
>
> Thanks,
> Amir.

\
 
 \ /
  Last update: 2024-05-27 14:46    [W:0.133 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site