From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (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 72F7C3F5BC5 for ; Tue, 4 Aug 2026 14:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785853295; cv=none; b=ly2SkjdaBvFBeKR42m8psU7wiP4/CUiHntw94HgJ+IBMGJBoc8fwsUSFPf+YVwGoz9tQgYe97VdQQjklRanb9thR+eQfIFFImkk6HhUbIHgE6KMkuFO2fxXZGJI/jOOpmi5V75pMhz3Lwf9rgUAowg5yI4/R+A/AToFjZ4DSTaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785853295; c=relaxed/simple; bh=OJ/HJEV95zbKoYJ3mdTiTc7gPIW1tf2Lw+OdLjlWXmo=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=VKkEr48K9zEk3Kpu9E+j/v4hMgdxbrtZCb/iHfn3J6n3eQtrbezaRUAlSNYqAHrDBa3iKp3FZYPB/R1vgQBH2B3d6nk1a87LIAE5U3HOmzpaNQcDug/05FAFGnlqpnH53iiofVcxqP4HmLyJRV6E53C6TMBgBJ4qi49aXcx9rqY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Y4pbGpSh; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Y4pbGpSh" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1785853264; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UmaqVfZmEPNNHuq2gS+2tfkTJb121im81Q+j52YT7hY=; b=Y4pbGpShvNJJsLG3uUF0TaJUryc3Q69KXqScBXe1H7/FQtyzBXC9+vG2/rLrQz/JYScNWt SGt777tjofzz2jF4BScIkz/6+AfS7kgxlvlAw/aZ6eCvygsRv6V9MEySiePlQiKzZUCNVz pRloTSNZ13vjQvTru7653lY/B0WfAcA= Date: Tue, 4 Aug 2026 22:20:53 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH net] net: pppoe: check register_netdevice_notifier() error in pppoe_init() X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qingfang Deng To: Minhong He , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Kees Cook , Eric Woudstra , Felix Fietkau , linux-kernel@vger.kernel.org References: <20260803085957.142386-1-heminhong@kylinos.cn> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On 8/4/2026 4:28 PM, Qingfang Deng wrote: > On 2026/8/3 16:59, Minhong He wrote: >> pppoe_init() ignores register_netdevice_notifier() errors and always >> returns success after installing packet handlers, which can leave the >> module loaded without its netdev notifier registered. >> >> Check the error and unwind the packet handlers and protocol registration >> on failure. > > A patch for the net tree requires a Fixes tag. As the notifier has been > present since day 1 of the Linux git repository, you can use: > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > >> Signed-off-by: Minhong He >> --- >>   drivers/net/ppp/pppoe.c | 11 ++++++++++- >>   1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c >> index 4a018acb5262..035795b120e0 100644 >> --- a/drivers/net/ppp/pppoe.c >> +++ b/drivers/net/ppp/pppoe.c >> @@ -1278,10 +1278,19 @@ static int __init pppoe_init(void) >>           dev_add_offload(&pppoe_packet_offload); >>       dev_add_pack(&pppoes_ptype); >>       dev_add_pack(&pppoed_ptype); >> -    register_netdevice_notifier(&pppoe_notifier); >> + >> +    err = register_netdevice_notifier(&pppoe_notifier); >> +    if (err) >> +        goto out_unregister_packs; > > You can move the registration above the dev_add_offload(), so that the > unwind path is cleaner. > AI-review found a use-after-free. To avoid that, this needs to be placed between register_pernet_device() and proto_register(). >>       return 0; >> +out_unregister_packs: >> +    dev_remove_pack(&pppoed_ptype); >> +    dev_remove_pack(&pppoes_ptype); >> +    if (IS_ENABLED(CONFIG_INET)) >> +        dev_remove_offload(&pppoe_packet_offload); >> +    unregister_pppox_proto(PX_PROTO_OE); >>   out_unregister_pppoe_proto: >>       proto_unregister(&pppoe_sk_proto); >>   out_unregister_net_ops: Best regards, Qingfang