All of lore.kernel.org
 help / color / mirror / Atom feed
* Is it possible to corrupt disk when writeback page with undetected UE?
@ 2022-09-15 22:36 Jane Chu
  2022-09-15 22:50 ` Luck, Tony
  0 siblings, 1 reply; 7+ messages in thread
From: Jane Chu @ 2022-09-15 22:36 UTC (permalink / raw)
  To: Luck, Tony, Borislav Petkov, djwong; +Cc: x86, linux-fsdevel, linux-mm

Hi,

Suppose there is a UE in a DRAM page that is backed by a disk file.
The UE hasn't been reported to the kernel, but low level firmware 
initiated scrubbing has already logged the UE.

The page is then dirtied by a write, although the write clearly failed,
it didn't trigger an MCE.

And without a subsequent read from the page, at some point, the page is 
written back to the disk, leaving a PAGE_SIZE of zeros in the targeted 
disk blocks.

Is this mode of disk corruption possible?

Thanks a lot!
-jane

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

* RE: Is it possible to corrupt disk when writeback page with undetected UE?
  2022-09-15 22:36 Is it possible to corrupt disk when writeback page with undetected UE? Jane Chu
@ 2022-09-15 22:50 ` Luck, Tony
  2022-09-16  0:26   ` Jane Chu
  0 siblings, 1 reply; 7+ messages in thread
From: Luck, Tony @ 2022-09-15 22:50 UTC (permalink / raw)
  To: chu, jane, Borislav Petkov, djwong; +Cc: x86, linux-fsdevel, linux-mm

> Suppose there is a UE in a DRAM page that is backed by a disk file.
> The UE hasn't been reported to the kernel, but low level firmware
> initiated scrubbing has already logged the UE.
>
> The page is then dirtied by a write, although the write clearly failed,
> it didn't trigger an MCE.
>
> And without a subsequent read from the page, at some point, the page is
> written back to the disk, leaving a PAGE_SIZE of zeros in the targeted
> disk blocks.
>
> Is this mode of disk corruption possible?

I didn't look at what was written to disk, but I have seen this. My test sequence
was to compile and then immediately run an error injection test program that
injected a memory UC error to an instruction.

Because the program was freshly compiled, the executable file was in the
page cache with all pages marked as modified. Later a sync (or memory
pressure) wrote the dirty page with poison to filesystem.

I did see an error reported by the disk controller.

-Tony

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

* Re: Is it possible to corrupt disk when writeback page with undetected UE?
  2022-09-15 22:50 ` Luck, Tony
@ 2022-09-16  0:26   ` Jane Chu
  2022-09-16  0:30     ` Yang Shi
  2022-09-16 16:17     ` Luck, Tony
  0 siblings, 2 replies; 7+ messages in thread
From: Jane Chu @ 2022-09-16  0:26 UTC (permalink / raw)
  To: Luck, Tony, Borislav Petkov, djwong; +Cc: x86, linux-fsdevel, linux-mm

On 9/15/2022 3:50 PM, Luck, Tony wrote:
>> Suppose there is a UE in a DRAM page that is backed by a disk file.
>> The UE hasn't been reported to the kernel, but low level firmware
>> initiated scrubbing has already logged the UE.
>>
>> The page is then dirtied by a write, although the write clearly failed,
>> it didn't trigger an MCE.
>>
>> And without a subsequent read from the page, at some point, the page is
>> written back to the disk, leaving a PAGE_SIZE of zeros in the targeted
>> disk blocks.
>>
>> Is this mode of disk corruption possible?
> 
> I didn't look at what was written to disk, but I have seen this. My test sequence
> was to compile and then immediately run an error injection test program that
> injected a memory UC error to an instruction.
> 
> Because the program was freshly compiled, the executable file was in the
> page cache with all pages marked as modified. Later a sync (or memory
> pressure) wrote the dirty page with poison to filesystem.
> 
> I did see an error reported by the disk controller.

Thanks a lot for this information!

Were you using madvise to inject an error to a mmap'ed address?
or a different tool?  Do you still have the test documented
somewhere?

And, aside from verifying every write with a read prior to sync,
any suggestion to minimize the window of such corruption?

thanks!
-jane

> 
> -Tony


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

* Re: Is it possible to corrupt disk when writeback page with undetected UE?
  2022-09-16  0:26   ` Jane Chu
