Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this possible racing condition? #73

Closed
hytgbn opened this issue Dec 15, 2020 · 2 comments
Closed

Is this possible racing condition? #73

hytgbn opened this issue Dec 15, 2020 · 2 comments

Comments

@hytgbn
Copy link
Contributor

hytgbn commented Dec 15, 2020

I recently found one of my host doesn't run specific cronjob file. The cronjob file is written when the host gets launched. (As part of UserData of AWS EC2 instance).

host: Amazon linux 4.14 assuming this supports inotify

Wondering if this race condition is ever possible:

  1. crond loads database without the cronjob file (or when the file doesn't have content) https://github.com/cronie-crond/cronie/blob/master/src/cron.c#L319
  2. Then the cronjob content is written.
  3. crond adds inotify watch https://github.com/cronie-crond/cronie/blob/master/src/cron.c#L333

If this is ever possible, would it make sense to do load_database after adds watch?

@t8m
Copy link
Member

t8m commented Dec 16, 2020

What is the cronie version on the system? There were some other possible races solved before.
But yes, it the job file is written simultaneously with crond startup I think the race you described above is possible and easy fix should be to just switch the order of the initial database load and watch setup.

hytgbn added a commit to hytgbn/cronie that referenced this issue Dec 24, 2020
Issue: cronie-crond#73

This CR is to fix race condition between file update and load_database
when INOTIFY is enabled.

Previously, if crontab file is simultaneously written when crond starts up,
there is chances to miss the notification. This is because load_database
was performed before inotify watches get registered.

This CR will invoke `load_database` after watches are registered, so
crond doesn't miss such updates.
t8m pushed a commit that referenced this issue Jan 4, 2021
Issue: #73

This CR is to fix race condition between file update and load_database
when INOTIFY is enabled.

Previously, if crontab file is simultaneously written when crond starts up,
there is chances to miss the notification. This is because load_database
was performed before inotify watches get registered.

This CR will invoke `load_database` after watches are registered, so
crond doesn't miss such updates.
@t8m
Copy link
Member

t8m commented Jan 22, 2021

Fixed with the PR #74

@t8m t8m closed this as completed Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants