Received: by 10.192.165.148 with SMTP id m20csp849097imm; Fri, 27 Apr 2018 08:28:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp5q5o3aWLFfrsk5WidGI7Phr+qIiSlG35ua7Pwy1Ew9JOMe5AberM5JMz8wq0AG8FkiYdz X-Received: by 10.98.72.209 with SMTP id q78mr2634498pfi.70.1524842921857; Fri, 27 Apr 2018 08:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524842921; cv=none; d=google.com; s=arc-20160816; b=eN7LrRKWH5FicDemDmFk45oHWLR36GzWnkink/DjDa03h9HLEaklzQE4gD2uCM67b2 XxfW1HQ2PkWehDCEkasAXUMiilRlytUBq4LQbX6xb/0D9331NjnokgW5umrperSGAW9h lXlHEbpg4tGNKn7ADqq4IFjbQD8U0HUN0FJ2gskmjC3axXg27htA7qaEP+Hj01iM1W9B 6Tx05VVwngMIyo6ZGHpWPKP4K+e03SUFjD6OB9GF7yzXpxweSMcUiu+V8O7TaCc0IByD ZqpkRBtoMWVxAQKapIJWU0Y766/p7l/w4tIrdFGtQxL8sYYFNbefkfssVQL0+nvLcAJ8 bktQ== 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=npBbk0XxG5Ew3r67A1M4MULoRrjzOG7U/P6M9auACxc=; b=itGV7Gniu46hL8lYP9/rm+h8jtk+EvEaj1sPV0v2Ris610dQM8NO7u93Ai1ALp1eld crvRD7EAxX797OPzNk2h60nv6GrkknZ9BGTLCGObPi2dHMqAyQuRdlwgK/dUIn5+OGAG yEVskn7fcfQMXzbC3B/f1B3wBRLHhbHcaYizfP3Wyn8AC+lBgD1iSY+PteRxk0PU5vZL ANJlcFW302WNy02+NpqZ6orIopv06vmERVLsi+hRSARPOkMNZeExPFei4xDspHcAfLjN HBAM/dtMMTrrUWys3qO0Ixx/4vnFF8roGbckzuFKn7Oo7bRF24CqPnHsuQiV/zJ+VlYf iRIw== 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 y14-v6si1426996pgo.286.2018.04.27.08.28.27; Fri, 27 Apr 2018 08:28:41 -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 S933195AbeD0OBm (ORCPT + 99 others); Fri, 27 Apr 2018 10:01:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:48550 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933171AbeD0OBi (ORCPT ); Fri, 27 Apr 2018 10:01:38 -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 E99982185A; Fri, 27 Apr 2018 14:01:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E99982185A 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.4 32/50] llc: delete timers synchronously in llc_sk_free() Date: Fri, 27 Apr 2018 15:58:34 +0200 Message-Id: <20180427135657.584983982@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135655.623669681@linuxfoundation.org> References: <20180427135655.623669681@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.4-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),