Coder Social home page Coder Social logo

Comments (3)

PeterHuewe avatar PeterHuewe commented on June 16, 2024

Okay the problem lies in the following order:
src/lib/session.c , session_open line 70:
session_table_lock(global.s_table);
session_table_lock now holds global.s_table mutex
line 71:
rv = check_max_sessions(is_rw);
which calls

static CK_RV check_max_sessions(bool is_rw) {

    unsigned long cnt = session_table_get_cnt(global.s_table, is_rw);
    return (cnt > MAX_NUM_OF_SESSIONS) ?
        CKR_SESSION_COUNT : CKR_OK;
}

which calls

unsigned long session_table_get_cnt(session_table *t, bool is_rw) {
    session_table_lock(t);
    unsigned long tmp = is_rw ? t->rw_cnt : t->cnt;
    session_table_unlock(t);
    return tmp;
}

--> session_table_get_cnt wants to take the mutex again on global.s_table (which is already held)
-> deadlock.

Question is whether the locking in session_open can simply be removed?

from tpm2-pkcs11.

williamcroberts avatar williamcroberts commented on June 16, 2024

I think you need to remove the locking from session_table_get_cnt(). The lock on the session table is required when adding an entry via session_table_new_ctx_unlocked(). Probably make a new session_table_get_count_unlocked() or something like that.

I am also OK with a general refactoring of the session code layout, not happy with how that currently turned out.

FYI: I have a --debug in configure that should use a PTHREAD_MUTEX_ERRORCHECK attributed thread.

from tpm2-pkcs11.

williamcroberts avatar williamcroberts commented on June 16, 2024

This seems to be fixed in #47 and #48

from tpm2-pkcs11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.