Received: by 10.192.165.148 with SMTP id m20csp814302imm; Fri, 27 Apr 2018 07:58:14 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo08AxCLTtLg+yZQVZVKKCseCGvWIYvhG/hioBNIGZdrUktNEjY45qZcjOt3lzOUiE96o0z X-Received: by 2002:a65:5d51:: with SMTP id e17-v6mr2425990pgt.100.1524841094347; Fri, 27 Apr 2018 07:58:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524841094; cv=none; d=google.com; s=arc-20160816; b=T76k24vkNXJz2CKUiCWjGKumbvZ91dILa0YUsEsfAEwBi4q4SYQ8I3IajRCuayMv2N KXJqfWZZo5oqQrxM5oN7r/xaTA6TEPTMpCMExKB0ZToNGx8Q3Aiebf5W2q9DG2Ww8B1+ laVAhOFAAKsk3FFcjyDP/JO6XLXG1QniS6nr+vOeml65w6cYMg2JcwOVBXNEcCv21QNC pS1OGfGCEzyqN3+vSrgdu6WQI3ZeAoGFbGJxXUX8Wrw73XgEXiJp+QJsAj0Clvjl7Izv txWN9/iRJFxlpp9CBQyZtydx2OHIJ0dC+p9zXobThvlmvim+TMjeVbvFiLiXRbsa/A7p WyAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=M8K88KkXPoGUU/zT+UhvzI1GRUuE4L7X+9w+L8g7j9c=; b=L65I1YKuCq9cxMXzMtgGO69RUqT3aRvuf6pUGlob4RL/0eW5X1PSBV4m/w1fimodi5 W73B1ZzKGMqw5zQ4o7xz2Sxq7L/yXDgwG6qtPjmZgYTMrKbj/kRij2evPbbrE42FLgpl rHQMtpTBDQNXAlCGIQdYqZ3GbUqAxTVVSEuW+NYDdzmmE++I0qWDR/2Gd5OwBSiCcM1E rzFUMs4w03/64oZKp6Bxrm7nXIZ61j/yiq0OZRvGKT+ZU5syVfcaP3Cohuc4E4M+7a2z DO2Ms+vUAnUXP2H+vcQ9+HJ6UAPRrzyDh2mQVqVmSEH7AYHIIb63TwtgrnGfC272W6PA /x7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4-v6si1388594pgf.684.2018.04.27.07.57.59; Fri, 27 Apr 2018 07:58:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934195AbeD0O44 (ORCPT + 99 others); Fri, 27 Apr 2018 10:56:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:52266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934083AbeD0OGO (ORCPT ); Fri, 27 Apr 2018 10:06:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75A7121864; Fri, 27 Apr 2018 14:06:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75A7121864 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+f922284c18ea23a8e457@syzkaller.appspotmail.com, Cong Wang , "David S. Miller" Subject: [PATCH 4.14 14/80] llc: delete timers synchronously in llc_sk_free() Date: Fri, 27 Apr 2018 15:58:07 +0200 Message-Id: <20180427135733.661305773@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135732.928644313@linuxfoundation.org> References: <20180427135732.928644313@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit b905ef9ab90115d001c1658259af4b1c65088779 ] The connection timers of an llc sock could be still flying after we delete them in llc_sk_free(), and even possibly after we free the sock. We could just wait synchronously here in case of troubles. Note, I leave other call paths as they are, since they may not have to wait, at least we can change them to synchronously when needed. Also, move the code to net/llc/llc_conn.c, which is apparently a better place. Reported-by: Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/llc_conn.h | 1 + net/llc/llc_c_ac.c | 9 +-------- net/llc/llc_conn.c | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) --- a/include/net/llc_conn.h +++ b/include/net/llc_conn.h @@ -97,6 +97,7 @@ static __inline__ char llc_backlog_type( struct sock *llc_sk_alloc(struct net *net, int family, gfp_t priority, struct proto *prot, int kern); +void llc_sk_stop_all_timers(struct sock *sk, bool sync); void llc_sk_free(struct sock *sk); void llc_sk_reset(struct sock *sk); --- a/net/llc/llc_c_ac.c +++ b/net/llc/llc_c_ac.c @@ -1096,14 +1096,7 @@ int llc_conn_ac_inc_tx_win_size(struct s int llc_conn_ac_stop_all_timers(struct sock *sk, struct sk_buff *skb) { - struct llc_sock *llc = llc_sk(sk); - - del_timer(&llc->pf_cycle_timer.timer); - del_timer(&llc->ack_timer.timer); - del_timer(&llc->rej_sent_timer.timer); - del_timer(&llc->busy_state_timer.timer); - llc->ack_must_be_send = 0; - llc->ack_pf = 0; + llc_sk_stop_all_timers(sk, false); return 0; } --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c @@ -951,6 +951,26 @@ out: return sk; } +void llc_sk_stop_all_timers(struct sock *sk, bool sync) +{ + struct llc_sock *llc = llc_sk(sk); + + if (sync) { + del_timer_sync(&llc->pf_cycle_timer.timer); + del_timer_sync(&llc->ack_timer.timer); + del_timer_sync(&llc->rej_sent_timer.timer); + del_timer_sync(&llc->busy_state_timer.timer); + } else { + del_timer(&llc->pf_cycle_timer.timer); + del_timer(&llc->ack_timer.timer); + del_timer(&llc->rej_sent_timer.timer); + del_timer(&llc->busy_state_timer.timer); + } + + llc->ack_must_be_send = 0; + llc->ack_pf = 0; +} + /** * llc_sk_free - Frees a LLC socket * @sk - socket to free @@ -963,7 +983,7 @@ void llc_sk_free(struct sock *sk) llc->state = LLC_CONN_OUT_OF_SVC; /* Stop all (possibly) running timers */ - llc_conn_ac_stop_all_timers(sk, NULL); + llc_sk_stop_all_timers(sk, true); #ifdef DEBUG_LLC_CONN_ALLOC printk(KERN_INFO "%s: unackq=%d, txq=%d\n", __func__, skb_queue_len(&llc->pdu_unack_q),