From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net] strparser: Fix incorrect strp->need_bytes value. Date: Thu, 12 Apr 2018 21:56:02 -0400 (EDT) Message-ID: <20180412.215602.1300513196203204706.davem@davemloft.net> References: <20180411220516.3062277-1-doronrk@fb.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: doronrk@fb.com Return-path: Received: from shards.monkeyblade.net ([184.105.139.130]:60528 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752612AbeDMB4E (ORCPT ); Thu, 12 Apr 2018 21:56:04 -0400 In-Reply-To: <20180411220516.3062277-1-doronrk@fb.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Doron Roberts-Kedes Date: Wed, 11 Apr 2018 15:05:16 -0700 > strp_data_ready resets strp->need_bytes to 0 if strp_peek_len indicates > that the remainder of the message has been received. However, > do_strp_work does not reset strp->need_bytes to 0. If do_strp_work > completes a partial message, the value of strp->need_bytes will continue > to reflect the needed bytes of the previous message, causing > future invocations of strp_data_ready to return early if > strp->need_bytes is less than strp_peek_len. Resetting strp->need_bytes > to 0 in __strp_recv on handing a full message to the upper layer solves > this problem. > > __strp_recv also calculates strp->need_bytes using stm->accum_len before > stm->accum_len has been incremented by cand_len. This can cause > strp->need_bytes to be equal to the full length of the message instead > of the full length minus the accumulated length. This, in turn, causes > strp_data_ready to return early, even when there is sufficient data to > complete the partial message. Incrementing stm->accum_len before using > it to calculate strp->need_bytes solves this problem. > > Found while testing net/tls_sw recv path. > > Fixes: 43a0c6751a322847 ("strparser: Stream parser for messages") > Signed-off-by: Doron Roberts-Kedes Applied and queued up for -stable.