From patchwork Fri Jun 8 16:25:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 163819 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C5182B6EF1 for ; Sat, 9 Jun 2012 02:25:08 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933139Ab2FHQZF (ORCPT ); Fri, 8 Jun 2012 12:25:05 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:34499 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932422Ab2FHQZE (ORCPT ); Fri, 8 Jun 2012 12:25:04 -0400 Received: by eeit10 with SMTP id t10so1220825eei.19 for ; Fri, 08 Jun 2012 09:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=SKi1clU3StzDk0l9+9K5jQ/uKx4+fG4lbGQ1204+wfg=; b=Ps2R3w5QYSz5KdtItHovdj2vqCutgYQDTonyUmNDMTfYvH34hqBoCNe3xppfXuj/cZ v/fll0qyD45cm+ae3H+/kyz0dbWSrVi0zRa5xIidmTp2n18m3vqy16OxSSA8BL1ej/6I MQbtYQrtamZCY5mzNzvGhByTdofSdPInEmMa5BcpQetfP1AlZ+3UMNEzttajrHZaZ/w9 xbtFcuJR4aNUQBOET+9US8IiQcVOnEiRNt0JDgGKcvsjiTZi8vsGTwXgxQ2YLOhqu5jN SLn+86SKLJp8INnEinOdbm1IrWH/8/A8ret0iQWs/GYgQRqWBT4/eyII+stTdCOOQePt AXoA== Received: by 10.14.119.202 with SMTP id n50mr3913448eeh.33.1339172702030; Fri, 08 Jun 2012 09:25:02 -0700 (PDT) Received: from [172.30.42.18] (122.237.66.86.rev.sfr.net. [86.66.237.122]) by mx.google.com with ESMTPS id p41sm23956227eef.5.2012.06.08.09.25.01 (version=SSLv3 cipher=OTHER); Fri, 08 Jun 2012 09:25:01 -0700 (PDT) Subject: [PATCH] l2tp: fix a race in l2tp_ip_sendmsg() From: Eric Dumazet To: David Miller Cc: netdev , James Chapman , Denys Fedoryshchenko Date: Fri, 08 Jun 2012 18:25:00 +0200 Message-ID: <1339172700.6001.128.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet Commit 081b1b1bb27f (l2tp: fix l2tp_ip_sendmsg() route handling) added a race, in case IP route cache is disabled. In this case, we should not do the dst_release(&rt->dst), since it'll free the dst immediately, instead of waiting a RCU grace period. Signed-off-by: Eric Dumazet Cc: James Chapman Cc: Denys Fedoryshchenko --- net/l2tp/l2tp_ip.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c index 70614e7..61d8b75 100644 --- a/net/l2tp/l2tp_ip.c +++ b/net/l2tp/l2tp_ip.c @@ -464,10 +464,12 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m sk->sk_bound_dev_if); if (IS_ERR(rt)) goto no_route; - if (connected) + if (connected) { sk_setup_caps(sk, &rt->dst); - else - dst_release(&rt->dst); /* safe since we hold rcu_read_lock */ + } else { + skb_dst_set(skb, &rt->dst); + goto xmit; + } } /* We dont need to clone dst here, it is guaranteed to not disappear. @@ -475,6 +477,7 @@ static int l2tp_ip_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *m */ skb_dst_set_noref(skb, &rt->dst); +xmit: /* Queue the packet to IP for output */ rc = ip_queue_xmit(skb, &inet->cork.fl); rcu_read_unlock();