@ 2022-09-16  0:30     ` Yang Shi
  2022-09-16  0:51       ` Jane Chu
  2022-09-16 16:17     ` Luck, Tony
  1 sibling, 1 reply; 7+ messages in thread
From: Yang Shi @ 2022-09-16  0:30 UTC (permalink / raw)
  To: Jane Chu
  Cc: Luck, Tony, Borislav Petkov, djwong, x86, linux-fsdevel, linux-mm

On Thu, Sep 15, 2022 at 5:27 PM Jane Chu <jane.chu@oracle.com> wrote:
>
> On 9/15/2022 3:50 PM, Luck, Tony wrote:
> >> Suppose there is a UE in a DRAM page that is backed by a disk file.
> >> The UE hasn't been reported to the kernel, but low level firmware
> >> initiated scrubbing has already logged the UE.
> >>
> >> The page is then dirtied by a write, although the write clearly failed,
> >> it didn't trigger an MCE.
> >>
> >> And without a subsequent read from the page, at some point, the page is
> >> written back to the disk, leaving a PAGE_SIZE of zeros in the targeted
> >> disk blocks.
> >>
> >> Is this mode of disk corruption possible?
> >
> > I didn't look at what was written to disk, but I have seen this. My test sequence
> > was to compile and then immediately run an error injection test program that
> > injected a memory UC error to an instruction.
> >
> > Because the program was freshly compiled, the executable file was in the
> > page cache with all pages marked as modified. Later a sync (or memory
> > pressure) wrote the dirty page with poison to filesystem.
> >
> > I did see an error reported by the disk controller.
>
> Thanks a lot for this information!
>
> Were you using madvise to inject an error to a mmap'ed address?
> or a different tool?  Do you still have the test documented
> somewhere?
>
> And, aside from verifying every write with a read prior to sync,
> any suggestion to minimize the window of such corruption?

We discussed the topic at this year's LSFMM summit. Please refer to
https://lwn.net/Articles/893565/

>
> thanks!
> -jane
>
> >
> > -Tony
>

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

* Re: Is it possible to corrupt disk when writeback page with undetected UE?
  2022-09-16  0:30     ` Yang Shi
