[lkml]   [2010]   [Jun]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] sanitize task->comm to avoid leaking escape codes
    On Tue, Jun 29, 2010 at 11:45:14AM +0300, Alexey Dobriyan wrote:
    > On Tue, Jun 29, 2010 at 12:03 AM, Kees Cook <> wrote:
    > > On Mon, Jun 28, 2010 at 01:00:28PM -0700, Andrew Morton wrote:
    > >> Surely it would be better to fix the tools which display this info
    > >> rather than making the kernel tell fibs.
    > >
    > > The strncpy in get_task_comm() is totally wrong -- it's testing the length
    > > of task->comm.
    > It also fills not just any buffer but buffer which is TASK_COMM_LEN byte wide.
    > > Why should get_task_comm not take a destination buffer length argument?
    > If you pass too small, you needlessly truncate output.

    If you pass too small a buffer, get_task_comm will happily write all over
    the caller's stack past the end of the buffer if the contents of task->comm
    are large enough:

    strncpy(buf, tsk->comm, sizeof(tsk->comm));

    The "n" argument to get_task_comm's use of strncpy is totally wrong --
    it needs to be the size of the destination, not the size of the source.
    Luckily, everyone using get_task_comm currently uses buffers that are

    > If you pass too large, you waste space.



    Kees Cook
    Ubuntu Security Team

     \ /
      Last update: 2010-06-29 17:13    [W:0.021 / U:15.012 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site