Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5008cccc authored by Shai Barack's avatar Shai Barack
Browse files

Work around kernel bug in memfd

https://bugzilla.kernel.org/show_bug.cgi?id=217238
Use F_SEAL_FUTURE_WRITE instead of F_SEAL_WRITE to work around a bug in older kernels.

Also remove F_SEAL_SEAL because it's unnecessary in this context.

Fixes: 409846908
Bug: 410561771
Test: BitmapTest
Flag: com.android.graphics.hwui.flags.bitmap_use_memfd
Change-Id: I47a3ba9da06ae6cce2f91e2f808280bdc0a354fd
parent 8ad29e43
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -706,12 +706,15 @@ static binder_status_t writeBlob(AParcel* parcel, uint64_t bitmapId, const SkBit
            }

            if (fcntl(fd, F_ADD_SEALS,
                        // Disallow growing / shrinking
                      // Disallow growing / shrinking.
                      F_SEAL_GROW | F_SEAL_SHRINK
                        // If immutable, disallow writing
                        | (immutable ? F_SEAL_WRITE : 0)
                        // Seal the seals 🦭
                        | F_SEAL_SEAL) == -1) {
                      // If immutable, disallow writing.
                      // Use F_SEAL_FUTURE_WRITE instead of F_SEAL_WRITE to work around a bug in
                      // pre-6.7 kernels.
                      // There are no writable mappings made prior to this, so both seals are
                      // functionally equivalent.
                      // See: b/409846908#comment39
                      | (immutable ? F_SEAL_FUTURE_WRITE : 0))) {
                return STATUS_UNKNOWN_ERROR;
            }