From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A265434F275 for ; Wed, 21 Jan 2026 19:47:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769024856; cv=none; b=SOVlviDGVXTwexEB3oy2evA2J6PAF+iHLqd6t94Et6LXq24CFoLT51vCWNh/es+qDlkvem628iNbnRTal7/WyayI4kXdvXeLGTvHD1scTxd2sZqMjjbEGLqJrc2cY20PZ1pbshwU2CKWb/poa3V/KJMiaYmsOhQJ0SvVAvnyKWs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769024856; c=relaxed/simple; bh=orzjDnZyozRaJvwCpqJ+jtvJM5mx9ik0LsEMc44wRrE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sSaIlw/rcYOCXGW9J3N2hwanplO9Zg7daUSOF5kxWQA1HUcZ1+BYnEHtHwOCmP9byp1Ed8G67faX2LlTw4z0ksk0674p1thnVYJQtt4JhxC07DQWHK2VXmFrkcVCWwqglZndfA2PQQd+WRsaDeos3toRPuoHYqmngTSRtxWEeLI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com; spf=none smtp.mailfrom=mojatatu.com; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b=OpGS25re; arc=none smtp.client-ip=74.125.82.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mojatatu-com.20230601.gappssmtp.com header.i=@mojatatu-com.20230601.gappssmtp.com header.b="OpGS25re" Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-1220154725fso187309c88.0 for ; Wed, 21 Jan 2026 11:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20230601.gappssmtp.com; s=20230601; t=1769024854; x=1769629654; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ghQ1KD4bD3UuMNHS90xQzdAHsii/uYgvSXFMZHQgAwQ=; b=OpGS25reeIVL229DD6aBx+eu31A+v4FeZpRy5frVWoJ/rFNOn3/X3nu54fJop8yKml lVqh+E2jaw/N+ZQd6fdb1i4mBxbc1BbTbeIqFdnIBIKQivhfXXzwJsm2SgY+izX4ofeE wzXCuzXlQAqLe0zGjsX3hxcGOAr1oB064ToxNiB6yWPamk8X1lgej7YoL3wb5guhYrZG 7OWT0K7o9F+jxdyapZvQhYxF15JIsBMd/fS5RSAfYwYvBF29g0PHC0IP7GI61pShd3tt ECTsoasbouoFOqs/dd4lC10Cnm5rsYnjhiXiMncLYx+WMxRlSipi5n6VnwxmPqWpNJTu r9sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769024854; x=1769629654; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ghQ1KD4bD3UuMNHS90xQzdAHsii/uYgvSXFMZHQgAwQ=; b=gKXze5g43ho7u39k7Mt/+25DzmyD4O7IRdhRgtVhn+ypft3JgX4WVLMeK8erPsUWMQ MZOiKpo4/AO/q151Gra9sM7kGUsYwCAebxDHdGz3pPLiPjIVoKawdiw5U1Ehq8X4FfR2 1Omgp1KOiIdKYk60eANSIeumQJiE3wAidUEBSM9tIL8pAuZMc8qYHgDz1jio7E8Gedf5 8GMRHcJHq0jsXmBUdVt2ZClmIII++0xgTUd8/3vFf0l+MyuaSSoULP3btjwhapmVjGtA 4WfZ2CqTpLBDur6eNMgtkmluyly9E0SVknx/au8HmchWLa3E6/t1gRpdE8AG45QLZF1q H0WQ== X-Forwarded-Encrypted: i=1; AJvYcCVN36hoQF3tkbmShy6TrLPLvXDjxulLIEiv0zwhM4ixfqelmmyc/dzpD002Vhc+d/nKc00IrYLnPFaOh/k=@vger.kernel.org X-Gm-Message-State: AOJu0YzpCKSy+96WN1UNQPDTpm4uP0u4h3+axsdUpQAyiU1ZCG6FuHwB KxM/NNY3Ao4K1wQlAtqubAnF2JLis6gt2VgJfeZLG30559NtzFd1uhmiXBaWuE4aRw== X-Gm-Gg: AZuq6aIcmwr4eb5NtKxqX0iImSzwTNHYwXZsm8EF75lx5pvLocvdV3zOFcsLTmawwBw vSHqLF9J9KB2GeLQm48DVCWvz+bZFYCuqqGovjUjZkfUZrL7sgjJDclj31CiYntLGMUtTHdI6Yh g9JR2Oa8gIGV5SeB4hNlz4kHogUxUe2oqLMadWei9dmrrW2QjTq0DCOi/jX8DgnBwHQUCUIUK3c yFhHw5hdUepOufV7Qz2IjwnNWugZAoRWBeYUiCjSPDNH2ySXEkI/a5DOW8RPzQ9qxklNsb2I03S JXA42X2ur9D667hC5RbuXrSW91PdP7YYw383XU8NcnSaV6KY1K7W8Qdu+UM66Mra7NV+G8NuMDJ S97Wi2q8tYgeP+QcG/b9YK8cINe/8pWi0JUXtv8ggBAVtpezHOnV06X7TNeV0fXpMqIaqa4CcKx hn4RZKfqyirkNArWNnhxK1yA== X-Received: by 2002:a05:7022:2390:b0:119:e569:f84d with SMTP id a92af1059eb24-12476a6d462mr351429c88.4.1769024853578; Wed, 21 Jan 2026 11:47:33 -0800 (PST) Received: from ?IPV6:2804:14d:5c54:4efb::1c9d? ([2804:14d:5c54:4efb::1c9d]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b6b3502c91sm22276230eec.9.2026.01.21.11.47.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Jan 2026 11:47:33 -0800 (PST) Message-ID: <50912945-9da4-40c8-adad-34baa2b1e81b@mojatatu.com> Date: Wed, 21 Jan 2026 16:47:27 -0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v3 7/7] net/sched: act_gate: guard NULL params in accessors To: Paul Moses , netdev@vger.kernel.org Cc: Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260121131954.2710459-1-p@1g4.org> <20260121131954.2710459-8-p@1g4.org> Content-Language: en-US From: Victor Nogueira In-Reply-To: <20260121131954.2710459-8-p@1g4.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 21/01/2026 10:21, Paul Moses wrote: > Guard NULL params in accessors/dump/timer paths to avoid crashes during > teardown or failed initialization. Other actions already guard params before > RCU cleanup (act_pedit, commit 52cf89f78c01bf; act_vlan, commits 4c5b9d9642c859 > and 1edf8abe04090c), so act_gate should tolerate NULL in reader paths too. > [...] > diff --git a/include/net/tc_act/tc_gate.h b/include/net/tc_act/tc_gate.h > index 9587d9e9fa38f..8c3309b0dd779 100644 > --- a/include/net/tc_act/tc_gate.h > +++ b/include/net/tc_act/tc_gate.h > @@ -54,12 +54,13 @@ struct tcf_gate { > > static inline s32 tcf_gate_prio(const struct tc_action *a) > { > - s32 tcfg_prio; > + s32 tcfg_prio = 0; > struct tcf_gate_params *p; > > rcu_read_lock(); > p = rcu_dereference(to_gate(a)->param); > - tcfg_prio = p->tcfg_priority; > + if (p) > + tcfg_prio = p->tcfg_priority; I don't believe you need to check for NULL in these helper functions. From what I understood, the only place setting this to NULL is the cleanup callback. You also won't be able to run this in parallel with the init callback. > [...] > list_for_each_entry(entry, &p->entries, list) > diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c > index e4134b9a4a314..65b53cbf37e67 100644 > --- a/net/sched/act_gate.c > +++ b/net/sched/act_gate.c > @@ -82,7 +82,11 @@ static enum hrtimer_restart gate_timer_func(struct hrtimer *timer) > > p = rcu_dereference_protected(gact->param, > lockdep_is_held(&gact->tcf_lock)); > + if (!p) > + goto out_unlock; Also don't think you need to check this here. Unless I'm missing something, cleanup will only set param to NULL after the timer callback has finished executing. > [...] > @@ -643,6 +652,8 @@ static int tcf_gate_dump(struct sk_buff *skb, struct tc_action *a, > > rcu_read_lock(); > p = rcu_dereference(gact->param); > + if (!p) > + goto nla_put_failure_rcu; I don't think you need the check here either. Take a look at act_vlan. cheers, Victor