From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226CFWq6ijCAFP5sj1qqwaT7pYwWjBRBroWfe06K/ROGidorCuvMVVV+SQnq5MSSm+cBBTr7 ARC-Seal: i=1; a=rsa-sha256; t=1517256986; cv=none; d=google.com; s=arc-20160816; b=hx2BZxLkpdlDLGBC+j83XDEKQGNCY09oYgnNpVeKP15jB2QT4aBoG5QkL8v97CVKZA zJRuZu8my15Vdbj09cRU5xCHXbjL5DjPIyMJaItA2JDMBsdkWTwlDI+/cngMeMYO+WhZ oJNgLugSaKPMFNVMA+dsJfQ0Sxrg/HxTWCpen3Hnhu0l9WTsRK2cP5+Vvu5Q2YvekppI khGIF0GHbIA4sueSQRf7k1Pw2ocdgm0HiTVZz1CM0UEAaw3kjiVBpSzWmjRS/QtFcvzC BxK/f3lANkWIcObX/GyqFaOcsqTsMT0ePHkqSBIZFzANPlvFNeIVfBCRbofIb1ZkP/ZA +B4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=v8YIUdYMY1GHV339pHTvSqEUE7d4uR1GQ5sZs5Dd/bw=; b=ZZ8DvYR27MDraEQbwWass/9ONV5ie18qoB51XvljOp+asrrDWxlW+F8DSBVVRQmT7i go0l8DWE+h19VYLEsaFtQFI/3gUq7NleQ0cSYko4gdpkh3lzW+/EQdymqol1/xpaYhQJ C+EDqRTIjV8FokWHZH05Qq+Zvfeq6FANmMu0gLM1OyTabAmjla+qoOsJzuZhAukgpyMD 45QaQTQ1z8DCGg67eeRtoxg0tSZEucfAKMj7/uvtt/xFNbzyKNivRQOgHpHOPe+CqmOM Kqs+IQHN/qFx1HAuYYPzMnhRTql3/tojS2bsCEuamtqnjoKoqV/8ECWiYWZzDoq3Asxr xmSg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xin Long , Neil Horman , Marcelo Ricardo Leitner , "David S. Miller" Subject: [PATCH 4.14 49/71] sctp: reinit stream if stream outcnt has been change by sinit in sendmsg Date: Mon, 29 Jan 2018 13:57:17 +0100 Message-Id: <20180129123830.641367653@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590959262042426074?= X-GMAIL-MSGID: =?utf-8?q?1590959262042426074?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xin Long [ Upstream commit 625637bf4afa45204bd87e4218645182a919485a ] After introducing sctp_stream structure, sctp uses stream->outcnt as the out stream nums instead of c.sinit_num_ostreams. However when users use sinit in cmsg, it only updates c.sinit_num_ostreams in sctp_sendmsg. At that moment, stream->outcnt is still using previous value. If it's value is not updated, the sinit_num_ostreams of sinit could not really work. This patch is to fix it by updating stream->outcnt and reiniting stream if stream outcnt has been change by sinit in sendmsg. Fixes: a83863174a61 ("sctp: prepare asoc stream for stream reconf") Signed-off-by: Xin Long Acked-by: Neil Horman Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sctp/socket.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -1880,8 +1880,14 @@ static int sctp_sendmsg(struct sock *sk, */ if (sinit) { if (sinit->sinit_num_ostreams) { - asoc->c.sinit_num_ostreams = - sinit->sinit_num_ostreams; + __u16 outcnt = sinit->sinit_num_ostreams; + + asoc->c.sinit_num_ostreams = outcnt; + /* outcnt has been changed, so re-init stream */ + err = sctp_stream_init(&asoc->stream, outcnt, 0, + GFP_KERNEL); + if (err) + goto out_free; } if (sinit->sinit_max_instreams) { asoc->c.sinit_max_instreams =