Racy access to ListDepth in CxPlatPoolFree in quic_platform_posix.h #2766
                  
                    
                      GaneshRapolu
                    
                  
                
                  started this conversation in
                General
              
            Replies: 1 comment 2 replies
-
| 
         This depth really is treated more as a guideline than a hard limit. This is just used to try to impose a reasonable limit on the maximum number of items in the pool, but the limit is still arbitrary; so there's not a lot of reason to add complexity to enforce it. Unless there is actually an issue that can be reproduced related to this, I'd most likely leave it as is. Thanks for doing the work to analyze the code and provide this feedback!  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
See
msquic/src/inc/quic_platform_posix.h
Line 537 in 1f2e91a
Pool->ListDepth is accessed with and without protection of Pool->Lock. However, ListDepth is declared as uint16_t in struct CXPLAT_POOL
msquic/src/inc/quic_platform_posix.h
Line 417 in 1f2e91a
It is neither an atomic variable, nor is the access inside CxPlatPoolFree atomic. Thus the read of ListDepth outside of Pool->Lock races with the write of ListDepth inside of Pool->Lock in CxPlatPoolFree. From my understanding, this is UB.
Think we can fix this without perf impact using relaxed atomics, as the CXPLAT_POOL_MAXIMUM_DEPTH is a best effort bound anyway.
Beta Was this translation helpful? Give feedback.
All reactions