From patchwork Mon Jun 26 15:47:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Pundir X-Patchwork-Id: 106351 Delivered-To: patch@linaro.org Received: by 10.140.101.48 with SMTP id t45csp161295qge; Mon, 26 Jun 2017 08:47:41 -0700 (PDT) X-Received: by 10.99.102.7 with SMTP id a7mr769948pgc.216.1498492061830; Mon, 26 Jun 2017 08:47:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498492061; cv=none; d=google.com; s=arc-20160816; b=tUVWd5UQ8j14bLHOXzatVgGaZfz62rBuL11ztlz/8blg+AJxqLGULHU5jvulVEXF1H +QEzBtI5ei2Qn0q+1QwHCAemkBcmqU6nn/WPtWjkJDYKuw4H5MGyz2ZUdkpC6J+svk3Z NdRnkJQkYGSXkTL+pg4EzmlprQai1MuxvjN78VZI0L3AZfoxLvz+tEWN/qI9i0r4HJvF ZmUd/NNbEpAmnuTsoxv0/bBV2A+WCbHjVGWReKZRVFWeIzK6mB7Hb3tJ/b4cgut/Vfh5 wEes1+WSCdNJBLqjsFzloHlLpud7rYSm2Uxhi/ftvYoY/Jxj2saPEpHvPpNlsDfSxYoP RL0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=DRE7E5jJ8OgrHDPMjLL/LtzzvVWUTABeUzZx70jAV0g=; b=d9hxcN5EFCzVToU+J1HFq1Dm4eBUvOv7B8XDZqiOEsTYxrCv1HuPmiVMUSKzniteM3 xMDMuo8hZmWi7cDuu+5Htqtygg3KjhDgGWqPOeINEmGkll5UcRX3OKsx7f5TtMqdSqMO gPlCMRVjz9vCPnrOAzzwVMv7I1N5inOPUhfxm6DNSplsxzzG4PXNqduKtID3fOc77N4T ++qFIM8MmZc+cUb5G3W3KLeiqGtGnAgjHPhUKmeEBp6zWD35eLrGrVYmoSPlokDwjJNf JmRmFlU2DkLsL+Zg5I/z0/qu+YVIMiavTE+GVq30ZvgrkmWV5C6dfKTVOb1gH+bVKIxE roBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=Zw5MhzBi; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 63si282868plf.50.2017.06.26.08.47.41; Mon, 26 Jun 2017 08:47:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@linaro.org header.b=Zw5MhzBi; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751940AbdFZPri (ORCPT + 6 others); Mon, 26 Jun 2017 11:47:38 -0400 Received: from mail-pg0-f44.google.com ([74.125.83.44]:36499 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751460AbdFZPrh (ORCPT ); Mon, 26 Jun 2017 11:47:37 -0400 Received: by mail-pg0-f44.google.com with SMTP id u62so2117004pgb.3 for ; Mon, 26 Jun 2017 08:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DRE7E5jJ8OgrHDPMjLL/LtzzvVWUTABeUzZx70jAV0g=; b=Zw5MhzBiV7wPl7AlzVQJB/dakpRvW6BvIBvmxs9giBvaOGs4KGZp8y7sUzNmeVj7zw nR9fIN1XBNdhxfSKP70oH5WRaY1/Xi7GpsAsQHOsuTuHzUROLGoR9Iy50g8pScwSP1QZ vkJbyukRc5jRhvU2McNAUZkAwzXD7wRhN/swk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DRE7E5jJ8OgrHDPMjLL/LtzzvVWUTABeUzZx70jAV0g=; b=ry/CFuBRd6rfvyFtnpoGexUXFjySoLST3uM3hL378aI0a+0OU8DgHFYk35M3HzOlGc 7uY7DuFU/WK1iayhREsy+6pbZzQFNc9fiyOIITF/uN2hCwM6a0wVUL9X3yERUBcVHxlz 988d/FJtDSiYoVJmK8r81cAPSNjv6I5HvBNftR/3wP+7jiD9rqZ4aTIG+MkzFWHp+3a+ UiZp3KIVBgPH6F6kh3EV0nbU6/XBPK6WPVfdrHMeD73lf/vpCeExhX8GoOCv3hBWk+kO Ipde77SdMpWZrUysJzb3surYsN9o1q1FZf89BAiP4KoKYrZV08CmL3A2Q9lX5CDdo1lT jAdg== X-Gm-Message-State: AKS2vOz4SKsWqWgZ3+WnCR0sDh9nKjlBpOEoIijjG1zoexEv/mqY7Qqf Z29KqrNinmY/SPRL X-Received: by 10.99.122.3 with SMTP id v3mr769296pgc.98.1498492056779; Mon, 26 Jun 2017 08:47:36 -0700 (PDT) Received: from localhost.localdomain ([106.51.139.251]) by smtp.gmail.com with ESMTPSA id s9sm829854pfe.21.2017.06.26.08.47.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Jun 2017 08:47:35 -0700 (PDT) From: Amit Pundir To: Greg KH , Guillaume Nault , "David S . Miller" Cc: Stable Subject: [PATCH for-4.9 4/5] l2tp: hold session while sending creation notifications Date: Mon, 26 Jun 2017 21:17:18 +0530 Message-Id: <1498492039-26905-5-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498492039-26905-1-git-send-email-amit.pundir@linaro.org> References: <1498492039-26905-1-git-send-email-amit.pundir@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Guillaume Nault commit 5e6a9e5a3554a5b3db09cdc22253af1849c65dff upstream. l2tp_session_find() doesn't take any reference on the returned session. Therefore, the session may disappear while sending the notification. Use l2tp_session_get() instead and decrement session's refcount once the notification is sent. Fixes: 33f72e6f0c67 ("l2tp : multicast notification to the registered listeners") Signed-off-by: Guillaume Nault Signed-off-by: David S. Miller Signed-off-by: Amit Pundir --- net/l2tp/l2tp_netlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c index 9f66272b163b..8c0f48350027 100644 --- a/net/l2tp/l2tp_netlink.c +++ b/net/l2tp/l2tp_netlink.c @@ -634,10 +634,12 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf session_id, peer_session_id, &cfg); if (ret >= 0) { - session = l2tp_session_find(net, tunnel, session_id); - if (session) + session = l2tp_session_get(net, tunnel, session_id, false); + if (session) { ret = l2tp_session_notify(&l2tp_nl_family, info, session, L2TP_CMD_SESSION_CREATE); + l2tp_session_dec_refcount(session); + } } out: