From: David Miller <davem@davemloft.net>
To: christophe.jaillet@wanadoo.fr
Cc: ajk@comnets.uni-bremen.de, linux-hams@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] net/hamradio/6pack: Fix the size of a sk_buff used in 'sp_bump()'
Date: Tue, 27 Aug 2019 21:39:53 -0700 (PDT) [thread overview]
Message-ID: <20190827.213953.102911550129423796.davem@davemloft.net> (raw)
In-Reply-To: <20190826190209.16795-1-christophe.jaillet@wanadoo.fr>
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Date: Mon, 26 Aug 2019 21:02:09 +0200
> We 'allocate' 'count' bytes here. In fact, 'dev_alloc_skb' already add some
> extra space for padding, so a bit more is allocated.
>
> However, we use 1 byte for the KISS command, then copy 'count' bytes, so
> count+1 bytes.
>
> Explicitly allocate and use 1 more byte to be safe.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch should be safe, be however may no be the correct way to fix the
> "buffer overflow". Maybe, the allocated size is correct and we should have:
> memcpy(ptr, sp->cooked_buf + 1, count - 1);
> or
> memcpy(ptr, sp->cooked_buf + 1, count - 1sp->rcount);
>
> I've not dig deep enough to understand the link betwwen 'rcount' and
> how 'cooked_buf' is used.
I'm trying to figure out how this code works too.
Why are they skipping over the first byte? Is that to avoid the
command byte? Yes, then using sp->rcount as the memcpy length makes
sense.
Why is the caller subtracting 2 from the RX buffer count when
calculating sp->rcount? This makes the situation even more confusing.
next prev parent reply other threads:[~2019-08-28 4:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-26 19:02 [PATCH] net/hamradio/6pack: Fix the size of a sk_buff used in 'sp_bump()' Christophe JAILLET
2019-08-28 4:39 ` David Miller [this message]
2019-09-07 13:48 ` David Miller
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=20190827.213953.102911550129423796.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=ajk@comnets.uni-bremen.de \
--cc=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-hams@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).