The Linux year 2038 bug

I guess all of u know bout Y2K the infamous time dependent bug . The bug did not result in any major problem as expected and most machines would continue operating as usual through the century turnover, with the worst result being an incorrect date . Now there is another bug “Year 2038 bug ” targeting linux users .

What is year 2038 bug?

Most UNIX , Linux and other *nix based OS are written in ANSI C language . And if you are a C programmer , you probably know that in C you use 32-bit data type ‘time_t’ which stores time , and the mechanism for doing this is very simple . It converts the complete date into seconds and saves the value into it . The time starts from 1st jan 1970 00:00 hrs GMT . This means according to the counter the value of 1st jan 1970 1:00 AM will be saved as ‘3600’ into the variable.

Since time_t is a 32-bit data type , it has 32 memory units of which can have a value of 0 or 1 . As the first bit is used for storing weather the value is positive or negative , there are 31 bits left. The maximum value a 31-bit variable can take is 2^31 -1 , which is equal to ‘2147483648’ , meaning the data type can store 2147483648 seconds starting from 1st jan 1970 00:00:00 hrs . This means it can store date up to 03:14:07 Tuesday, January 19, 2038 . Times beyond this moment will “wrap around” and be represented internally as a negative number, and cause programs to fail, since they will see these times not as being in 2038 but rather in 1970 or 1901, depending on the implementation. Erroneous calculations and decisions may therefore result .

How dangerous is it?

To get an idea how dangerous it can be , do a small test (the output of this test will crash your GNOME environment) . Go to your linux machine , restart it and enter BIOS . Set the time to anything beyond 03:14:07 Tuesday, January 19, 2038 , save and restart the machine . When your Linux machine starts up , you will find that GNOME refuses to start up and will show some error messages . If you move to the command line and run the ‘top’ command , you will find some applications such as xscreensaver have gone to infinity loop and occupy the full processing power .

So what do you do about this problem?

By 2038 most implementations would have migrated to 64 bit . But saying that 2038 is far away is not the solution . Think of all the devices that are embedded with Linux . If a hacker manages to get into these devices and simply change the date to 2039 , the device will start to malfunctioning .Or a spammer could send out a mail with a malicious code that generates a fake time stamp of year 2039 and cause a Linux mail server to crash.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: