<feed xmlns='http://www.w3.org/2005/Atom'>
<title>talos-skiboot/libc/stdio/vsnprintf.c, branch master</title>
<subtitle>Talos™ II skiboot sources</subtitle>
<id>https://git.raptorcs.com/git/talos-skiboot/atom?h=master</id>
<link rel='self' href='https://git.raptorcs.com/git/talos-skiboot/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/'/>
<updated>2017-02-02T05:35:42+00:00</updated>
<entry>
<title>libc/stdio/vsnprintf.c: add explicit fallthrough</title>
<updated>2017-02-02T05:35:42+00:00</updated>
<author>
<name>Stewart Smith</name>
<email>stewart@linux.vnet.ibm.com</email>
</author>
<published>2017-02-02T05:35:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=11cf409be293091470b3f75619416e2bb2697265'/>
<id>urn:sha1:11cf409be293091470b3f75619416e2bb2697265</id>
<content type='text'>
silences recent GCC warning

Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>libc : Changes variable data type where return value of strlen() stored from int to size_t</title>
<updated>2016-10-11T04:40:30+00:00</updated>
<author>
<name>Mukesh Ojha</name>
<email>mukesh02@linux.vnet.ibm.com</email>
</author>
<published>2016-09-02T04:56:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=32dc2a19bb6a91862b414fdd6eec07154e5e4308'/>
<id>urn:sha1:32dc2a19bb6a91862b414fdd6eec07154e5e4308</id>
<content type='text'>
Reason of the change as integer value may overflow, and it can give negative
value for the length.

This patch also changes the data type of variable which is compared with
strlen() as the comparison also has to be done on the same level.

Signed-off-by: Mukesh Ojha &lt;mukesh02@linux.vnet.ibm.com&gt;
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>Fix for typos</title>
<updated>2016-06-20T05:08:05+00:00</updated>
<author>
<name>Frederic Bonnard</name>
<email>frediz@linux.vnet.ibm.com</email>
</author>
<published>2016-06-13T09:37:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=4c95b5e04e3c4f72e4005574f67cd6e365d3276f'/>
<id>urn:sha1:4c95b5e04e3c4f72e4005574f67cd6e365d3276f</id>
<content type='text'>
While reviewing the Debian packaging, codespell found those.
Most proposed fixes are based on codespell's default dictionnary.

Signed-off-by: Frederic Bonnard &lt;frediz@linux.vnet.ibm.com&gt;
Reviewed-by: Mukesh Ojha &lt;mukesh02@linux.vnet.ibm.com&gt;
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>opal: Fix buffer overrun in print_* functions.</title>
<updated>2015-01-19T06:15:22+00:00</updated>
<author>
<name>Mahesh Salgaonkar</name>
<email>mahesh@linux.vnet.ibm.com</email>
</author>
<published>2015-01-14T18:32:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=d0b91f6c8b4f159fc05eca21fceff1bf98fabd51'/>
<id>urn:sha1:d0b91f6c8b4f159fc05eca21fceff1bf98fabd51</id>
<content type='text'>
While running HMI tests I saw a massive corruption in OPAL for one of the
HMI test that injects TB error. On investigation I found that
vsnprintf()-&gt;print_itoa() was the culprit. print_itoa function uses tmp
array of size 16 to convert unsigned long value to ASCII. But an unsigned
value of 0xffffffffffffffff needs atleast 25 characters to print its ASCII
representation. This caused an array to overflow resulting into corruption,
unpredictable behavior and finally system termination.

We could fix this by increasing the size of tmp[] array but that still won't
fix this bug completely. While auditing vsnprintf() function I found that
it makes use of print_*() functions to write data to buffer. But none of
the print_* function have any check on buffer size before writing data to it.
Without size check print_*() can easily overrun buffer passed by
vprlog()-&gt;vsnprintf()-&gt;print_format()-&gt;print_*() causing massive corruption
leading to unpredictable behavior.

This patch fixes this bug by modifying print_*() function to check for
buffer size to avoid buffer overrun.

- Modified print_format(), print_fill() and print_itoa() to take bufsize
  as argument and added a size check while writing to buffer.
- Remove temporary array from print_itoa(), instead write data directly to
  buffer.
- Added two new function print_str_fill() and print_str() to be used as
  helper routine for '%s' fmt case in print_format() function. These new
  routines now has a check on buffer size while copying NULL terminated
  string to buffer.
- Added "!bufsize" check in vsnprintf() to avoid buffer overrun while
  setting NULL character before returning.

I ran HMI tests with this patch successfully. I also tested this patch by
reducing size of the buffer (in core/console-log.c:vprlog()) from 320 to 50
and booted the lid successfully with no corruption at all.

Signed-off-by: Mahesh Salgaonkar &lt;mahesh@linux.vnet.ibm.com&gt;
Acked-by: Ananth N Mavinakayanahalli &lt;ananth@in.ibm.com&gt;
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>vsnprintf: Change print_itoa to use less stack</title>
<updated>2014-11-26T00:22:23+00:00</updated>
<author>
<name>Shreyas B. Prabhu</name>
<email>shreyas@linux.vnet.ibm.com</email>
</author>
<published>2014-11-18T19:37:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=17e1e12ecfff1dea9f388b8c816ad638b0eff720'/>
<id>urn:sha1:17e1e12ecfff1dea9f388b8c816ad638b0eff720</id>
<content type='text'>
Remove recursive call in print_itoa to reduce the stack usage.

Signed-off-by: Shreyas B. Prabhu &lt;shreyas@linux.vnet.ibm.com&gt;
Signed-off-by: Stewart Smith &lt;stewart@linux.vnet.ibm.com&gt;
</content>
</entry>
<entry>
<title>Initial commit of Open Source release</title>
<updated>2014-07-02T05:36:20+00:00</updated>
<author>
<name>Benjamin Herrenschmidt</name>
<email>benh@kernel.crashing.org</email>
</author>
<published>2014-07-02T05:36:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.raptorcs.com/git/talos-skiboot/commit/?id=1d880992fd8c8457a2d990ac6622cfd58fb1b261'/>
<id>urn:sha1:1d880992fd8c8457a2d990ac6622cfd58fb1b261</id>
<content type='text'>
Signed-off-by: Benjamin Herrenschmidt &lt;benh@kernel.crashing.org&gt;
</content>
</entry>
</feed>
