Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp6479lqc; Thu, 29 Feb 2024 08:49:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXWVI58tWMMpB8I09m5mf4wg2hv+DFBuFUh3zoooOPpYlnvXNCubo2DBBpvDUFddF2k2xbV9FOAxjHSZX0bTLPpRKNt4jXdgOrPoE4Kdw== X-Google-Smtp-Source: AGHT+IGWSECbk49JrvCA0uz/eZHZtrrSrrZbNkd6d+9KDhblrDnxFep3qOtBg0lRxNney0zkBjoX X-Received: by 2002:a05:6830:1d85:b0:6e4:7b7e:72bc with SMTP id y5-20020a0568301d8500b006e47b7e72bcmr2364637oti.35.1709225399705; Thu, 29 Feb 2024 08:49:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709225399; cv=pass; d=google.com; s=arc-20160816; b=mUKSrOY7rtSXlXYdqzcHF+EhIul89OekeHw5dzpkNsaTQ6iB2HX5jZaNdc1LIcZ1yK HEfjKAAuQQReaF/wlkx75zO9Nsb9fI1wxs2IO3ag/L+oz+z7WTJSA9469H1n7vYGiK3L ejbBjgfKot8LwmOgIC2JfKr0JWTULKey1fxNdKl337Pc8qi0wkqeG3Wnhm598iQijUnM l8vLAW1AD5NDLVXwz4852YNilr5OBhPIUqKAaxr4/uRwRPv1eV0OGULcYvRWFz0enGon r0AUO14ISP8bIIz5kE+oOx89yFWOJCQFFVMK1oHMnIZmVt4COpGYS/PQyeGd9oTdfhci yaZQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date; bh=T6Pkmz5R7hYW0WURpnNhHSOKLtI5lLd/4I/7Y6tCDMs=; fh=0epQymrKNs1TbRJMJOaNoTaK9X++x6GQdu4KQCDokOI=; b=CE/IrZ6PNDPMZocizYF+kfDBmXTxebU0GxOMsNt7HqRCydSzH3/s6WrNiBXYSLk/Hu ey6AY1y5j0oB1zRxK5DF7+53GWuAP0/0F6F/4YNfU0wUKPcnEYdyMHMjw5xKjHInCDYy g9TmpQCLu1VMuzuzD75ZGRPZUujho7FW0MSYEY7l0VB1To11MtR3rsVCl/LybWHULWqO acZyKGFNPQuaxQM7kvvXJ6gJwX+2itrs4VMavIvGov3vJTOtUNtpqICl3aieFNVTEhJu wW23a4ZFdS2DTm8rp+WDw3InOAoA9ztdKEyhIlJClTGvhLcUsLcZZNHr0l3cu8X2YTxs IHyg==; 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-87057-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87057-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x1-20020a654141000000b005dc422f0808si1721595pgp.637.2024.02.29.08.49.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 08:49:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87057-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gnumonks.org); spf=pass (google.com: domain of linux-kernel+bounces-87057-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87057-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 022E9B26367 for ; Thu, 29 Feb 2024 16:22:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 545BA14BF29; Thu, 29 Feb 2024 16:11:02 +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 1ACDD144059; Thu, 29 Feb 2024 16:10:55 +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=1709223061; cv=none; b=s9d2TcGw3XOuqgPfTiC7F1A0kTNQE+YN0Gg+cmvg78kRN1YJWVj/3z9MoOraiFha/Wa+/xhTdAxbNLJ2ZZZWJyJi9RnmTA2ktLrcGt+WUdNyhiy6dihJ6R48ha6WODxPhmd5D2pAnowU95YNomBHsQjZSSvJ86jN2nO0hRZoEE4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709223061; c=relaxed/simple; bh=X99fyzIl3BzdVUyIVfrX2sEXZjIkx/BM0jeCNyNhsHk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hAtGMUj9kYXk+m95AkVs7B95gWOAFS4CT/cBgVMPQdoiVYk3E1quP20TyONjVLybn3pHsv8E1NwVQqGZlDVEN9ZPQeV0BFAkRHpqdXjnxiXoLqfwbDrnXkzoxp+MIJCXFu1rbRDQrUD3ikIyCrF/BW0XNu5fbzlVg3oIJ8yI9ok= 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=35722 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 1rfizf-0066XT-HB; Thu, 29 Feb 2024 17:10:49 +0100 Date: Thu, 29 Feb 2024 17:10:46 +0100 From: Pablo Neira Ayuso To: Vasiliy Kovalev Cc: Alexander Ofitserov , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, edumazet@google.com, laforge@gnumonks.org, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, 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> <3d8314ae-03d9-6e43-86ad-f830ea01c737@basealt.ru> 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 Content-Transfer-Encoding: 8bit In-Reply-To: <3d8314ae-03d9-6e43-86ad-f830ea01c737@basealt.ru> X-Spam-Score: -1.8 (-) On Thu, Feb 29, 2024 at 11:37:28AM +0300, Vasiliy Kovalev wrote: [...] > This patch fixes another problem, but a similar one, since the sequence is > incorrect when registering subsystems. > > Initially, the registration sequence in the gtp module was as follows: > > 1) rtnl_link_register(); > > 2) genl_register_family(); > > 3) register_pernet_subsys(); > > During debugging of the module, when starting the syzkaller reproducer, it > turned out that after genl_register_family() (2), > > without waiting for register_pernet_subsys()(3), the /.dumpit/  event is > triggered, in which the data of the unregistered pernet subsystem is > accessed. > > That is, the bug was fixed by the commit > > 136cfaca2256 ("gtp: fix use-after-free and null-ptr-deref in gtp_genl_dump_pdp()")[1] > > and the registration sequence became as follows: > > 1) rtnl_link_register(); > > 2) register_pernet_subsys(); > > 3) genl_register_family(); > > However, syzkaller has discovered another problem: > > after registering rtnl_link_register, the .newlink event is triggered, in > which the data of the unregistered pernet subsystem is accessed. > > This problem is reproducible on current stable kernels and the latest > upstream kernel 6.8-rc6, in which the patch 136cfaca2256 [1] is applied. > > Therefore, the correct sequence should be as follows: > > 1)register_pernet_subsys(); > > 2) rtnl_link_register(); > > 3) genl_register_family(); > > The proposed patch is developed on top of the commit changes [1], does not > conflict with it and fixes the described bug. > > [1] https://lore.kernel.org/lkml/20240220160434.29bcaf43@kernel.org/T/#mb1f72c2ad57b7ea6d47333e8616beccf8bce0e23 Thanks for explaining, fix LGTM.