{"id":817512,"url":"http://patchwork.ozlabs.org/api/patches/817512/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/44b0d835c98aebc1896b4806bd9b74a9793856f2.1506086081.git.g.nault@alphalink.fr/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<44b0d835c98aebc1896b4806bd9b74a9793856f2.1506086081.git.g.nault@alphalink.fr>","list_archive_url":null,"date":"2017-09-22T13:39:23","name":"[net,1/2] l2tp: ensure sessions are freed after their PPPOL2TP socket","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"66a5056a92e776c1400eef2ef5ebd6aff373f21e","submitter":{"id":22975,"url":"http://patchwork.ozlabs.org/api/people/22975/?format=json","name":"Guillaume Nault","email":"g.nault@alphalink.fr"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/44b0d835c98aebc1896b4806bd9b74a9793856f2.1506086081.git.g.nault@alphalink.fr/mbox/","series":[{"id":4627,"url":"http://patchwork.ozlabs.org/api/series/4627/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4627","date":"2017-09-22T13:39:22","name":"l2tp: fix some races in session deletion","version":1,"mbox":"http://patchwork.ozlabs.org/series/4627/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/817512/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/817512/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xzF2d0JH2z9sPk\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri, 22 Sep 2017 23:39:37 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752380AbdIVNjf (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 22 Sep 2017 09:39:35 -0400","from zimbra.alphalink.fr ([217.15.80.77]:52467 \"EHLO\n\tzimbra.alphalink.fr\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1752337AbdIVNjc (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 22 Sep 2017 09:39:32 -0400","from localhost (localhost [127.0.0.1])\n\tby mail-2-cbv2.admin.alphalink.fr (Postfix) with ESMTP id\n\t602722B520B3; Fri, 22 Sep 2017 15:39:31 +0200 (CEST)","from zimbra.alphalink.fr ([127.0.0.1])\n\tby localhost (mail-2-cbv2.admin.alphalink.fr [127.0.0.1])\n\t(amavisd-new, port 10032)\n\twith ESMTP id WjqyBhcvOUuR; Fri, 22 Sep 2017 15:39:24 +0200 (CEST)","from localhost (localhost [127.0.0.1])\n\tby mail-2-cbv2.admin.alphalink.fr (Postfix) with ESMTP id\n\tDCDF22B5206F; Fri, 22 Sep 2017 15:39:23 +0200 (CEST)","from zimbra.alphalink.fr ([127.0.0.1])\n\tby localhost (mail-2-cbv2.admin.alphalink.fr [127.0.0.1])\n\t(amavisd-new, port 10026)\n\twith ESMTP id hxnvUpjnNJFA; Fri, 22 Sep 2017 15:39:23 +0200 (CEST)","from c-dev-0.admin.alphalink.fr (94-84-15-217.reverse.alphalink.fr\n\t[217.15.84.94])\n\tby mail-2-cbv2.admin.alphalink.fr (Postfix) with ESMTP id\n\tB42222B52057; Fri, 22 Sep 2017 15:39:23 +0200 (CEST)","by c-dev-0.admin.alphalink.fr (Postfix, from userid 1000)\n\tid 9659160179; Fri, 22 Sep 2017 15:39:23 +0200 (CEST)"],"X-Virus-Scanned":"amavisd-new at mail-2-cbv2.admin.alphalink.fr","Date":"Fri, 22 Sep 2017 15:39:23 +0200","From":"Guillaume Nault <g.nault@alphalink.fr>","To":"netdev@vger.kernel.org","Cc":"James Chapman <jchapman@katalix.com>, Tom Parkin <tparkin@katalix.com>,\n\tSabrina Dubroca <sd@queasysnail.net>","Subject":"[PATCH net 1/2] l2tp: ensure sessions are freed after their PPPOL2TP\n\tsocket","Message-ID":"<44b0d835c98aebc1896b4806bd9b74a9793856f2.1506086081.git.g.nault@alphalink.fr>","References":"<cover.1506086081.git.g.nault@alphalink.fr>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<cover.1506086081.git.g.nault@alphalink.fr>","X-Mutt-Fcc":"=Sent","User-Agent":"NeoMutt/20170609 (1.8.3)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"If l2tp_tunnel_delete() or l2tp_tunnel_closeall() deletes a session\nright after pppol2tp_release() orphaned its socket, then the 'sock'\nvariable of the pppol2tp_session_close() callback is NULL. Yet the\nsession is still used by pppol2tp_release().\n\nTherefore we need to take an extra reference in any case, to prevent\nl2tp_tunnel_delete() or l2tp_tunnel_closeall() from freeing the session.\n\nSince the pppol2tp_session_close() callback is only set if the session\nis associated to a PPPOL2TP socket and that both l2tp_tunnel_delete()\nand l2tp_tunnel_closeall() hold the PPPOL2TP socket before calling\npppol2tp_session_close(), we're sure that pppol2tp_session_close() and\npppol2tp_session_destruct() are paired and called in the right order.\nSo the reference taken by the former will be released by the later.\n\nSigned-off-by: Guillaume Nault <g.nault@alphalink.fr>\n---\n net/l2tp/l2tp_ppp.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)","diff":"diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c\nindex 50e3ee9a9d61..bc6e8bfc5be4 100644\n--- a/net/l2tp/l2tp_ppp.c\n+++ b/net/l2tp/l2tp_ppp.c\n@@ -437,11 +437,11 @@ static void pppol2tp_session_close(struct l2tp_session *session)\n \n \tBUG_ON(session->magic != L2TP_SESSION_MAGIC);\n \n-\tif (sock) {\n+\tif (sock)\n \t\tinet_shutdown(sock, SEND_SHUTDOWN);\n-\t\t/* Don't let the session go away before our socket does */\n-\t\tl2tp_session_inc_refcount(session);\n-\t}\n+\n+\t/* Don't let the session go away before our socket does */\n+\tl2tp_session_inc_refcount(session);\n }\n \n /* Really kill the session socket. (Called from sock_put() if\n","prefixes":["net","1/2"]}