Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp575193img; Fri, 22 Mar 2019 04:21:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzy/M3WLoGOP80Xo1cN9TxIggIMVNAQ46ykD7d9BKFitIfR+gAsvHIvJmyjrKK4QDOi22GO X-Received: by 2002:a63:2a8f:: with SMTP id q137mr8312403pgq.31.1553253683711; Fri, 22 Mar 2019 04:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253683; cv=none; d=google.com; s=arc-20160816; b=mnlftjEp8Uk7UL/+BKzAwT+0mRrVFj4AAbFSPqsIgTaQMOyH90byMz3Jr7RzSYHZAb u2yjDUb8HkskKRF2ulHGNGPGQ9XoGDKO5nnECjphzAkX0N4cg1o6XpWS7vZYLfsv3z2h ylpRQJAGISWTzJmHKGYG/mjxpsIovOYKuYzMTvrqe3aMFSSBYFlOq1io0Q+PDlV9MALm RMr0svofbrvt4rnswLLRLVBzedozw0sR5uTrKWeM+bKvL9w78iti4u+qW37Rl0tMGeb0 QrZZxIK9goji532GrGenvxQbmThqhV8XSEdxSIO/YTcpftlbbbq6z4J67pki4CvWvsR6 HnqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1cSlDu+wU5PSUOGT+jLb94lX4BHH88jdoWPn/2mrquw=; b=fhsG6z9ymrcEFFE3u3iPH1O+njkj4vvp0Ho7bx44ddTeJOeD5eFddGb6KblZ9N2Rti 3q0mQBqWOaoxIbH+mrrdTj2pt6XspS7eX0mm+yNEvHN3kQ6SeKpDlbgXGSAKRdAC5ujt y0rMSUFkkzZ4JMI1SULags/JCmTo1Wjt/sRrb0fGAUyuk+i8qQhQSon53rJX2toNUVgn Qv/zaSaq4sWoZwhddqo8y//hUU41k5MG5nrLqA9JLnItccutdVL83XIAsdOCa8CPLfa5 kuRiLjbDfG4wNAFT58eI4Vmj3nGMvsFYeY2kHFxRDizorFOaxoyP61Pu78jHYqkrvPsC JSEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=C5oqlKKd; 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 o1si7236980pld.439.2019.03.22.04.21.08; Fri, 22 Mar 2019 04:21:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=C5oqlKKd; 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 S1728241AbfCVLTw (ORCPT + 99 others); Fri, 22 Mar 2019 07:19:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:46296 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728219AbfCVLTt (ORCPT ); Fri, 22 Mar 2019 07:19:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E096421929; Fri, 22 Mar 2019 11:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253588; bh=hi6mJt25cE86RVv4ESzBNUlLQDjnk49JNou5OvXAdJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C5oqlKKdgNrtTDxs+d05q1Hem8SIdcsxMp2DXoJL1kjJqp0/43/DpP2/jAQNB4k3b 2Cc5+WI5m/h0iRBB6y2T6mk0x2HA28wlIHq/tImdSw1lb1ZuqXRPjThn0KUuanvdxY q2SViWzvVesQwIOIRsuJH35+WTHjhv8pzcWL2IQ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , "David S. Miller" , Sasha Levin Subject: [PATCH 3.18 014/134] isdn: i4l: isdn_tty: Fix some concurrency double-free bugs Date: Fri, 22 Mar 2019 12:13:47 +0100 Message-Id: <20190322111211.099297951@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 2ff33d6637393fe9348357285931811b76e1402f ] The functions isdn_tty_tiocmset() and isdn_tty_set_termios() may be concurrently executed. isdn_tty_tiocmset isdn_tty_modem_hup line 719: kfree(info->dtmf_state); line 721: kfree(info->silence_state); line 723: kfree(info->adpcms); line 725: kfree(info->adpcmr); isdn_tty_set_termios isdn_tty_modem_hup line 719: kfree(info->dtmf_state); line 721: kfree(info->silence_state); line 723: kfree(info->adpcms); line 725: kfree(info->adpcmr); Thus, some concurrency double-free bugs may occur. These possible bugs are found by a static tool written by myself and my manual code review. To fix these possible bugs, the mutex lock "modem_info_mutex" used in isdn_tty_tiocmset() is added in isdn_tty_set_termios(). Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/isdn/i4l/isdn_tty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index bc912611fe097..b166354b80428 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -1459,15 +1459,19 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) { modem_info *info = (modem_info *) tty->driver_data; + mutex_lock(&modem_info_mutex); if (!old_termios) isdn_tty_change_speed(info); else { if (tty->termios.c_cflag == old_termios->c_cflag && tty->termios.c_ispeed == old_termios->c_ispeed && - tty->termios.c_ospeed == old_termios->c_ospeed) + tty->termios.c_ospeed == old_termios->c_ospeed) { + mutex_unlock(&modem_info_mutex); return; + } isdn_tty_change_speed(info); } + mutex_unlock(&modem_info_mutex); } /* -- 2.19.1