From: Dan Carpenter <dan.carpenter@oracle.com>
To: nan chen <whutchennan@gmail.com>
Cc: Krzysztof Halasa <khc@pm.waw.pl>,
Jakub Kicinski <kuba@kernel.org>,
security@kernel.org, Greg KH <greg@kroah.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH] hdlc_ppp: add range checks in ppp_cp_parse_cr()
Date: Wed, 9 Sep 2020 10:19:24 +0300 [thread overview]
Message-ID: <20200909071924.GT8321@kadam> (raw)
In-Reply-To: <CAMnVd19nWToENW3X7v_PZN4snoXAoLgqKqn=dezXnd=z89zL7Q@mail.gmail.com>
On Wed, Sep 09, 2020 at 05:37:37AM +0800, nan chen wrote:
> Looks like the judgment of len <sizeof(valid_accm) has a problem.
> The judgment cannot avoid the memory overflow of the memcpy below.
> case LCP_OPTION_ACCM: /* async control character
> map */
> + if (len < sizeof(valid_accm))
> + goto err_out;
> Assume that the initial value of len is 10.Then the length of 'out' memory
> is 10.
> And assume the value of opt[1] in each loop is 2.
> Then it will loop 3 times.
> 3 times memcpy will cause the 'out' memory to be overwritten by 18 bytes (
> > 10 bytes). This will be memory overflow.
>
> I think the correct way is to judge the value of opt[1] like this:
> . case LCP_OPTION_ACCM: /* async control character
> map */
> + if (opt[1] < sizeof(valid_accm))
> + goto err_out;
>
Yeah. You're right. The "nak_len" count would grow faster than it
should leading to memory corruption. I'll resend.
regards,
dan carpenter
next prev parent reply other threads:[~2020-09-09 7:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200908153200.GB4165114@kroah.com>
2020-09-08 17:53 ` [PATCH] hdlc_ppp: add range checks in ppp_cp_parse_cr() Dan Carpenter
[not found] ` <CAMnVd19nWToENW3X7v_PZN4snoXAoLgqKqn=dezXnd=z89zL7Q@mail.gmail.com>
2020-09-09 7:19 ` Dan Carpenter [this message]
2020-09-09 9:46 ` [PATCH v2 net] " Dan Carpenter
2020-09-10 20:00 ` 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=20200909071924.GT8321@kadam \
--to=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=greg@kroah.com \
--cc=khc@pm.waw.pl \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=security@kernel.org \
--cc=whutchennan@gmail.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).