mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Exit tmpfs.fileInodeOperations.Translate early if required.Start >= EOF.
Otherwise required and optional can be empty or have negative length. PiperOrigin-RevId: 204007079 Change-Id: I59e472a87a8caac11ffb9a914b8d79bf0cd70995
This commit is contained in:
@@ -451,9 +451,12 @@ func (f *fileInodeOperations) Translate(ctx context.Context, required, optional
|
||||
// Constrain translations to f.attr.Unstable.Size (rounded up) to prevent
|
||||
// translation to pages that may be concurrently truncated.
|
||||
pgend := fs.OffsetPageEnd(f.attr.Unstable.Size)
|
||||
var buserr error
|
||||
var beyondEOF bool
|
||||
if required.End > pgend {
|
||||
buserr = &memmap.BusError{io.EOF}
|
||||
if required.Start >= pgend {
|
||||
return nil, &memmap.BusError{io.EOF}
|
||||
}
|
||||
beyondEOF = true
|
||||
required.End = pgend
|
||||
}
|
||||
if optional.End > pgend {
|
||||
@@ -481,9 +484,12 @@ func (f *fileInodeOperations) Translate(ctx context.Context, required, optional
|
||||
// Don't return the error returned by f.data.Fill if it occurred outside of
|
||||
// required.
|
||||
if translatedEnd < required.End && cerr != nil {
|
||||
return ts, cerr
|
||||
return ts, &memmap.BusError{cerr}
|
||||
}
|
||||
return ts, buserr
|
||||
if beyondEOF {
|
||||
return ts, &memmap.BusError{io.EOF}
|
||||
}
|
||||
return ts, nil
|
||||
}
|
||||
|
||||
// InvalidateUnsavable implements memmap.Mappable.InvalidateUnsavable.
|
||||
|
||||
Reference in New Issue
Block a user