netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Cc: davem@davemloft.net, kuba@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	syzbot+c2a7e5c5211605a90865@syzkaller.appspotmail.com
Subject: Re: [PATCH] net/qrtr: restrict length in qrtr_tun_write_iter()
Date: Mon, 22 Feb 2021 09:45:09 +0100	[thread overview]
Message-ID: <573bd57c-5ef8-3d4c-1fe9-eaa0337e7bfd@gmail.com> (raw)
In-Reply-To: <20210221123912.3185059-1-snovitoll@gmail.com>



On 2/21/21 1:39 PM, Sabyrzhan Tasbolatov wrote:
>> Do we really expect to accept huge lengths here ?
> 
> Sorry for late response but I couldnt find any reference to the max
> length of incoming data for qrtr TUN interface.
> 
>> qrtr_endpoint_post() will later attempt a netdev_alloc_skb() which will need
>> some extra space (for struct skb_shared_info)
> 
> Thanks, you're right, qrtr_endpoint_post() will alloc another slab buffer.
> We can check the length of skb allocation but we need to do following:
> 
> int qrtr_endpoint_post(.., const void *data, size_t len) 
> {
> 	..
> 	when QRTR_PROTO_VER_1:
> 		hdrlen = sizeof(*data);
> 	when QRTR_PROTO_VER_2:
> 		hdrlen = sizeof(*data) + data->optlen;
> 	
> 	len = (KMALLOC_MAX_SIZE - hdrlen) % data->size;
> 	skb = netdev_alloc_skb(NULL, len);
> 	..
> 	skb_put_data(skb, data + hdrlen, size);
> 
> 
> So it requires refactoring as in qrtr_tun_write_iter() we just allocate and
> pass it to qrtr_endpoint_post() and there
> we need to do len calculation as above *before* netdev_alloc_skb(NULL, len).
> 
> Perhaps there is a nicer solution though.
> 

A protocol requiring contiguous physical memory allocations of up to KMALLOC_MAX_SIZE
bytes would be really unreliable.

I suggest we simply limit the allocations to 64KB, unless qrtr maintainers shout,
or start implementing scatter gather.






      reply	other threads:[~2021-02-22  8:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02  9:20 [PATCH] net/qrtr: restrict user-controlled length in qrtr_tun_write_iter() Sabyrzhan Tasbolatov
2021-02-04  0:28 ` Jakub Kicinski
2021-02-04  9:02   ` [PATCH] net/qrtr: replaced useless kzalloc with kmalloc " Sabyrzhan Tasbolatov
2021-02-04 18:51     ` Jakub Kicinski
2021-02-04 18:53       ` Jakub Kicinski
2021-02-04  0:40 ` [PATCH] net/qrtr: restrict user-controlled length " patchwork-bot+netdevbpf
2021-02-12 11:51 ` Eric Dumazet
2021-02-21 12:39   ` [PATCH] net/qrtr: restrict " Sabyrzhan Tasbolatov
2021-02-22  8:45     ` Eric Dumazet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=573bd57c-5ef8-3d4c-1fe9-eaa0337e7bfd@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=snovitoll@gmail.com \
    --cc=syzbot+c2a7e5c5211605a90865@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).