Commit 520dfd8b authored by Jesse Brandeburg's avatar Jesse Brandeburg Committed by Jeff Kirsher

i40e: clamp debugfs nvm read command

This issue was identified by the coverity checker where we were
not checking the upper limit on reads, reported by Hannes
Frederic Sowa.

Implement more specific limits on reads (min 1k, max 4k)
Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
CC: Hannes Frederic Sowa <hannes@stressinduktion.org>
Tested-by: default avatarKavindya Deegala <kavindya.s.deegala@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 6301002f
...@@ -1742,11 +1742,13 @@ static ssize_t i40e_dbg_command_write(struct file *filp, ...@@ -1742,11 +1742,13 @@ static ssize_t i40e_dbg_command_write(struct file *filp,
goto command_write_done; goto command_write_done;
} }
/* Read at least 512 words */ /* set the max length */
if (buffer_len == 0) buffer_len = min_t(u16, buffer_len, I40E_MAX_AQ_BUF_SIZE/2);
buffer_len = 512;
bytes = 2 * buffer_len; bytes = 2 * buffer_len;
/* read at least 1k bytes, no more than 4kB */
bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE);
buff = kzalloc(bytes, GFP_KERNEL); buff = kzalloc(bytes, GFP_KERNEL);
if (!buff) if (!buff)
goto command_write_done; goto command_write_done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment