FreeAndNil commented on issue #279:
URL: 
https://github.com/apache/logging-log4net/issues/279#issuecomment-3697377332

   @gdziadkiewicz this issue was reported as "security vulnerability" via 
yeswehack.com.
   There a no real world problems, yet.
   
   What you you think about the following paths?
   
   Lock order A (logging path)
   
   ```csharp
   // AppenderSkeleton.cs
   public virtual void DoAppend(LoggingEvent loggingEvent)
   {
     lock (LockObj)
     {
         Append(loggingEvent);
     }
   }
   
   // RollingFileAppender.cs
   protected override void Append(LoggingEvent loggingEvent)
   {
     ...
     AdjustFileBeforeAppend();
     ...
   }
   
   protected virtual void AdjustFileBeforeAppend()
   {
     _mutexForRolling?.WaitOne();
   }
   
   DoAppend()                
     lock(LockObj)
       Append()             
         AdjustFileBeforeAppend()
            _mutexForRolling.WaitOne()
   ```
   Holds LockObj -> waits for _mutexForRolling
   
   Lock order B (rollover path)
   
   ```csharp
   // RollingFileAppender.cs
   protected virtual void RollOverTime(bool fileIsOpen)
   {
     _mutexForRolling?.WaitOne();
     try
     {
       RollOverRenameFiles(...);
     }
     finally
     {
       _mutexForRolling?.ReleaseMutex();
     }
   }
   
   protected virtual void RollOverRenameFiles(string baseFileName)
   {
     SafeOpenFile();
   }
   
   // FileAppender.cs
   protected void SafeOpenFile()
   {
     OpenFile(_fileName, _appendToFile);
   }
   
   protected virtual void OpenFile(string fileName, bool append)
   {
     lock (LockObj)
     {
       // ...
     }
   }
   
   RollOverTime()
     _mutexForRolling.WaitOne()
       RollOverRenameFiles()
         SafeOpenFile()
           OpenFile()
             lock(LockObj)
   ```
   Holds _mutexForRolling -> waits for LockObj
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to