@ 2022-09-16  0:51       ` Jane Chu
  0 siblings, 0 replies; 7+ messages in thread
From: Jane Chu @ 2022-09-16  0:51 UTC (permalink / raw)
  To: Yang Shi
  Cc: Luck, Tony, Borislav Petkov, djwong, x86, linux-fsdevel, linux-mm

On 9/15/2022 5:30 PM, Yang Shi wrote:
> On Thu, Sep 15, 2022 at 5:27 PM Jane Chu <jane.chu@oracle.com> wrote:
>>
>> On 9/15/2022 3:50 PM, Luck, Tony wrote:
>>>> Suppose there is a UE in a DRAM page that is backed by a disk file.
>>>> The UE hasn't been reported to the kernel, but low level firmware
>>>> initiated scrubbing has already logged the UE.
>>>>
>>>> The page is then dirtied by a write, although the write clearly failed,
>>>> it didn't trigger an MCE.
>>>>
>>>> And without a subsequent read from the page, at some point, the page is
>>>> written back to the disk, leaving a PAGE_SIZE of zeros in the targeted
>>>> disk blocks.
>>>>
>>>> Is this mode of disk corruption possible?
>>>
>>> I didn't look at what was written to disk, but I have seen this. My test sequence
>>> was to compile and then immediately run an error injection test program that
>>> injected a memory UC error to an instruction.
>>>
>>> Because the program was freshly compiled, the executable file was in the
>>> page cache with all pages marked as modified. Later a sync (or memory
>>> pressure) wrote the dirty page with poison to filesystem.
>>>
>>> I did see an error reported by the disk controller.
>>
>> Thanks a lot for this information!
>>
>> Were you using madvise to inject an error to a mmap'ed address?
>> or a different tool?  Do you still have the test documented
>> somewhere?
>>
>> And, aside from verifying every write with a read prior to sync,
>> any suggestion to minimize the window of such corruption?
> 
> We discussed the topic at this year's LSFMM summit. Please refer to
> https://lwn.net/Articles/893565/

Thanks!  I'll take a look.

-jane

> 
>>
>> thanks!
>> -jane
>>
>>>
>>> -Tony
>>


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

* RE: Is it possible to corrupt disk when writeback page with undetected UE?
  2022-09-16  0:26   ` Jane Chu
  2022-09-16  0:30     ` Yang Shi
@ 2022-09-16 16:17     ` Luck, Tony
  2022-09-16 19:26       ` Jane Chu
  1 sibling, 1 reply; 7+ messages in thread
From: Luck, Tony @ 2022-09-16 16:17 UTC (permalink / raw)
  To: chu, jane, Borislav Petkov, djwong; +Cc: x86, linux-fsdevel, linux-mm

> Were you using madvise to inject an error to a mmap'ed address?
> or a different tool?  Do you still have the test documented
> somewhere?

I was injecting with ACPI/EINJ (so tweaking some ECC bits in memory to create
a real uncorrectable error). This was a long time back when I was just trying to
get basic recovery from usermode access to poison working reliably. So I just
noted the workaround ("make; sync; run_test") to keep making progress.

Handling poison in the page cache has been on my TODO list for a long time.
Someday it will make it to the top.

> And, aside from verifying every write with a read prior to sync,
> any suggestion to minimize the window of such corruption?

There's no cheap solution. As you point out the best that can be done
is to reduce the window (since bits may get flipped after you perform
your check but before DMS to storage).

-Tony


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

* Re: Is it possible to corrupt disk when writeback page with undetected UE?
  2022-09-16 16:17     ` Luck, Tony
@ 2022-09-16 19:26       ` Jane Chu
  0 siblings, 0 replies; 7+ messages in thread
From: Jane Chu @ 2022-09-16 19:26 UTC (permalink / raw)
  To: Luck, Tony, Borislav Petkov, djwong; +Cc: x86, linux-fsdevel, linux-mm

On 9/16/2022 9:17 AM, Luck, Tony wrote:
>> Were you using madvise to inject an error to a mmap'ed address?
>> or a different tool?  Do you still have the test documented
>> somewhere?
> 
> I was injecting with ACPI/EINJ (so tweaking some ECC bits in memory to create
> a real uncorrectable error). This was a long time back when I was just trying to
> get basic recovery from usermode access to poison working reliably. So I just
> noted the workaround ("make; sync; run_test") to keep making progress.
> 
> Handling poison in the page cache has been on my TODO list for a long time.
> Someday it will make it to the top.

I see, looking forward to your patches.

> 
>> And, aside from verifying every write with a read prior to sync,
>> any suggestion to minimize the window of such corruption?
> 
> There's no cheap solution. As you point out the best that can be done
> is to reduce the window (since bits may get flipped after you perform
> your check but before DMS to storage).

Sounds like the disk controller is the last in the chain in terms
of detecting a late UE, so if the disk controller detection could
trickle up to a filesystem level action marking 'file:<offset,len>'
being bad and relate the information to user for repair, that might be 
reasonable...

thanks,
-jane

> 
> -Tony
> 


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

end of thread, other threads:[~2022-09-16 19:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15 22:36 Is it possible to corrupt disk when writeback page with undetected UE? Jane Chu
2022-09-15 22:50 ` Luck, Tony
2022-09-16  0:26   ` Jane Chu
2022-09-16  0:30     ` Yang Shi
2022-09-16  0:51       ` Jane Chu
2022-09-16 16:17     ` Luck, Tony
2022-09-16 19:26       ` Jane Chu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.