lkml.org 
[lkml]   [2007]   [Feb]   [4]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
DateSat, 03 Feb 2007 22:00:53 -0800
FromPetr Vandrovec <>
SubjectRe: NCPFS and brittle connections
Pierre Ossman wrote:
> Ok... how about this baby instead. I've replaced the stack allocated
> request structure by one allocated with kmalloc() and reference counted
> using an atomic_t. I couldn't see anything else that was associated to
> the process, so I believe this should suffice.
> 
> (This is just a RFC. Once I get an ok from you I'll put together a more
> proper patch mail)
> 
> -       req.tx_type = *(u_int16_t*)server->packet;
> -
> -       result = ncp_add_request(server, &req);
> +       struct ncp_request_reply *req;
> +
> +       req = ncp_alloc_req();
> +       if (!req)
> +               return -ENOMEM;
> +
> +       req->reply_buf = reply_buf;
> +       req->datalen = max_reply_size;
> +       req->tx_iov[1].iov_base = server->packet;
> +       req->tx_iov[1].iov_len = size;
> +       req->tx_iovlen = 1;
> +       req->tx_totallen = size;
> +       req->tx_type = *(u_int16_t*)server->packet;

Problem is with these pointers - reply_buf & server->packet.  Now code 
will just read packet from server->packet, and write result to 
reply_buf, most probably transmiting some random data to network, and 
overwriting innocent memory on receiption...  I believe that you need to 
make copies of server->packet/size for transmission, and some simillar 
solution for receive as well.  As both request & response can be up to 
~66000 bytes.
							Petr

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-02-04 07:03    [from the cache]
©2003-2008