summaryrefslogtreecommitdiffstats
path: root/virt/kvm/async_pf.c
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-03-04 09:56:02 -0500
committerSteven Rostedt <rostedt@goodmis.org>2015-03-04 09:56:02 -0500
commit4a8fe4e1811c96ad0ad9f4083f2fe4fb43b2988d (patch)
tree320bcd3bff9e4ce9cd97f6dcd839666751ead21c /virt/kvm/async_pf.c
parent13a7a6ac0a11197edcd0f756a035f472b42cdf8b (diff)
downloadtalos-op-linux-4a8fe4e1811c96ad0ad9f4083f2fe4fb43b2988d.tar.gz
talos-op-linux-4a8fe4e1811c96ad0ad9f4083f2fe4fb43b2988d.zip
seq_buf: Fix seq_buf_vprintf() truncation
In seq_buf_vprintf(), vsnprintf() is used to copy the format into the buffer remaining in the seq_buf structure. The return of vsnprintf() is the amount of characters written to the buffer excluding the '\0', unless the line was truncated! If the line copied does not fit, it is truncated, and a '\0' is added to the end of the buffer. But in this case, '\0' is included in the length of the line written. To know if the buffer had overflowed, the return length will be the same as the length of the buffer passed in. The check in seq_buf_vprintf() only checked if the length returned from vsnprintf() would fit in the buffer, as the seq_buf_vprintf() is only to be an all or nothing command. It either writes all the string into the seq_buf, or none of it. If the string is truncated, the pointers inside the seq_buf must be reset to what they were when the function was called. This is not the case. On overflow, it copies only part of the string. The fix is to change the overflow check to see if the length returned from vsnprintf() is less than the length remaining in the seq_buf buffer, and not if it is less than or equal to as it currently does. Then seq_buf_vprintf() will know if the write from vsnpritnf() was truncated or not. Cc: stable@vger.kernel.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'virt/kvm/async_pf.c')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud