From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f73.google.com (mail-yx1-f73.google.com [74.125.224.73]) (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 B9C3E379EE0 for ; Tue, 28 Apr 2026 17:04:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777395860; cv=none; b=DY2/SNZgiK80U5FWBOT7ppCcxch0u5K9f2K1ZhsRgJsuxKqMsCUuPB5r5OUsEQpo9RIDCjL4sPZk4PdvQC04YFce7gwHcJ1s3Tlw7s7hlF+cy85LKIKP2LapSoZjAv3U+PkJKNLSuaugB+vNS0laorn+5Kjh6Jpo1l3UtgCKdbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777395860; c=relaxed/simple; bh=wkTkUGn5w0x298A5D/1ipkya6hboovyUVKNvgO/cYYo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=GGs8RwlUk4pboyfy2GhuzX3BxtOiWFoxU95en7FWGJmTBNQDc/BUTur39nDP0cVgTBdNQbP5xDG+Om75xGS9hq8hMwp64aaGoZREHd6O9PKrCUllcIZcy3LIO6/Z2uhnArjx3i8ISzTneyGeGll+egoHqDjwghHye8rVtlKwUIM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Mx568fe8; arc=none smtp.client-ip=74.125.224.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Mx568fe8" Received: by mail-yx1-f73.google.com with SMTP id 956f58d0204a3-6545a37ea2dso12846275d50.0 for ; Tue, 28 Apr 2026 10:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1777395858; x=1778000658; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=FUbU5K6FT0AKJdqvw/ptsAYButAjGg0L1SpY29bEPPY=; b=Mx568fe8SLm5RcvaFQYksWNcYQOh+7MFcHbqGgghhnu2Lsy2WdCLRSIIpqGoHWjVyx lf2kQohVJVSiJQ86nW30SfIjWrE7LCXpAzjRmzPgUtyRA8pmr9qDtiMs72Ayl6JZYhQY 1P8nq/hRKWcexm2Er4zqGCNgxaJOvAesgRenhtzec9XQSWaZWxMS3jzkiDQlo5LYPN22 6O+VTjLp26m8xHPJTdyTNk+sdaH4WJ6bZKIlHUlfp+fQ4f+YEzWkAcCka3QoPC+TKlI3 HVLkdBKo6sdgVj2cb057e37qGRaI4aXZoQbp72yCuoScmEbBM9J2TPQ0M2px0jd2xI5E 7E4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777395858; x=1778000658; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FUbU5K6FT0AKJdqvw/ptsAYButAjGg0L1SpY29bEPPY=; b=g4bT6gghNwYS2+VEZ5U7ZMJFsskaM//gsQ1dXfVLXWQY+rJQFQef6P7gdb7V/retQL lh06l9dOxHDamBPbgTOQ6uvHomxrNP/GgAMOj6uPuzN/crApUKNsM2Qhuoa5+rNPiexS hkHQkaPBYgDcMm8N21wunAAkM7Vw2J4neZCpVjEi13nc3zfAq8TJcALb6E4jjRkAtm/+ WMRWDl0dS63J8p3z/S07j98E/ru+V+k2O7KbYVazpVxQ2lISair10r8urG2zv+OU//d/ i87Ww2tNs/lG2iV2PAFSy4TPbEk5ZQW3c6Z+KWO7PU71jEAUT/KbZi+Jr7dMe7dt1Lul 2BPA== X-Forwarded-Encrypted: i=1; AFNElJ9ANFZow6zBWHkhd3zBCqWYUFVEfkVpugJiiVgCBp8IUgIhL5Ff5vzQpqqlNk1RfFJ4t0GJGOs=@vger.kernel.org X-Gm-Message-State: AOJu0YxTqZB0ID+JBBEnbg7pQwmKYNX7k2fhE1OmdZwqoyvSnLKOsZCx HcboJBDqie3XtQlJ1LeMfTv98KVYK7bJydtjQVOMDOExLCH8w3fWC9jMvXHW5GdpzV0WENOM3IV qId4b9Z+/Do4/Pw== X-Received: from yxtt28.prod.google.com ([2002:a05:690e:425c:b0:650:1566:cb5e]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:690e:4802:b0:653:f51:90b1 with SMTP id 956f58d0204a3-65beed7b720mr2733227d50.24.1777395857454; Tue, 28 Apr 2026 10:04:17 -0700 (PDT) Date: Tue, 28 Apr 2026 17:04:11 +0000 In-Reply-To: <20260428170414.250566-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260428170414.250566-1-edumazet@google.com> X-Mailer: git-send-email 2.54.0.545.g6539524ca2-goog Message-ID: <20260428170414.250566-2-edumazet@google.com> Subject: [PATCH v2 net-next 1/4] net/sched: propagate tc_fill_tclass() error From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: Simon Horman , Jamal Hadi Salim , Jiri Pirko , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet Content-Type: text/plain; charset="UTF-8" Change tc_fill_tclass() to return -EMSGSIZE when skb is too small. Change its caller to propagate this error (instead of -EINVAL) Signed-off-by: Eric Dumazet --- net/sched/sch_api.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index ed869a5ffc7377b7c19e66ae5fc9788e709488da..32ccd4672083aa19340520155aeba6d8b6ff546c 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c @@ -1987,15 +1987,16 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q, out_nlmsg_trim: nla_put_failure: nlmsg_trim(skb, b); - return -1; + return -EMSGSIZE; } static int tclass_notify(struct net *net, struct sk_buff *oskb, struct nlmsghdr *n, struct Qdisc *q, unsigned long cl, int event, struct netlink_ext_ack *extack) { - struct sk_buff *skb; u32 portid = oskb ? NETLINK_CB(oskb).portid : 0; + struct sk_buff *skb; + int ret; if (!rtnl_notify_needed(net, n->nlmsg_flags, RTNLGRP_TC)) return 0; @@ -2004,9 +2005,10 @@ static int tclass_notify(struct net *net, struct sk_buff *oskb, if (!skb) return -ENOBUFS; - if (tc_fill_tclass(skb, q, cl, portid, n->nlmsg_seq, 0, event, extack) < 0) { + ret = tc_fill_tclass(skb, q, cl, portid, n->nlmsg_seq, 0, event, extack); + if (ret < 0) { kfree_skb(skb); - return -EINVAL; + return ret; } return rtnetlink_send(skb, net, portid, RTNLGRP_TC, @@ -2017,17 +2019,19 @@ static int tclass_get_notify(struct net *net, struct sk_buff *oskb, struct nlmsghdr *n, struct Qdisc *q, unsigned long cl, struct netlink_ext_ack *extack) { - struct sk_buff *skb; u32 portid = oskb ? NETLINK_CB(oskb).portid : 0; + struct sk_buff *skb; + int ret; skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); if (!skb) return -ENOBUFS; - if (tc_fill_tclass(skb, q, cl, portid, n->nlmsg_seq, 0, RTM_NEWTCLASS, - extack) < 0) { + ret = tc_fill_tclass(skb, q, cl, portid, n->nlmsg_seq, 0, + RTM_NEWTCLASS, extack); + if (ret < 0) { kfree_skb(skb); - return -EINVAL; + return ret; } return rtnetlink_send(skb, net, portid, RTNLGRP_TC, @@ -2041,7 +2045,7 @@ static int tclass_del_notify(struct net *net, struct netlink_ext_ack *extack) { u32 portid = oskb ? NETLINK_CB(oskb).portid : 0; - struct sk_buff *skb; + struct sk_buff *skb = NULL; int err = 0; if (!cops->delete) @@ -2052,13 +2056,12 @@ static int tclass_del_notify(struct net *net, if (!skb) return -ENOBUFS; - if (tc_fill_tclass(skb, q, cl, portid, n->nlmsg_seq, 0, - RTM_DELTCLASS, extack) < 0) { + err = tc_fill_tclass(skb, q, cl, portid, n->nlmsg_seq, 0, + RTM_DELTCLASS, extack); + if (err < 0) { kfree_skb(skb); - return -EINVAL; + return err; } - } else { - skb = NULL; } err = cops->delete(q, cl, extack); -- 2.54.0.545.g6539524ca2-goog