From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18715C10F11 for ; Wed, 24 Apr 2019 19:04:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E843320656 for ; Wed, 24 Apr 2019 19:04:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388877AbfDXTER (ORCPT ); Wed, 24 Apr 2019 15:04:17 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:40765 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726168AbfDXTER (ORCPT ); Wed, 24 Apr 2019 15:04:17 -0400 Received: by mail-wr1-f66.google.com with SMTP id h4so26636407wre.7 for ; Wed, 24 Apr 2019 12:04:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=a8OdkG0PQkzW/PTkhx1x9j6vRJf/pm2Jg+tcOjOnNnw=; b=KacknTTiBsA3IV8kY3Qojqbmc125QVZ86ZvAwa999e8EtdrKyPi9YxRCdUVhI4sjL+ maY5aygRkGGCbN8Ej9ArEz9OukKkam3qr+TNufdCxHeZ7F4IvUoSDx6nLCWQzzRa1XUN X2TdipCHgNb8viGrdwekQR4D/v9Adxpr3AHtDSQihqZmGYGpOtSRmi+uli2rly3i1Xdw KlNj6Ij7D6lldGnCgpovWl8PLUQm26QDQ7Mf42cUILoA42MtUGwhk7QwI9VjL3v8HOjn /sNviMjHbO0dilXqauTGlkTSKNhrwCKQLynnbGaJ52QCbcUWc5eSGVgEI4Wm02w1cu9W cQgQ== X-Gm-Message-State: APjAAAUI+uyAsYlePlNZWZ8uyMk9IvHXNNEIxwuPgsfEcQK2Cc6vzNDi MAZh8lZpW4hHGD0abF7Olnz6PA== X-Google-Smtp-Source: APXvYqyv+1JwuJepVcYXn6m387V5AqjhyZpc6v/zPkr//+pJgO/3+P5SKgq5asXA76iGuas8Q+Yu1Q== X-Received: by 2002:a5d:42c5:: with SMTP id t5mr19734678wrr.275.1556132655908; Wed, 24 Apr 2019 12:04:15 -0700 (PDT) Received: from pc-2.home (2a01cb05850ddf00045dd60e6368f84b.ipv6.abo.wanadoo.fr. [2a01:cb05:850d:df00:45d:d60e:6368:f84b]) by smtp.gmail.com with ESMTPSA id 4sm15599627wmg.12.2019.04.24.12.04.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Apr 2019 12:04:15 -0700 (PDT) Date: Wed, 24 Apr 2019 21:04:13 +0200 From: Guillaume Nault To: Eric Dumazet Cc: "David S . Miller" , netdev , Eric Dumazet , James Chapman Subject: Re: [PATCH net] l2tp: use rcu_dereference_sk_user_data() in l2tp_udp_encap_recv() Message-ID: <20190424190413.GC17274@pc-2.home> References: <20190423164326.108651-1-edumazet@google.com> <20190424095809.GA17274@pc-2.home> <20190424182108.GB17274@pc-2.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Apr 24, 2019 at 11:29:25AM -0700, Eric Dumazet wrote: > On Wed, Apr 24, 2019 at 11:21 AM Guillaume Nault wrote: > > > > > And then, we'd need to make sure that ->sk_user_data is in sync with > > the encap_rcv() callback (or whatever actually uses the data pointed > > to). Otherwise a module could treat ->sk_user_data as a struct foo > > pointer while it actually points to a struct bar. > > > > For example, a quick look at net/sunrpc/svcsock.c seems to indicate > > that svc_addsock() would accept any (unconnected) UDP socket and pass > > it to svc_addsock(), which in turn would override ->sk_user_data with > > a struct svc_sock pointer. If the socket was previously set up by L2TP, > > then we'd end up with ->sk_user_data pointing to a svc_sock structure, > > but ->encap_rcv still pointing to l2tp_udp_encap_recv(). That's going > > to give unexpected results when l2tp_udp_encap_recv() will dereference > > ->sk_user_data to access (what it believes to be) its tunnel structure. > > A full audit is needed, and I have started it. If you want to help > just send a patch ;) > > I have looked at this l2tp code only after fixing another issue in > RXRPC, and would have > looked later at SUNRPC. Hum, sorry, I didn't realise that. I'm really interested in the solutions you can come up with.