Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3015016pxb; Mon, 18 Oct 2021 06:38:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMQYeikKiY/1MdhimG8U1fizR/ct2vsvQLPqUUSiB2DH0kNZeJ0vCKIJVSLKSSfhSPrSvw X-Received: by 2002:a17:903:246:b0:13f:2ff9:8b93 with SMTP id j6-20020a170903024600b0013f2ff98b93mr27460227plh.54.1634564316480; Mon, 18 Oct 2021 06:38:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564316; cv=none; d=google.com; s=arc-20160816; b=IwL8VCKHrliAazP6HUA1aMv9tQ0cKsfqNgAAsEpqa/P2mpy15/4dLr0/vxI8cOT1zs zR6z4+j3WgnO5gsRwf7HFNlTL05o31B5hM1DGMUiGLcuFRWOBlaH2YAoTsrA4nE/VCUg UScOC0jXWq8i00T9Yc5d1h6u4HTxJMXVnyJOhddkeZHem7wD+opXtmdR4kX3t6aDU51T uTnaOovk5Ga5I/V7bMARbIDleGZCqOaqMkeNoR0px5nOMSubApI2weUv1FV5+1tR6vPV OKtceg/YzJMRNkKrjCcA88xQlC8ODgbeCN43EBS8mSz3Ig7jwT9g/0wFcKD4I1ks1pBW KzbQ== 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=PutTMpaozcMzoYwZHzC7PY2BorhMeQTI2zIAFcRGQTQ=; b=KUhqVpVeEf8O5DideCWQLKsTegQF+eIRqQs8m/u5OPiBG6rbfpZSwTPY2Y2UwufI3j Pfds2KO2EnjwpSvToGG/2VV/MAfLPWXQLfb6G/MFe9Ncq2P9ZnH0kbMGSwTvCed3/z5y Ub+tvhhd0zBLjnoKbgK2xYa65dXzs+JoeKLHMt3gzIxCnHKqLoK6T+g3TLD3Oqo9+ozG /b4lZJZihfNCEHJb96iOUvitg3L2hdcv+9XmrDSWYFU7UP08CqFi+HshFYP90bv0pB33 VjMDtuy0SbQz2SsQSxaJTfd7Exwvz2kN5JkQFxsjt+U0n+h8NfhDIZ+u/u2ONvJKkJ6l XXTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XDiETysm; 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 p15si1149876plw.13.2021.10.18.06.38.24; Mon, 18 Oct 2021 06:38:36 -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=XDiETysm; 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 S231946AbhJRNjU (ORCPT + 99 others); Mon, 18 Oct 2021 09:39:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:52856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbhJRNgd (ORCPT ); Mon, 18 Oct 2021 09:36:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3AFC7613D0; Mon, 18 Oct 2021 13:31:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563869; bh=q5fAp+YBYcdhwPHFstIh6HhVzWBCWxw8a5w7Nw9s8KM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XDiETysmSZndvtfoIlA0XlGGe8u4LC3FpinfgxyYYCi8A503iqeGgvafXhoZPOCfY +SbRt2l7M5omy+o/aVDodM5g1suI4GhMkNLA6PsEQ88MVjvT9ZZVILN/tZDqhg2i16 XBhMqbHN/DoQVqk5XXC810D/FNJQrDpcPItC+1LM= 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.4 45/69] sctp: account stream padding length for reconf chunk Date: Mon, 18 Oct 2021 15:24:43 +0200 Message-Id: <20211018132330.967646307@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@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 @@ -3659,7 +3659,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;