On 31/05/2019 15:44, Kees Cook wrote: > On Fri, May 31, 2019 at 11:46:29AM +0100, Colin Ian King wrote: >> Hi, >> >> Static analysis with Coverity on linux-next has found a potential issue >> with the following commit: >> >> commit 1633a4f04cc171fc638deb5c95af96032d3c591b >> Author: Ke Wu <mik...@google.com> >> Date: Thu May 30 12:22:08 2019 -0700 >> >> security/loadpin: Allow to exclude specific file types >> >> >> 209 for (j = 0; j < ARRAY_SIZE(kernel_read_file_str); j++) { >> 210 if (strcmp(cur, kernel_read_file_str[j]) == 0) { >> 211 pr_info("excluding: %s\n", >> 212 kernel_read_file_str[j]); >> >> CID 81977 (#1 of 1): Out-of-bounds write >> overrun-local: Overrunning array ignore_read_file_id of 8 4-byte >> elements at element index 8 (byte offset 35) using index j (which >> evaluates to 8). >> >> 213 ignore_read_file_id[j] = 1; >> >> According to Coverity ignore_read_file_id is an array of 8 integers. >> However, ARRAY_SIZE(kernel_read_file_str) is 9, so we have an out of >> bounds write on ignore_read_file[j] when j is 8. > > What am I missing? This doesn't fail the build: > > + BUILD_BUG_ON(ARRAY_SIZE(exclude_read_files) != > + ARRAY_SIZE(ignore_read_file_id)); > > They have the same number of elements. >
Yep, that's very true. I'll discuss this with Coverity as this seems like a weird false positive. Apologies for the noise. Colin