[SERVER-11002] Insufficient permission will crash checkReadAhead() Created: 02/Oct/13  Updated: 11/Jul/16  Resolved: 07/Oct/13

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: 2.5.3

Type: Bug Priority: Major - P3
Reporter: Christian Zuckschwerdt Assignee: Matt Kangas
Resolution: Done Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux with Grsec / VM


Backwards Compatibility: Fully Compatible
Operating System: Linux
Participants:

 Description   

In https://github.com/mongodb/mongo/blob/master/src/mongo/db/db.cpp#L614
the function checkReadAhead() introduced by Core/SERVER-7335
https://jira.mongodb.org/browse/SERVER-7335
uses boost::filesystem::exists() without checks for exceptions.

An exception will be thrown if the path can't be accessed (due to insufficient access rights in my case). This will crash the startup.

I gather that checking the readahead is informational only. It would be an improvement to just log the error and carry on.

The attached patch will catch the filesystem exception and log a line of
Wed Oct 2 13:52:40.434 [initandlisten] boost::filesystem::status: Permission denied: "/sys/dev/block/9:0/queue/read_ahead_kb"

See here for the changes:
https://github.com/zuckschwerdt/mongo/commit/f0b286380b4647ebd7a1e084b84309f12bc8e087

And here for the complete patch with indentation
https://github.com/zuckschwerdt/mongo/commit/581f3abe6b1faa2a65168c3044eb1e8f737c07b8



 Comments   
Comment by Matt Kangas [ 07/Oct/13 ]

Merged in 69079a7 and b766095. Thanks for contributing to MongoDB!

Comment by Matt Kangas [ 03/Oct/13 ]

Hi Christian,

Your patch looks good. If you sign our contributor's agreement and submit this as a pull request, I will be happy to give you full credit for the fix.

  1. http://www.mongodb.com/legal/contributor-agreement
  2. Then submit a pull request from https://github.com/zuckschwerdt/mongo/tree/fix-checkreadahead-fs-exception

Please include "SERVER-11002" in the title of your pull request

Generated at Thu Feb 08 03:24:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.