Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp159954rbe; Wed, 28 Feb 2024 16:01:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU1I5a+4fks3RvEJeP6QEjnaT/wYttWmSbINSW4X477L+gRrG2dZw93Umgh0EQTf6FFrcHWW6wJ+Ymedzx+yQRpdX0jr+81tY2i70X7EA== X-Google-Smtp-Source: AGHT+IHCWmQY02AcFyFsieSDx+HEpmeho41zt7v6owI1iAqLBd/1ebdY/RE+a8yLPgb0OaPQ4gg/ X-Received: by 2002:a05:6602:4906:b0:7c0:3d0f:b7cf with SMTP id ef6-20020a056602490600b007c03d0fb7cfmr97042iob.8.1709164867321; Wed, 28 Feb 2024 16:01:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709164867; cv=pass; d=google.com; s=arc-20160816; b=vIcOGWfwg45+nhX0p+wImQQ4srO3lG6JoPgOvKGED+qNifTsHhPeLC9RiWwVMSL1FN Q7mp2ejLeN2RYutvpF3yZCk7Q7CpFdOpSXH+vVmoOE5rokTZLAKllJ7CZZ74xe4uF605 d8x5tHT4yj9AhtUxjmUW20nTnJPlbslYll54k+oyMdVY9CCqy7qIX0SxCY9JVoOEUe0P qXUhRzFMbG/Zs8q8qZjzbN1D02K6WD3GjSUpNOTLi34013OPfTtUUJz5SFykysbcNkfe uESOydeMzSC6tZUw7MDarun7sNpTF9IbxNnV6pkB8So014idnkHjSuPUFzJrti+qblF8 iDyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=HWJLrQxCSLmRJTF4m9XifvIyJIjK3fGNYfl9qgNheAQ=; fh=WZjib9HuGTGoWXvMC49MIWCMwwNvy+Ew1Kw1wfBA28U=; b=MyVrPOcnjzVhJl1ao0121GlrINxZEDs/6rNpOd9uYxPRKBI3SmTqKgKF0bK634gNga +qTqEO599YFzXALWO9lOUNOupZd/2dG0j1pofoJbCNdCQLKGhxTe7A5nvVYAHN4jUhD5 CB0OmtBCuoo2C8AXCwzS85PLSgky0/VwovoEJeSWa4HMaxqrpxmerNkWyHV6HcGRXw2Q dEzfYF8VK471tNhlDY6Rvx14oy95bhCitLiiEjgX1eFEdODmYPS4LDkji8RQuDGbzJTw U4M/vHRt8K4PF3tf9R2mQFDugx1qDhMUtBjKvug4kWW1Ud51GjE5lFUIf5RUZ6sqZX+h WC0w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gnumonks.org); spf=pass (google.com: domain of linux-kernel+bounces-85858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85858-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x21-20020a029715000000b004746be3c533si90926jai.60.2024.02.28.16.01.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 16:01:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gnumonks.org); spf=pass (google.com: domain of linux-kernel+bounces-85858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85858-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 38F1E2882B2 for ; Wed, 28 Feb 2024 23:51:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5588476EEC; Wed, 28 Feb 2024 23:51:46 +0000 (UTC) Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [213.95.27.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F66972931; Wed, 28 Feb 2024 23:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.95.27.120 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709164305; cv=none; b=mGHVcB4iTF/k+J1fcv5zxJc0wMZF3GqaDxAlS3V0TJhLsj509cfuKlg+47KBvZLOOylGZLNumPVdiOUpKsiXXKoKr1Tp8ZkckSrv3OEHsjTZn4a0ylcJBOagYbhiOvAjlpkXu8HhISE5z7UW9SRE+SxCjB1qEOa3BV+A8mwDU2Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709164305; c=relaxed/simple; bh=e56CFHFkLiBHp65hwLBvKm7eKWDnSCWhNsYtrm/tC/E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GM40lVpDYF9OLGhpA5nTZHE1ixXfL8eTOJsLok0BWtEH9nVYzzNJ/4zSBxg8WGbjTyYgw76/+kB8A4dUu+0l2jvQr5gaNooY5XFVf3I5Q46YBSnK+BcmDJP5K0qXscdyWfIS36ZW9zJGj0vcEMrkP4h93hJXzeEG/leiWQWHoSo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=gnumonks.org; arc=none smtp.client-ip=213.95.27.120 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gnumonks.org Received: from [78.30.41.52] (port=54716 helo=gnumonks.org) by ganesha.gnumonks.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rfThx-0053eL-7N; Thu, 29 Feb 2024 00:51:31 +0100 Date: Thu, 29 Feb 2024 00:51:28 +0100 From: Pablo Neira Ayuso To: Alexander Ofitserov Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, edumazet@google.com, laforge@gnumonks.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, kovalev@altlinux.org, nickel@altlinux.org, dutyrok@altlinux.org, stable@vger.kernel.org Subject: Re: [PATCH net] gtp: fix use-after-free and null-ptr-deref in gtp_newlink() Message-ID: References: <20240228114703.465107-1-oficerovas@altlinux.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240228114703.465107-1-oficerovas@altlinux.org> X-Spam-Score: -1.9 (-) On Wed, Feb 28, 2024 at 02:47:03PM +0300, Alexander Ofitserov wrote: > The gtp_link_ops operations structure for the subsystem must be > registered after registering the gtp_net_ops pernet operations structure. A fix for this was already applied, see: commit 136cfaca22567a03bbb3bf53a43d8cb5748b80ec Author: Vasiliy Kovalev Date: Wed Feb 14 19:27:33 2024 +0300 gtp: fix use-after-free and null-ptr-deref in gtp_genl_dump_pdp() > diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c > index 2129ae42c7030..0ddec4cc84093 100644 > --- a/drivers/net/gtp.c > +++ b/drivers/net/gtp.c > @@ -1903,26 +1903,26 @@ static int __init gtp_init(void) > > get_random_bytes(>p_h_initval, sizeof(gtp_h_initval)); > > - err = rtnl_link_register(>p_link_ops); > + err = register_pernet_subsys(>p_net_ops); > if (err < 0) > goto error_out; BTW, I like that this calls register_pernet_subsys() before rtnl_link_register(), where a rtnetlink request could come before pernet is set up. > - err = register_pernet_subsys(>p_net_ops); > + err = rtnl_link_register(>p_link_ops); > if (err < 0) > - goto unreg_rtnl_link; > + goto unreg_pernet_subsys; > > err = genl_register_family(>p_genl_family); > if (err < 0) > - goto unreg_pernet_subsys; > + goto unreg_rtnl_link; > > pr_info("GTP module loaded (pdp ctx size %zd bytes)\n", > sizeof(struct pdp_ctx)); > return 0; > > -unreg_pernet_subsys: > - unregister_pernet_subsys(>p_net_ops); > unreg_rtnl_link: > rtnl_link_unregister(>p_link_ops); > +unreg_pernet_subsys: > + unregister_pernet_subsys(>p_net_ops); > error_out: > pr_err("error loading GTP module loaded\n"); > return err; > -- > 2.42.1 > >