Skip to content

Commit

Permalink
8293232: Fix race condition in pkcs11 SessionManager
Browse files Browse the repository at this point in the history
Backport-of: 939741c0a0a4a5ce2c68d14b15e1f42563bc653d
  • Loading branch information
zzambers committed Mar 21, 2023
1 parent d6f8151 commit ad41d90
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions jdk/src/share/classes/sun/security/pkcs11/SessionManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -202,7 +202,12 @@ void demoteObjSession(Session session) {
// will be added to correct pool on release, nothing to do now
return;
}
opSessions.release(session);
// Objects could have been added to this session by other thread between
// check in Session.removeObject method and objSessions.remove call
// higher. Therefore releaseSession method, which performs additional
// check for objects, is used here to avoid placing this session
// in wrong pool due to race condition.
releaseSession(session);
}

private Session openSession() throws PKCS11Exception {
Expand Down

1 comment on commit ad41d90

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.