lkml.org 
[lkml]   [2020]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.19 11/17] AX.25: Prevent integer overflows in connect and sendmsg
    Date
    From: Dan Carpenter <dan.carpenter@oracle.com>

    [ Upstream commit 17ad73e941b71f3bec7523ea4e9cbc3752461c2d ]

    We recently added some bounds checking in ax25_connect() and
    ax25_sendmsg() and we so we removed the AX25_MAX_DIGIS checks because
    they were no longer required.

    Unfortunately, I believe they are required to prevent integer overflows
    so I have added them back.

    Fixes: 8885bb0621f0 ("AX.25: Prevent out-of-bounds read in ax25_sendmsg()")
    Fixes: 2f2a7ffad5c6 ("AX.25: Fix out-of-bounds read in ax25_connect()")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ---
    net/ax25/af_ax25.c | 5 ++++-
    1 file changed, 4 insertions(+), 1 deletion(-)

    --- a/net/ax25/af_ax25.c
    +++ b/net/ax25/af_ax25.c
    @@ -1191,6 +1191,7 @@ static int __must_check ax25_connect(str
    fsa->fsa_ax25.sax25_ndigis != 0) {
    /* Valid number of digipeaters ? */
    if (fsa->fsa_ax25.sax25_ndigis < 1 ||
    + fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS ||
    addr_len < sizeof(struct sockaddr_ax25) +
    sizeof(ax25_address) * fsa->fsa_ax25.sax25_ndigis) {
    err = -EINVAL;
    @@ -1512,7 +1513,9 @@ static int ax25_sendmsg(struct socket *s
    struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)usax;

    /* Valid number of digipeaters ? */
    - if (usax->sax25_ndigis < 1 || addr_len < sizeof(struct sockaddr_ax25) +
    + if (usax->sax25_ndigis < 1 ||
    + usax->sax25_ndigis > AX25_MAX_DIGIS ||
    + addr_len < sizeof(struct sockaddr_ax25) +
    sizeof(ax25_address) * usax->sax25_ndigis) {
    err = -EINVAL;
    goto out;

    \
     
     \ /
      Last update: 2020-07-30 10:07    [W:4.352 / U:0.184 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site