Received: by 10.192.165.148 with SMTP id m20csp785397imm; Fri, 27 Apr 2018 07:29:50 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqUS6w+nPxiYddlC9qBOkKiN5FQerttaGHwgBtxY0K8R5Vk6P4KhJo21mxRpZaGTX2VI8mY X-Received: by 10.98.204.220 with SMTP id j89mr2474398pfk.182.1524839390077; Fri, 27 Apr 2018 07:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524839390; cv=none; d=google.com; s=arc-20160816; b=qGO4GPcbJ8FeZVi05oz/29cW7ALC8IvbOpb/7ms3BwiKT1xs+5T23c5WPhf+Zn4wa3 y5Cowl4dUnh9NDWWgi905SdPMT3pKyq5sdGeO3y/nSVghWaXCogRK7vDPX90ibpGyITO Ux0FTdIh3Bfc01EokM32p3RLPCRy0vxctQaXcqDxoMKNF+BfKTleCXpYqa3u1qDgi6C8 wkC3/psJ+8pZin4jPRmkx9m9NuWO0k00JW6w9OWV5VpMz//XScWArKoHPcISx/Pu9FWP BvUB5HTQaUo6Zl853eynmEaTiJsJbRpvlIbn2Rt8IZZ3B3b4iwRNg3o9bLP1zGme/RI9 l6eQ== 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=cjimlrrUHEQp0vdg+KuaCBuJWNppzBfRORnyeBuD7xs=; b=z92CIUxE1ZC0csEUZZJdxFQ8t5VX6nWv6nDdktTF3QvPXEeioYX/Ql5Myg9YKrjhHo uDnzbIXCQAMnuFGoK4NVwJCRyeqQAPpnJoBVURi5mngoZRrpARKwIUimmOmn1FNr8edM 0vUvBg3MOh16YIitGAWwHUPAeoCwGBfVYzFvas5zwiQ4l0mlApzypaU/QZEcL2HWBA4R 8yQKZ0B8Z/WOY84beDBCyp9VajxmR8/E1JFiZbGSRtb8B49VydO/Fe+ylkdfaV3vrAq2 /t443/I69OFUSPvFR9Bz2iMmqsH+Dk1kmuBH1/rDLpZDwt0m9e81NR2I2y2piFj3QAgR ePqQ== 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 o63si335873pfg.5.2018.04.27.07.29.36; Fri, 27 Apr 2018 07:29:50 -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 S935115AbeD0O2f (ORCPT + 99 others); Fri, 27 Apr 2018 10:28:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:56098 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934977AbeD0OLO (ORCPT ); Fri, 27 Apr 2018 10:11: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 1E805218BC; Fri, 27 Apr 2018 14:11:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E805218BC 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, Guillaume Nault , "David S. Miller" Subject: [PATCH 4.16 44/81] l2tp: fix {pppol2tp, l2tp_dfs}_seq_stop() in case of seq_file overflow Date: Fri, 27 Apr 2018 15:58:46 +0200 Message-Id: <20180427135745.764668138@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180427135743.216853156@linuxfoundation.org> References: <20180427135743.216853156@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.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guillaume Nault [ Upstream commit 5411b6187adf62909e3b998ac782e722904c7487 ] Commit 0e0c3fee3a59 ("l2tp: hold reference on tunnels printed in pppol2tp proc file") assumed that if pppol2tp_seq_stop() was called with non-NULL private data (the 'v' pointer), then pppol2tp_seq_start() would not be called again. It turns out that this isn't guaranteed, and overflowing the seq_file's buffer in pppol2tp_seq_show() is a way to get into this situation. Therefore, pppol2tp_seq_stop() needs to reset pd->tunnel, so that pppol2tp_seq_start() won't drop a reference again if it gets called. We also have to clear pd->session, because the rest of the code expects a non-NULL tunnel when pd->session is set. The l2tp_debugfs module has the same issue. Fix it in the same way. Fixes: 0e0c3fee3a59 ("l2tp: hold reference on tunnels printed in pppol2tp proc file") Fixes: f726214d9b23 ("l2tp: hold reference on tunnels printed in l2tp/tunnels debugfs file") Signed-off-by: Guillaume Nault Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/l2tp/l2tp_debugfs.c | 5 ++++- net/l2tp/l2tp_ppp.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) --- a/net/l2tp/l2tp_debugfs.c +++ b/net/l2tp/l2tp_debugfs.c @@ -106,8 +106,11 @@ static void l2tp_dfs_seq_stop(struct seq return; /* Drop reference taken by last invocation of l2tp_dfs_next_tunnel() */ - if (pd->tunnel) + if (pd->tunnel) { l2tp_tunnel_dec_refcount(pd->tunnel); + pd->tunnel = NULL; + pd->session = NULL; + } } static void l2tp_dfs_seq_tunnel_show(struct seq_file *m, void *v) --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -1626,8 +1626,11 @@ static void pppol2tp_seq_stop(struct seq return; /* Drop reference taken by last invocation of pppol2tp_next_tunnel() */ - if (pd->tunnel) + if (pd->tunnel) { l2tp_tunnel_dec_refcount(pd->tunnel); + pd->tunnel = NULL; + pd->session = NULL; + } } static void pppol2tp_seq_tunnel_show(struct seq_file *m, void *v)