Changeset 390e987e in rtems for cpukit/libblock


Ignore:
Timestamp:
Sep 16, 2013, 8:43:30 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
38d94f56
Parents:
a44917e
git-author:
Sebastian Huber <sebastian.huber@…> (09/16/13 08:43:30)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/16/13 08:54:51)
Message:

libblock: PR2145: Limit maximum read-ahead blocks

This helps to prevent stack overflows due to configuration errors.

Location:
cpukit/libblock
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libblock/include/rtems/bdbuf.h

    ra44917e r390e987e  
    461461 * @retval RTEMS_CALLED_FROM_ISR Called from an interrupt context.
    462462 * @retval RTEMS_INVALID_NUMBER The buffer maximum is not an integral multiple
    463  * of the buffer minimum.
     463 * of the buffer minimum.  The maximum read-ahead blocks count is too large.
    464464 * @retval RTEMS_RESOURCE_IN_USE Already initialized.
    465465 * @retval RTEMS_UNSATISFIED Not enough resources.
  • cpukit/libblock/src/bdbuf.c

    ra44917e r390e987e  
    13791379}
    13801380
     1381static size_t
     1382rtems_bdbuf_read_request_size (uint32_t transfer_count)
     1383{
     1384  return sizeof (rtems_blkdev_request)
     1385    + sizeof (rtems_blkdev_sg_buffer) * transfer_count;
     1386}
     1387
    13811388/**
    13821389 * Initialise the cache.
     
    14041411   * Check the configuration table values.
    14051412   */
     1413
    14061414  if ((bdbuf_config.buffer_max % bdbuf_config.buffer_min) != 0)
     1415    return RTEMS_INVALID_NUMBER;
     1416
     1417  if (rtems_bdbuf_read_request_size (bdbuf_config.max_read_ahead_blocks)
     1418      > RTEMS_MINIMUM_STACK_SIZE / 8U)
    14071419    return RTEMS_INVALID_NUMBER;
    14081420
     
    20782090#define bdbuf_alloc(size) __builtin_alloca (size)
    20792091
    2080   req = bdbuf_alloc (sizeof (rtems_blkdev_request) +
    2081                      sizeof (rtems_blkdev_sg_buffer) * transfer_count);
     2092  req = bdbuf_alloc (rtems_bdbuf_read_request_size (transfer_count));
    20822093
    20832094  req->req = RTEMS_BLKDEV_REQ_READ;
Note: See TracChangeset for help on using the changeset viewer.