From: Ding Hui <dinghui@sangfor.com.cn>
To: Simon Horman <simon.horman@corigine.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, intel-wired-lan@lists.osuosl.org,
jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com,
keescook@chromium.org, grzegorzx.szczurek@intel.com,
mateusz.palczewski@intel.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
pengdonglin@sangfor.com.cn, huangcun@sangfor.com.cn
Subject: Re: [RESEND PATCH net 1/2] iavf: Fix use-after-free in free_netdev
Date: Wed, 19 Apr 2023 09:11:37 +0800 [thread overview]
Message-ID: <ff2e0a06-abbb-213a-40ed-20c8e8b2f429@sangfor.com.cn> (raw)
In-Reply-To: <ZD70DKC3+K6gngTh@corigine.com>
On 2023/4/19 3:48, Simon Horman wrote:
> Hi Ding Hui,
>
> On Mon, Apr 17, 2023 at 03:40:15PM +0800, Ding Hui wrote:
>> We do netif_napi_add() for all allocated q_vectors[], but potentially
>> do netif_napi_del() for part of them, then kfree q_vectors and lefted
>
> nit: lefted -> leave
>
Thanks, I'll update in v2.
>> invalid pointers at dev->napi_list.
>>
>> If num_active_queues is changed to less than allocated q_vectors[] by
>> unexpected, when iavf_remove, we might see UAF in free_netdev like this:
>>
...
>>
>> Fix it by letting netif_napi_del() match to netif_napi_add().
>>
>> Signed-off-by: Ding Hui <dinghui@sangfor.com.cn>
>> Cc: Donglin Peng <pengdonglin@sangfor.com.cn>
>> CC: Huang Cun <huangcun@sangfor.com.cn>
>
> as this is a fix it probably should have a fixes tag.
> I wonder if it should be:
>
> Fixes: cc0529271f23 ("i40evf: don't use more queues than CPUs")
I don't think so.
I searched the git log, and found that the mismatched usage was
introduced since the beginning of i40evf_main.c, so I'll add
Fixes: 5eae00c57f5e ("i40evf: main driver core")
in v2.
>
> Code change looks good to me.
>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
>
Thanks.
And sorry for you confusion since my RESEND.
>> ---
>> drivers/net/ethernet/intel/iavf/iavf_main.c | 6 +-----
>> 1 file changed, 1 insertion(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
>> index 095201e83c9d..a57e3425f960 100644
>> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
>> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
>> @@ -1849,19 +1849,15 @@ static int iavf_alloc_q_vectors(struct iavf_adapter *adapter)
>> static void iavf_free_q_vectors(struct iavf_adapter *adapter)
>> {
>> int q_idx, num_q_vectors;
>> - int napi_vectors;
>>
>> if (!adapter->q_vectors)
>> return;
>>
>> num_q_vectors = adapter->num_msix_vectors - NONQ_VECS;
>> - napi_vectors = adapter->num_active_queues;
>>
>> for (q_idx = 0; q_idx < num_q_vectors; q_idx++) {
>> struct iavf_q_vector *q_vector = &adapter->q_vectors[q_idx];
>> -
>> - if (q_idx < napi_vectors)
>> - netif_napi_del(&q_vector->napi);
>> + netif_napi_del(&q_vector->napi);
>> }
>> kfree(adapter->q_vectors);
>> adapter->q_vectors = NULL;
>> --
>> 2.17.1
>>
>
--
Thanks,
- Ding Hui
next prev parent reply other threads:[~2023-04-19 1:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 7:40 [RESEND PATCH net 0/2] iavf: Fix issues when setting channels concurrency with removing Ding Hui
2023-04-17 7:40 ` [RESEND PATCH net 1/2] iavf: Fix use-after-free in free_netdev Ding Hui
2023-04-18 19:48 ` Simon Horman
2023-04-18 19:50 ` Simon Horman
2023-04-18 19:52 ` Simon Horman
2023-04-19 1:11 ` Ding Hui [this message]
2023-04-19 5:50 ` Simon Horman
2023-04-17 7:40 ` [RESEND PATCH net 2/2] iavf: Fix out-of-bounds when setting channels on remove Ding Hui
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=ff2e0a06-abbb-213a-40ed-20c8e8b2f429@sangfor.com.cn \
--to=dinghui@sangfor.com.cn \
--cc=anthony.l.nguyen@intel.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=grzegorzx.szczurek@intel.com \
--cc=huangcun@sangfor.com.cn \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jesse.brandeburg@intel.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mateusz.palczewski@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pengdonglin@sangfor.com.cn \
--cc=simon.horman@corigine.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®