lkml.org 
[lkml]   [2018]   [Nov]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.9 22/92] can: dev: __can_get_echo_skb(): Dont crash the kernel if can_priv::echo_skb is accessed out of bounds
    Date
    4.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Marc Kleine-Budde <mkl@pengutronix.de>

    commit e7a6994d043a1e31d5b17706a22ce33d2a3e4cdc upstream.

    If the "struct can_priv::echo_skb" is accessed out of bounds would lead
    to a kernel crash. Better print a sensible warning message instead and
    try to recover.

    Cc: linux-stable <stable@vger.kernel.org>
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/net/can/dev.c | 6 +++++-
    1 file changed, 5 insertions(+), 1 deletion(-)

    --- a/drivers/net/can/dev.c
    +++ b/drivers/net/can/dev.c
    @@ -457,7 +457,11 @@ struct sk_buff *__can_get_echo_skb(struc
    {
    struct can_priv *priv = netdev_priv(dev);

    - BUG_ON(idx >= priv->echo_skb_max);
    + if (idx >= priv->echo_skb_max) {
    + netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n",
    + __func__, idx, priv->echo_skb_max);
    + return NULL;
    + }

    if (priv->echo_skb[idx]) {
    /* Using "struct canfd_frame::len" for the frame

    \
     
     \ /
      Last update: 2018-11-29 15:55    [W:4.049 / U:0.140 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site