Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3010231pxb; Mon, 18 Oct 2021 06:32:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAp5cnjdc5G/nLBajJFeEzD39JL9Z958wM4moE+/fw+K/DiDOSQG5vRG7wqV9G0cXjiZho X-Received: by 2002:a17:90a:11:: with SMTP id 17mr33064302pja.238.1634563975985; Mon, 18 Oct 2021 06:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634563975; cv=none; d=google.com; s=arc-20160816; b=y1wh5yf8BDZ/JjPb14uqvE1NV1qrJmLjnMSAKZCM4XLM2uXAUUz/xQpScxDmvEYa+B xyKW0RgLfjp0oFHFEqDK0803Sc8RG8abg42ESVTD38c5cIfFSs7LbzSEwAXqCGQbAv84 5RxrXFqV34odOIJzmUjTRxsExJFwb06dz5ZBdWNFpKeJStCb6/OJEazSU+2S3VOqwJdQ at1TbA1R81IiMMFw9ITBkMKuWAJExIYKqo2OEq2eTauSzgAS+oyBehSi/H3tCeLqvSYr idPWG4KhBpusK4FqFBc7xASneCY+nZQhXOjzFxkbbLw19Y22Ziz0n33NzdYGAe8fEWWg a49g== 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=7syqYZGiO2pJNL37Iedyi+36UFFIV4AkIe9xE/R1Y7U=; b=Bg1pZ0xfnUzKu2g//PF3GBchZbMiQ+Tc0LxUTWn9JVVq4efDHCXZ8SdbL/eJyUnJIL gU03dNTuf/wmoDPrFcwUyPOy5OqIkGvUR827aGMj8yiijz3O0gVUnvMympIyh28S7I8O HGku/BKzlAblO3koikphDRhNsNh2b8RyFKN6/p2kpC0k/D0PdjF0oTCV7Be70c3asJBz M7eH0FrdUZds6HHvd9lJoH7+RQtyJO8Q6lcYyG2zWwA1dIlez0gjM/Q284rc7lABiT0F h33c30QAGuMAEAk3JpGb6uFUIdTAemFxlUvVkFvcEFEE49YU4oY+nK6mqtxLCdVjtS0C Bn5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DsjQaG7n; 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 m203si21563433pfd.256.2021.10.18.06.32.42; Mon, 18 Oct 2021 06:32:55 -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=DsjQaG7n; 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 S233084AbhJRNco (ORCPT + 99 others); Mon, 18 Oct 2021 09:32:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:41784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232636AbhJRNam (ORCPT ); Mon, 18 Oct 2021 09:30:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9CAB06135E; Mon, 18 Oct 2021 13:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563707; bh=nWPJtnQw4HI9f3ZVSzcIANMyEsM4326AmbLQjkdyVxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DsjQaG7n1SzUEtFdBQPtGs8qLa4r0XohRJ2wIsXWQZAY5pXW+GqY4yEI+ILKY/0wO KCmm4pOAx4uR+iLCox9OInvwzN2B44q6MXaFh4lwhL28B8zM/OTQHSaUv1X3RTCJ3+ DuG1ORqVUMNMrK7tj/SJGrMmnpIx7xxBI0KH7EM8= 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 4.19 33/50] sctp: account stream padding length for reconf chunk Date: Mon, 18 Oct 2021 15:24:40 +0200 Message-Id: <20211018132327.629206662@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132326.529486647@linuxfoundation.org> References: <20211018132326.529486647@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 @@ -3673,7 +3673,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;