Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3032339pxb; Mon, 18 Oct 2021 07:00:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxS2DUqdVOfuEFKZpXi+ETaSLj/l9nw6OumkOjcIMGRuxtazW5BVnDVF2xXiFVHQ8cHavbz X-Received: by 2002:aa7:df83:: with SMTP id b3mr44225007edy.294.1634565600942; Mon, 18 Oct 2021 07:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634565600; cv=none; d=google.com; s=arc-20160816; b=BByASrANH4K3gxZWWmul4DfsAhUzuh9Z72zO49nAJQ767Nkityaawz66bxGuOFrtRM vRPgPh4uuejAfGQz4zOjYHIehdSWPG6XeKas/G8RcE8aEJ9NulQQwOhTPPZYkCIhKktT 90YuZvvwawtnLncARN5/K0Q2CM/Pl7FcCvrXmXZMnMQp56tSkPtnkFH7aO/LPM72yFYg opSCEdj4DOGlHU1MVVgfM/+QLjVKYDwaRDorwmZXV8x2IXEIehdWrLQImLp6gar3KMJM vEbeUxYwEusIktKgyjMR+38eBSsrQtVAbcisisP6SDDDDM6+IejaBPsc69MW2/kVBnZ/ IG7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hArPnmd24R3cmNMFmryO1t1Ft1NUUn0oYPaiohoz4ZM=; b=hxlbC413KfebYh7Ej5SIw1fozBxK0foMdGhu3cm+ZYMAYpIyvwn2T3MMl5V0YtVnkJ HLBQQ2Ei6FrKD7xcvTXqH/RBjXO8Irerpk+CQBSFdhzs9QEb/LtBYcoZ/EdO4MjcMiD/ D9dB9vjt+He3cfHzhDD+NUAE/lML4K8dia6JWRr1QlnVwyIas7RtIi9UvUG0XgpRl1gh 9rtDnNJGJnPR2NprIRT6W0xZAlBhSSWjNBvE6c/UlgJlZR7TiRxxd8KTV3r5q4wCI2HU bPSSpa87s8vIKCCtClUs8mo9tMXgrkXK4fwrPZxtTkrG64fd+G8np8YMH/48bGNjlIxH +9uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ctVe21xT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si19523168edv.608.2021.10.18.06.59.37; Mon, 18 Oct 2021 07:00:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ctVe21xT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234173AbhJRN75 (ORCPT + 99 others); Mon, 18 Oct 2021 09:59:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:58168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234281AbhJRN5v (ORCPT ); Mon, 18 Oct 2021 09:57:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D33161A10; Mon, 18 Oct 2021 13:41:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634564465; bh=LRP1vHEPOxp/oJ9HHffPTa8Qfw/xtFrf5LnyU+x4GwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ctVe21xTND1YqVRTMd8MmcH5sqfWI/ATRrI567fynb4HDki0weO44fl/yfQPpqZ3j ixajHZG+46Lvx6pckeVXStSrp9q0DIBEV7I/EJmRUhlBKt+Xmavq8AxY2bTXuV7yCX 6NM87JZBncBMhTCdgTwsURLDdgNdlJkZA+ej/6KU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vlad Yasevich , Neil Horman , Eiichi Tsukata , Marcelo Ricardo Leitner , Marcelo Ricardo Leitner , Xin Long , Jakub Kicinski Subject: [PATCH 5.14 098/151] sctp: account stream padding length for reconf chunk Date: Mon, 18 Oct 2021 15:24:37 +0200 Message-Id: <20211018132343.855413392@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132340.682786018@linuxfoundation.org> References: <20211018132340.682786018@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eiichi Tsukata commit a2d859e3fc97e79d907761550dbc03ff1b36479c upstream. sctp_make_strreset_req() makes repeated calls to sctp_addto_chunk() which will automatically account for padding on each call. inreq and outreq are already 4 bytes aligned, but the payload is not and doing SCTP_PAD4(a + b) (which _sctp_make_chunk() did implicitly here) is different from SCTP_PAD4(a) + SCTP_PAD4(b) and not enough. It led to possible attempt to use more buffer than it was allocated and triggered a BUG_ON. Cc: Vlad Yasevich Cc: Neil Horman Cc: Greg KH Fixes: cc16f00f6529 ("sctp: add support for generating stream reconf ssn reset request chunk") Reported-by: Eiichi Tsukata Signed-off-by: Eiichi Tsukata Signed-off-by: Marcelo Ricardo Leitner Signed-off-by: Marcelo Ricardo Leitner Reviewed-by: Xin Long Link: https://lore.kernel.org/r/b97c1f8b0c7ff79ac4ed206fc2c49d3612e0850c.1634156849.git.mleitner@redhat.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sctp/sm_make_chunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -3697,7 +3697,7 @@ struct sctp_chunk *sctp_make_strreset_re outlen = (sizeof(outreq) + stream_len) * out; inlen = (sizeof(inreq) + stream_len) * in; - retval = sctp_make_reconf(asoc, outlen + inlen); + retval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen)); if (!retval) return NULL;