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=-8.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 744FDC43381 for ; Thu, 7 Mar 2019 18:25:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 45E2E20661 for ; Thu, 7 Mar 2019 18:25:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YAUhpiTq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726652AbfCGSZK (ORCPT ); Thu, 7 Mar 2019 13:25:10 -0500 Received: from mail-qk1-f196.google.com ([209.85.222.196]:46692 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726625AbfCGSZI (ORCPT ); Thu, 7 Mar 2019 13:25:08 -0500 Received: by mail-qk1-f196.google.com with SMTP id i5so9599777qkd.13; Thu, 07 Mar 2019 10:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=a2EmKvD01ALzoz0/vYYsn+VoDqKpweDigxl+a8suuDQ=; b=YAUhpiTq6usRkbEN8coUr7Ktb7EWfMkM+Gs80SrtvzaRV5H49bzXHwqUD1Z22Gx4uU Rjj9ohe/RdDo+Ji9WCUdjBEiYsmz3G2jtgHGMZ4zxKyjqczo59IPq2C/Iwvdswi2L/M7 OCl/knRm8WPbSFOEjpBMXymYcjz7l3gMGOJEBvj6+AIk0A+emokZpi5S30WwxzaHvHD8 Mphwng8UDNfJZ91LrELYeNawmL6prItCEZkHa9sVqT8nmZgSKlbT95SJ33Bn11VUMG9K KD2Pu9xl0gZ4xtZCYfVCnL//7BN/9T+i6qKVEt8gMdehMOTw9nLpydDo6J2sl3YfOHC9 0x9A== 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=a2EmKvD01ALzoz0/vYYsn+VoDqKpweDigxl+a8suuDQ=; b=uRlOkpWcZKWadgS1JLwyVGTB3t6zNzJPlJIOlGbl93pIOKZXS6CuQY9HcHO3MfjccV FS6oDDP7rKNG4HaZpEeSXsWZSzNiDFkELxfK2huhGai2KZHh3+RjDBzH8gagz5mV9peY kA+NV8L3/qTbhxEhlpnwW0xxQaSLqB5Sn9mY2bNnOvYWOtHOAvTcOcWRBt0snMX46Q6q hmE02AZIHscXmFnYGibNGnhuq31mA5wg1VoFwLsMXlNMzEgW7pY68MmPqz9QDNVdEOwR CwCEMTnzlFdGllU1rFyfYFyP97d/yCzXH4Pre6th9Hi0BHinQ1KTS4fAcIilAnrTJ6l2 yY9A== X-Gm-Message-State: APjAAAWZC6qZ6fvXdRP2VNcpUiJC+ku6ObsFUCyqIFO+UgN/QtaUyHK0 8SvOK6ytsXiDy0Su+x8I5p0= X-Google-Smtp-Source: APXvYqyC14+jgscyWsDpaVIoVkp3P3pJ4yuNZUpa8G25Rxuj7fKfJGiKtkUPNxIWnE9bstVLimRe2A== X-Received: by 2002:a37:4bd2:: with SMTP id y201mr10889605qka.346.1551983106830; Thu, 07 Mar 2019 10:25:06 -0800 (PST) Received: from localhost.localdomain ([2001:1284:f013:3791:2e0d:70cd:9752:703c]) by smtp.gmail.com with ESMTPSA id t1sm3421138qki.65.2019.03.07.10.25.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Mar 2019 10:25:05 -0800 (PST) Received: by localhost.localdomain (Postfix, from userid 1000) id 98448180B7B; Thu, 7 Mar 2019 15:25:03 -0300 (-03) Date: Thu, 7 Mar 2019 15:25:03 -0300 From: Marcelo Ricardo Leitner To: Xin Long Cc: network dev , linux-sctp@vger.kernel.org, davem@davemloft.net, Neil Horman Subject: Re: [PATCH net 1/3] sctp: sctp_sock_migrate() returns error if sctp_bind_addr_dup() fails Message-ID: <20190307182503.GB13515@localhost.localdomain> References: <6837e72485125c8740900fd17fa84ac68b8892a5.1551606805.git.lucien.xin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6837e72485125c8740900fd17fa84ac68b8892a5.1551606805.git.lucien.xin@gmail.com> 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 Sun, Mar 03, 2019 at 05:54:53PM +0800, Xin Long wrote: > It should fail to create the new sk if sctp_bind_addr_dup() fails > when accepting or peeloff an association. > > Signed-off-by: Xin Long > --- > net/sctp/socket.c | 34 ++++++++++++++++++++++++---------- > 1 file changed, 24 insertions(+), 10 deletions(-) > > diff --git a/net/sctp/socket.c b/net/sctp/socket.c > index a2771b3..22adb8d 100644 > --- a/net/sctp/socket.c > +++ b/net/sctp/socket.c > @@ -102,9 +102,9 @@ static int sctp_send_asconf(struct sctp_association *asoc, > struct sctp_chunk *chunk); > static int sctp_do_bind(struct sock *, union sctp_addr *, int); > static int sctp_autobind(struct sock *sk); > -static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, > - struct sctp_association *assoc, > - enum sctp_socket_type type); > +static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk, > + struct sctp_association *assoc, > + enum sctp_socket_type type); > > static unsigned long sctp_memory_pressure; > static atomic_long_t sctp_memory_allocated; > @@ -4655,7 +4655,11 @@ static struct sock *sctp_accept(struct sock *sk, int flags, int *err, bool kern) > /* Populate the fields of the newsk from the oldsk and migrate the > * asoc to the newsk. > */ > - sctp_sock_migrate(sk, newsk, asoc, SCTP_SOCKET_TCP); > + error = sctp_sock_migrate(sk, newsk, asoc, SCTP_SOCKET_TCP); > + if (error) { > + sk_common_release(newsk); > + newsk = NULL; > + } > > out: > release_sock(sk); > @@ -5401,7 +5405,12 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp) > /* Populate the fields of the newsk from the oldsk and migrate the > * asoc to the newsk. > */ > - sctp_sock_migrate(sk, sock->sk, asoc, SCTP_SOCKET_UDP_HIGH_BANDWIDTH); > + err = sctp_sock_migrate(sk, sock->sk, asoc, > + SCTP_SOCKET_UDP_HIGH_BANDWIDTH); > + if (err) { > + sock_release(sock); I'm having a hard time understanding why it needs sock_release() here and sk_common_release() in the above chunk. AFAICT by here (after sctp_sock_migrate call) the sockets are pretty much the same. Mind elaborating please? > + sock = NULL; > + } > > *sockp = sock; >