From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Corinna Vinschen <vinschen@redhat.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org
Subject: Re: [Intel-wired-lan] [PATCH] igc: fix a log entry using uninitialized netdev
Date: Thu, 25 Apr 2024 11:46:26 -0700 [thread overview]
Message-ID: <87r0etwa9p.fsf@intel.com> (raw)
In-Reply-To: <ZioKlQR9z8RWGFAB@calimero.vinschen.de>
Corinna Vinschen <vinschen@redhat.com> writes:
> On Apr 24 17:06, Vinicius Costa Gomes wrote:
>> Andrew Lunn <andrew@lunn.ch> writes:
>>
>> > On Tue, Apr 23, 2024 at 12:24:54PM +0200, Corinna Vinschen wrote:
>> >> During successful probe, igc logs this:
>> >>
>> >> [ 5.133667] igc 0000:01:00.0 (unnamed net_device) (uninitialized): PHC added
>> >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> >> The reason is that igc_ptp_init() is called very early, even before
>> >> register_netdev() has been called. So the netdev_info() call works
>> >> on a partially uninitialized netdev.
>> >>
>> >> Fix this by calling igc_ptp_init() after register_netdev(), right
>> >> after the media autosense check, just as in igb. Add a comment,
>> >> just as in igb.
>> >
>> > The network stack can start sending and receiving packet before
>> > register_netdev() returns. This is typical of NFS root for example. Is
>> > there anything in igc_ptp_init() which could cause such packet
>> > transfers to explode?
>> >
>>
>> There might be a very narrow window (probably impossible?), what I can
>> see is:
>>
>> 1. the netdevice is exposed to userspace;
>> 2. userspace does the SIOCSHWTSTAMP ioctl() to enable TX timestamps;
>> 3. userspace sends a packet that is going to be timestamped;
>>
>> if this happens before igc_ptp_init() is called, adapter->ptp_tx_lock is
>> going to be uninitialized, and (3) is going to crash.
>
> The same would then be possible on igb as well, wouldn't it?
>
Given how many years igb is being used, perhaps "possible" is too strong
:-)
On igb what exists is slightly different, as there's no ptp_tx_lock
there, the "problem" there is trying to enqueue a job on a workqueue
that is going to be uninitialized, during this time window.
And to be sure, I am still uncertain that this is possible.
>
>> If there's anything that makes this impossible/extremely unlikely, the
>> patch looks good:
>>
>> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>>
>>
>> Cheers,
>> --
>> Vinicius
>
>
> Corinna
>
Cheers,
--
Vinicius
WARNING: multiple messages have this Message-ID (diff)
From: Vinicius Costa Gomes <vinicius.gomes@intel.com>
To: Corinna Vinschen <vinschen@redhat.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org
Subject: Re: [Intel-wired-lan] [PATCH] igc: fix a log entry using uninitialized netdev
Date: Thu, 25 Apr 2024 11:46:26 -0700 [thread overview]
Message-ID: <87r0etwa9p.fsf@intel.com> (raw)
In-Reply-To: <ZioKlQR9z8RWGFAB@calimero.vinschen.de>
Corinna Vinschen <vinschen@redhat.com> writes:
> On Apr 24 17:06, Vinicius Costa Gomes wrote:
>> Andrew Lunn <andrew@lunn.ch> writes:
>>
>> > On Tue, Apr 23, 2024 at 12:24:54PM +0200, Corinna Vinschen wrote:
>> >> During successful probe, igc logs this:
>> >>
>> >> [ 5.133667] igc 0000:01:00.0 (unnamed net_device) (uninitialized): PHC added
>> >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> >> The reason is that igc_ptp_init() is called very early, even before
>> >> register_netdev() has been called. So the netdev_info() call works
>> >> on a partially uninitialized netdev.
>> >>
>> >> Fix this by calling igc_ptp_init() after register_netdev(), right
>> >> after the media autosense check, just as in igb. Add a comment,
>> >> just as in igb.
>> >
>> > The network stack can start sending and receiving packet before
>> > register_netdev() returns. This is typical of NFS root for example. Is
>> > there anything in igc_ptp_init() which could cause such packet
>> > transfers to explode?
>> >
>>
>> There might be a very narrow window (probably impossible?), what I can
>> see is:
>>
>> 1. the netdevice is exposed to userspace;
>> 2. userspace does the SIOCSHWTSTAMP ioctl() to enable TX timestamps;
>> 3. userspace sends a packet that is going to be timestamped;
>>
>> if this happens before igc_ptp_init() is called, adapter->ptp_tx_lock is
>> going to be uninitialized, and (3) is going to crash.
>
> The same would then be possible on igb as well, wouldn't it?
>
Given how many years igb is being used, perhaps "possible" is too strong
:-)
On igb what exists is slightly different, as there's no ptp_tx_lock
there, the "problem" there is trying to enqueue a job on a workqueue
that is going to be uninitialized, during this time window.
And to be sure, I am still uncertain that this is possible.
>
>> If there's anything that makes this impossible/extremely unlikely, the
>> patch looks good:
>>
>> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>>
>>
>> Cheers,
>> --
>> Vinicius
>
>
> Corinna
>
Cheers,
--
Vinicius
next prev parent reply other threads:[~2024-04-25 18:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 10:24 [Intel-wired-lan] [PATCH] igc: fix a log entry using uninitialized netdev Corinna Vinschen
2024-04-23 10:24 ` Corinna Vinschen
2024-04-23 10:49 ` [Intel-wired-lan] " Hariprasad Kelam
2024-04-23 10:49 ` Hariprasad Kelam
2024-04-24 22:34 ` [Intel-wired-lan] " Andrew Lunn
2024-04-24 22:34 ` Andrew Lunn
2024-04-25 0:06 ` [Intel-wired-lan] " Vinicius Costa Gomes
2024-04-25 0:06 ` Vinicius Costa Gomes
2024-04-25 7:47 ` [Intel-wired-lan] " Corinna Vinschen
2024-04-25 7:47 ` Corinna Vinschen
2024-04-25 18:46 ` Vinicius Costa Gomes [this message]
2024-04-25 18:46 ` Vinicius Costa Gomes
2024-05-07 9:00 ` naamax.meir
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r0etwa9p.fsf@intel.com \
--to=vinicius.gomes@intel.com \
--cc=andrew@lunn.ch \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=netdev@vger.kernel.org \
--cc=vinschen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.