ExportXMLWordPrintableJSON

    • Query Optimization
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I found a potential null pointer dereference in listSessionsParseSpec() in MongoDB 8.0.9

      The return value of Client::getCurrent()->getOperationContext() is passed to LogicalSessionCache::get() without a prior null check:

      {{uassert(
      31111,
      str::stream() << "The " << DocumentSourceListLocalSessions::kStageName
      << " stage is not allowed in this context :: missing a LogicalSessionCache",
      LogicalSessionCache::get(Client::getCurrent()->getOperationContext()));}}

      According to the documentation of Client::getOperationContext(), this method may return nullptr if the client has no active operation context:

      "Gets the operation context active on this client, or nullptr if there is no such context."

      If getOperationContext() returns nullptr, the pointer is passed to LogicalSessionCache::get(OperationContext*), which dereferences it without checking

      {{LogicalSessionCache* LogicalSessionCache::get(OperationContext* ctx) {
      return get(ctx->getClient()->getServiceContext());
      }}}

      This may lead to undefined behavior. Although the call is made inside uassert, the null pointer would be dereferenced while evaluating its condition, before uassert can handle the result.

      The return value of getOperationContext() should be checked before passing it to LogicalSessionCache::get().

      Found by Linux Verification Center (linuxtesting.org) with SVACE.

      Reporter: Grebennikov Aleksandr (grebennikov@bmstu.ru)

            Assignee:
            Unassigned
            Reporter:
            Александр Гребенников (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: