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

Skip to content
Commit 91e6cd0b authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make sure caller verification is done inside a lock

This caller verification needs to be done in an atomic manner.  There
is a possible race condition in the following code.

  @BinderThread
  public boolean doSomething() {
      if (!calledFromValidUser()) {
          return false;
      }
      // possible race condition here.
      synchronized(mMethodMap) {
          // actual operations
      }
  }

Insted, we should check the caller after taking a lock.

  @BinderThread
  public boolean doSomething() {
      synchronized(mMethodMap) {
          if (!calledFromValidUserLocked()) {
              return false;
          }

          // actual operations
      }
  }

Bug: 34886274
Test: atest CtsInputMethodTestCases CtsInputMethodServiceHostTestCases
Change-Id: I02df0307ce2aecc77de8fb2afaa39e5ecf8f3fe2
parent ca2d3b6c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment