From patchwork Fri Sep 8 14:35:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Ricardo Leitner X-Patchwork-Id: 811638 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="s261Up/S"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xpfy44QgGz9s7G for ; Sat, 9 Sep 2017 00:35:56 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756171AbdIHOfn (ORCPT ); Fri, 8 Sep 2017 10:35:43 -0400 Received: from mail-qk0-f169.google.com ([209.85.220.169]:34586 "EHLO mail-qk0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754978AbdIHOfl (ORCPT ); Fri, 8 Sep 2017 10:35:41 -0400 Received: by mail-qk0-f169.google.com with SMTP id b23so6747538qkg.1; Fri, 08 Sep 2017 07:35:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=l4DF1g2duA/qzOt4AAWpmtCeH6YjuAdZddMGm4mIqI0=; b=s261Up/S6ripfDu3EwMTgol+zAOaCnGXONilZeYWjVnUyqu7Iv78RYlSvS749agB9/ iTbBOjaW92xzJibamI73Ox651lXBpwnOFx5QJMfZI9lobI4qlOzTgjzL9p2qA+qxQjLc SyN5ORn3Wze+iFNOUq3SAoTJQqYSwiSNOvFpK3d3HX+rYmGf9Wh/LxCfZ53xoFOKXHCo 73hwB0Lya7klPuud/kyXWtmz8oMuWUKTUn/ZVGFwq/wRs9zwEWstUPQ0MLsF7U5xq1Tp 3edK6wDKxnBY/6lZNL3vx5fgElqWkTtKyjpwRIJlTHTLS/N09BmR/D3TsC1NVfb66GPs oMJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=l4DF1g2duA/qzOt4AAWpmtCeH6YjuAdZddMGm4mIqI0=; b=pv0ZlInYl7Toh71eFyNDBVDha8B7NWLaCAgqGj44E+ACeNA8+fIXyXeiEcf6fmVddq bKVtPreqTp+lEhWcxcGz7611at9bVL5tb/6NahAGgefVIb0AkTYAnkMwbKkbHHPGjJ8B Tn5LmfQ9CyRZFPRt80yKDNve+WwPOIQfGFbM2pRz1eMXFv5DDxsA3Wzd5zz0hso4lObr kSbD41bRm3ck4ICfTuzioEXlY8blov+9lEceU+3bzUwZC1JCU0bQ8HwEZHgnPnV804Tz +N/Q17ojM97eZOTFBuY+DGYGCmNEvm2OjwTWJsclmB04fhBwyIwtjp1n2DpNKWrAZ3A8 3sTQ== X-Gm-Message-State: AHPjjUjHgnxMjjagu4xf4OZtvH10AuPXNTND7zhWvnWsnd4ay3oau9YF i7glnXdhw7A6J/1O X-Google-Smtp-Source: AOwi7QAxOGXTtXUJSvjD8ZNlwJrnF/H8bVTMIPZBk4b7mC6Tf6OQ8KFm1FtNXxM2cnXmwMHD1CF1dg== X-Received: by 10.55.16.4 with SMTP id a4mr4216445qkh.115.1504881340063; Fri, 08 Sep 2017 07:35:40 -0700 (PDT) Received: from localhost.localdomain.com ([2001:1284:f016:8579:5ee0:c5ff:fe34:bf34]) by smtp.gmail.com with ESMTPSA id 20sm1390722qtr.1.2017.09.08.07.35.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Sep 2017 07:35:39 -0700 (PDT) From: Marcelo Ricardo Leitner To: netdev@vger.kernel.org Cc: linux-sctp@vger.kernel.org, Neil Horman , Vlad Yasevich , Harald Welte Subject: [PATCH net] sctp: fix missing wake ups in some situations Date: Fri, 8 Sep 2017 11:35:21 -0300 Message-Id: <202d7b2e172746c0bed742255bc1583beca45fce.1504880548.git.marcelo.leitner@gmail.com> X-Mailer: git-send-email 2.13.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Commit fb586f25300f ("sctp: delay calls to sk_data_ready() as much as possible") minimized the number of wake ups that are triggered in case the association receives a packet with multiple data chunks on it and/or when io_events are enabled and then commit 0970f5b36659 ("sctp: signal sk_data_ready earlier on data chunks reception") moved the wake up to as soon as possible. It thus relies on the state machine running later to clean the flag that the event was already generated. The issue is that there are 2 call paths that calls sctp_ulpq_tail_event() outside of the state machine, causing the flag to linger and possibly omitting a needed wake up in the sequence. One of the call paths is when enabling SCTP_SENDER_DRY_EVENTS via setsockopt(SCTP_EVENTS), as noticed by Harald Welte. The other is when partial reliability triggers removal of chunks from the send queue when the application calls sendmsg(). This commit fixes it by not setting the flag in case the socket is not owned by the user, as it won't be cleaned later. This works for user-initiated calls and also for rx path processing. Fixes: fb586f25300f ("sctp: delay calls to sk_data_ready() as much as possible") Reported-by: Harald Welte Signed-off-by: Marcelo Ricardo Leitner --- Hi. Please consider this one for -stable. Thanks net/sctp/ulpqueue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c index 0225d62a869f8deff10565c4625df0a10464ce87..a71be33f3afeb0aaaef174ee082c4c547aab1e2d 100644 --- a/net/sctp/ulpqueue.c +++ b/net/sctp/ulpqueue.c @@ -265,7 +265,8 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *ulpq, struct sctp_ulpevent *event) sctp_ulpq_clear_pd(ulpq); if (queue == &sk->sk_receive_queue && !sp->data_ready_signalled) { - sp->data_ready_signalled = 1; + if (!sock_owned_by_user(sk)) + sp->data_ready_signalled = 1; sk->sk_data_ready(sk); } return 1;