From 1d36eca243ea54ffc82ef2de0649ba1bd23eb588 Mon Sep 17 00:00:00 2001 From: Josh Boyer Date: Thu, 12 Nov 2015 08:45:24 -0500 Subject: [PATCH] CVE-2015-5327 x509 time validation --- X.509-Fix-the-time-validation-ver-3.patch | 79 +++++++++++++++++++++++ kernel.spec | 6 ++ 2 files changed, 85 insertions(+) create mode 100644 X.509-Fix-the-time-validation-ver-3.patch diff --git a/X.509-Fix-the-time-validation-ver-3.patch b/X.509-Fix-the-time-validation-ver-3.patch new file mode 100644 index 000000000..a4056d878 --- /dev/null +++ b/X.509-Fix-the-time-validation-ver-3.patch @@ -0,0 +1,79 @@ +From 5cfd0a0f7cbc6bc9833b8a1bb5acb6056c9c53d9 Mon Sep 17 00:00:00 2001 +From: David Howells +Date: Thu, 12 Nov 2015 11:38:40 +0000 +Subject: [PATCH] X.509: Fix the time validation [ver #3] + +This fixes CVE-2015-5327. It affects kernels from 4.3-rc1 onwards. + +Fix the X.509 time validation to use month number-1 when looking up the +number of days in that month. Also put the month number validation before +doing the lookup so as not to risk overrunning the array. + +This can be tested by doing the following: + +cat < +Signed-off-by: David Howells +Tested-by: Mimi Zohar +Acked-by: David Woodhouse +--- + crypto/asymmetric_keys/x509_cert_parser.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/crypto/asymmetric_keys/x509_cert_parser.c b/crypto/asymmetric_keys/x509_cert_parser.c +index af71878dc15b..ddde54c45ff7 100644 +--- a/crypto/asymmetric_keys/x509_cert_parser.c ++++ b/crypto/asymmetric_keys/x509_cert_parser.c +@@ -531,7 +531,11 @@ int x509_decode_time(time64_t *_t, size_t hdrlen, + if (*p != 'Z') + goto unsupported_time; + +- mon_len = month_lengths[mon]; ++ if (year < 1970 || ++ mon < 1 || mon > 12) ++ goto invalid_time; ++ ++ mon_len = month_lengths[mon - 1]; + if (mon == 2) { + if (year % 4 == 0) { + mon_len = 29; +@@ -543,9 +547,7 @@ int x509_decode_time(time64_t *_t, size_t hdrlen, + } + } + +- if (year < 1970 || +- mon < 1 || mon > 12 || +- day < 1 || day > mon_len || ++ if (day < 1 || day > mon_len || + hour < 0 || hour > 23 || + min < 0 || min > 59 || + sec < 0 || sec > 59) +-- +2.4.3 + diff --git a/kernel.spec b/kernel.spec index edee8ed3d..7b0f0f797 100644 --- a/kernel.spec +++ b/kernel.spec @@ -608,6 +608,9 @@ Patch552: megaraid_sas-Do-not-use-PAGE_SIZE-for-max_sectors.patch #rhbz 1275490 Patch553: ideapad-laptop-Add-Lenovo-Yoga-900-to-no_hw_rfkill-d.patch +#CVE-2015-5327 +Patch554: X.509-Fix-the-time-validation-ver-3.patch + # END OF PATCH DEFINITIONS %endif @@ -2051,6 +2054,9 @@ fi # # %changelog +* Thu Nov 12 2015 Josh Boyer +- CVE-2015-5327 x509 time validation + * Wed Nov 11 2015 Josh Boyer - Linux v4.3 - Fix Yoga 900 rfkill switch issues (rhbz 1275490)