From patchwork Fri Mar 28 20:16:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 14032413 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 EEEEA1D4356 for ; Fri, 28 Mar 2025 20:16:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743193001; cv=none; b=IyajSTTYP+2bDIpMUC5LHccvGIzKOIWmUy9W9eeYF9ffii8XSarbFBqqIFf/6CaPPwlFfEB4sWPgXGGmdCjrrioTh5PYVMHKum43N4aT56Em5sdOf9o/Nhs7+10y6RimINLdwL9DdQ/Cwtzc+yHEAnGqUh+Gk89oabGuib+vPos= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743193001; c=relaxed/simple; bh=4pKDRF2iwqr49H7DZYsTMHDKvX2XkMm1dW7bXSLKeHU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=asFbRS+ZN9ijXa/Pt04AohH5UeGYEsgXu4mZpb+rx95iQJ9FH+Yo3hOZw3t0doSrzrzNeC+zwPJlKDbWIJz8i0K1H8NDI5a5HXzfdwNhqNyAviFcGKTNVGYX53f7hVSBBGPzPgYsuLQgSEIGvUrJ+NQl0B7uUgMSdIegk0nhvm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ykoHCi8/; arc=none smtp.client-ip=209.85.216.74 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--tavip.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ykoHCi8/" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ff854a2541so4019328a91.0 for ; Fri, 28 Mar 2025 13:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743192999; x=1743797799; 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=g84tB6TTtPFwbjWNx+m4WUrR648noFqvtBZRSiUTd+4=; b=ykoHCi8/A8Hhigx9nZFuWjJyzI+axln7MhLokrhqj/tC9OMAKKHS1WQw9NPi08buRa Q4rjf4x4vulyGB8vNRqa37Ux12N0rbYYjT5B56mHw1Gc5v1ZpRX10GC8Vl933UPAeLTU k1gPUpAeZ3+zW7gE0HbEibqssZqEwRh9h1E+AVhpZmfRHLjlIApdp43588aTR2JRTMiT la1kUQRkLh45UA8V5+8rI3A9BHJVx/CJ3lsr9wKTBS8UON1s4mLPrfKXG0EGp2kZovFI mrKlvUGLSawgjhK+uFshjkA1B1qiOAZCimeYQnAi3W6Ixc4+AmRzX3SfzrbUR1Npo1fh YrYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743192999; x=1743797799; 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=g84tB6TTtPFwbjWNx+m4WUrR648noFqvtBZRSiUTd+4=; b=Ea+uZ/hEbsqsCPRya6TYAmv9/DU32OaQLvpb7DLomai0jKeFUPuCCTFR7giGurzyhr dZUhVuUt5YN9CrlyUlWEm1xWktB+6qCW65omX7tDyOlOQnuahlb4I2EtsISIMnC98CdF +vVH7f1ISvgKfrlF3Df+lc+sKJtR9HXlTa8HxSEbzyVQoYeecsxwEL760+Xxs4nE8dzG UdjR631dyDsZpqPRz8A4SlD9WqT7WhWgQciTnxl2ROtowH8l70EhJnD0ms25uAziVScZ cvUygrO28GFfssOAgB+fwOPIgdO76fyguZLMncRrUeRiexBj1zuN5HuMgb8sW65LmjQU fo1g== X-Forwarded-Encrypted: i=1; AJvYcCVDAeKk8iypDyH+bRbEbrYdJnmysKjbKMlmkqHfk8pFy+d6OF8G+7Hj6j2fM9A8g8s2n4c/1sc=@vger.kernel.org X-Gm-Message-State: AOJu0YxWxb8H2iOkHYWbccvV/i8aAB5bK9tyz2P+0Kc4kJjGOKM8OUjp APN1aIpt12s2xrpRGet6Al3y1Vl+6THegfM5GX3/ktTrsS86TEqH5V60ys2xvEI+K++Nbm+9rg= = X-Google-Smtp-Source: AGHT+IHOeUK7pBfUR/y08vQ+ZDP8bmgMa/wZrE9pwj8UiKL3n16HPSHJ0UE6F6ZKPvOapoIAUMVV9WH4sw== X-Received: from pjp4.prod.google.com ([2002:a17:90b:55c4:b0:2ea:3a1b:f493]) (user=tavip job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:d007:b0:301:98fc:9b51 with SMTP id 98e67ed59e1d1-30531f7beebmr856462a91.5.1743192999226; Fri, 28 Mar 2025 13:16:39 -0700 (PDT) Date: Fri, 28 Mar 2025 13:16:32 -0700 In-Reply-To: <20250328201634.3876474-1-tavip@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250328201634.3876474-1-tavip@google.com> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog Message-ID: <20250328201634.3876474-2-tavip@google.com> Subject: [PATCH net 1/3] net_sched: sch_sfq: use a temporary work area for validating configuration From: Octavian Purdila To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, Octavian Purdila X-Patchwork-Delegate: kuba@kernel.org Many configuration parameters have influence on others (e.g. divisor -> flows -> limit, depth -> limit) and so it is difficult to correctly do all of the validation before applying the configuration. And if a validation error is detected late it is difficult to roll back a partially applied configuration. To avoid these issues use a temporary work area to update and validate the configuration and only then apply the configuration to the internal state. Signed-off-by: Octavian Purdila --- net/sched/sch_sfq.c | 60 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 65d5b59da583..027a3fde2139 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -631,6 +631,18 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, struct red_parms *p = NULL; struct sk_buff *to_free = NULL; struct sk_buff *tail = NULL; + /* work area for validating changes before committing them */ + struct { + int limit; + unsigned int divisor; + unsigned int maxflows; + int perturb_period; + unsigned int quantum; + u8 headdrop; + u8 maxdepth; + u8 flags; + } tmp; + if (opt->nla_len < nla_attr_size(sizeof(*ctl))) return -EINVAL; @@ -656,36 +668,60 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, NL_SET_ERR_MSG_MOD(extack, "invalid limit"); return -EINVAL; } + sch_tree_lock(sch); + + /* copy configuration to work area */ + tmp.limit = q->limit; + tmp.divisor = q->divisor; + tmp.headdrop = q->headdrop; + tmp.maxdepth = q->maxdepth; + tmp.maxflows = q->maxflows; + tmp.perturb_period = q->perturb_period; + tmp.quantum = q->quantum; + tmp.flags = q->flags; + + /* update and validate configuration */ if (ctl->quantum) - q->quantum = ctl->quantum; - WRITE_ONCE(q->perturb_period, ctl->perturb_period * HZ); + tmp.quantum = ctl->quantum; + tmp.perturb_period = ctl->perturb_period * HZ; if (ctl->flows) - q->maxflows = min_t(u32, ctl->flows, SFQ_MAX_FLOWS); + tmp.maxflows = min_t(u32, ctl->flows, SFQ_MAX_FLOWS); if (ctl->divisor) { - q->divisor = ctl->divisor; - q->maxflows = min_t(u32, q->maxflows, q->divisor); + tmp.divisor = ctl->divisor; + tmp.maxflows = min_t(u32, tmp.maxflows, tmp.divisor); } if (ctl_v1) { if (ctl_v1->depth) - q->maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH); + tmp.maxdepth = min_t(u32, ctl_v1->depth, SFQ_MAX_DEPTH); if (p) { - swap(q->red_parms, p); - red_set_parms(q->red_parms, + red_set_parms(p, ctl_v1->qth_min, ctl_v1->qth_max, ctl_v1->Wlog, ctl_v1->Plog, ctl_v1->Scell_log, NULL, ctl_v1->max_P); } - q->flags = ctl_v1->flags; - q->headdrop = ctl_v1->headdrop; + tmp.flags = ctl_v1->flags; + tmp.headdrop = ctl_v1->headdrop; } if (ctl->limit) { - q->limit = min_t(u32, ctl->limit, q->maxdepth * q->maxflows); - q->maxflows = min_t(u32, q->maxflows, q->limit); + tmp.limit = min_t(u32, ctl->limit, tmp.maxdepth * tmp.maxflows); + tmp.maxflows = min_t(u32, tmp.maxflows, tmp.limit); } + /* commit configuration, no return from this point further */ + q->limit = tmp.limit; + q->divisor = tmp.divisor; + q->headdrop = tmp.headdrop; + q->maxdepth = tmp.maxdepth; + q->maxflows = tmp.maxflows; + WRITE_ONCE(q->perturb_period, tmp.perturb_period); + q->quantum = tmp.quantum; + q->flags = tmp.flags; + if (p) + swap(q->red_parms, p); + qlen = sch->q.qlen; while (sch->q.qlen > q->limit) { dropped += sfq_drop(sch, &to_free); From patchwork Fri Mar 28 20:16:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 14032414 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 8A3821E8358 for ; Fri, 28 Mar 2025 20:16:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743193004; cv=none; b=dqZlxLIPMsN6cZ70nqoRetgbta2FtDDV1ne8NKXquh3GOuRO01N4bK+Hr2eWBDYIbhTsE6Bv25Tc5VEToqSgUNPPgLytJWcBHpsNi302mAx9hApnVatFVqM6nhysAvr3FSZsdzluUktPUABjMkMX5U4Fwyz/TrqhNB7IPOzxjFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743193004; c=relaxed/simple; bh=/d8vO2C1eeO5N9G7Typl2yyUYpz8IbUG8Oa6nkZ1pLA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=bagIsrdqNl/8swekdjQpAc52cQEkU6yI2WKc2a43xUUspO5Bz2QO9yyo/bKACVBYWK0O+sqojRtOpZgw45tVdy0rnFSl/HxH6lIaizzHKwjTRh/8p4W72vmS44CgrbUfG6Mt/PWEN83rZUHQumGfkOLqG+kmOV2CJRRgQUSOKrU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=rI+CPn9T; arc=none smtp.client-ip=209.85.216.74 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--tavip.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="rI+CPn9T" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ff581215f7so2695592a91.3 for ; Fri, 28 Mar 2025 13:16:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743193001; x=1743797801; 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=p0YXNUFYQ3sMTWf05xT4CZP2DxoBoh8fB4N7zDXyH2A=; b=rI+CPn9TMicLDZFwbVKmcEP3DI45v6sF5vkXDFWROgHBqOeow6rw4tocDvFPE2uBMF XfOqkjx6UbmsmwfW9XJA5eDIX5qDc82FyN4homA9/k4ozi3LYpV+g16qxWB278bwxEPj tFRxdufNiiZ+h4HaKDCmlDLh6lbZgkCrv066Ho+NfdvHuX2ogdLXTeCwUpGhYyXfArA3 pzZhaWUS03YtN+xtyYvaPDZBAOUliCHOBMcGORc5ZMqMfVzErRfSKDM8NbqbOHSVCzok B6z14vRNBNoJN411sSbnybCdx2HyZ5dgCwu+m0NuRHpKqlnuEgWwf7Yl6/R+fQv74ZeC 6jsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743193001; x=1743797801; 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=p0YXNUFYQ3sMTWf05xT4CZP2DxoBoh8fB4N7zDXyH2A=; b=BF+Ut2qMFGu+syB2mqeghM9GaM431NFbq6hff3bN2h+iVE9ZHoKANbc0OMkdlbxiHg yGBy+MisEz6rRP8epb6BinZVod/frhQWKcsT+3QG920YihVb53B4KBGSLhaLrlFhn0Y6 HL5ig7YoYi0MVrDeajItTN0AhzI30D7ZzRHV9NR7UmsdE4eJsxei1lkMrsKZ26RzkIVE jdKWXj3GiTxQMu3AkbEYyaoNV4+dLMN9fdyUQTXULPDfBjF4Uammb2SBp2Dm62ndJrNe vr5CSJUqgykk8tcLyN4HmBndyDXz9FlNwTAXYt+fIA2Is3ynHpQ0aQZ4uJYTCyHSQWkF hXhQ== X-Forwarded-Encrypted: i=1; AJvYcCWarwOzEacIUyKfa8zQ+hgM+3gPzYuT+a0DPtcRaeg+KJ9wslb2ab+mjEehap4rg881VJFS0W0=@vger.kernel.org X-Gm-Message-State: AOJu0YyTR6fw0OK9gLLCGaUhrT3UcYeHTPQ39fOI7/ZYSD4HlbcDz82e kxUZh9HbngVO2YQQiErs2YqUqaDknZ4ei0scgv/jvWwT5qdpeynED4H8S6rOkgZU/YNDY+KIrQ= = X-Google-Smtp-Source: AGHT+IH7GsVfne83CdL1W8HGAxpwontSfLjxTtcPqtRYt4mmyeSInURDrqnUPnm1UOYREYHqzai6w/uc0Q== X-Received: from pjbse5.prod.google.com ([2002:a17:90b:5185:b0:2f5:63a:4513]) (user=tavip job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:384d:b0:2ff:58e1:2bb4 with SMTP id 98e67ed59e1d1-30532153742mr619489a91.22.1743193000859; Fri, 28 Mar 2025 13:16:40 -0700 (PDT) Date: Fri, 28 Mar 2025 13:16:33 -0700 In-Reply-To: <20250328201634.3876474-1-tavip@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250328201634.3876474-1-tavip@google.com> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog Message-ID: <20250328201634.3876474-3-tavip@google.com> Subject: [PATCH net 2/3] net_sched: sch_sfq: move the limit validation From: Octavian Purdila To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, Octavian Purdila , syzbot X-Patchwork-Delegate: kuba@kernel.org It is not sufficient to directly validate the limit on the data that the user passes as it can be updated based on how the other parameters are changed. Move the check at the end of the configuration update process to also catch scenarios where the limit is indirectly updated, for example with the following configurations: tc qdisc add dev dummy0 handle 1: root sfq limit 2 flows 1 depth 1 tc qdisc add dev dummy0 handle 1: root sfq limit 2 flows 1 divisor 1 This fixes the following syzkaller reported crash: ------------[ cut here ]------------ UBSAN: array-index-out-of-bounds in net/sched/sch_sfq.c:203:6 index 65535 is out of range for type 'struct sfq_head[128]' CPU: 1 UID: 0 PID: 3037 Comm: syz.2.16 Not tainted 6.14.0-rc2-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x201/0x300 lib/dump_stack.c:120 ubsan_epilogue lib/ubsan.c:231 [inline] __ubsan_handle_out_of_bounds+0xf5/0x120 lib/ubsan.c:429 sfq_link net/sched/sch_sfq.c:203 [inline] sfq_dec+0x53c/0x610 net/sched/sch_sfq.c:231 sfq_dequeue+0x34e/0x8c0 net/sched/sch_sfq.c:493 sfq_reset+0x17/0x60 net/sched/sch_sfq.c:518 qdisc_reset+0x12e/0x600 net/sched/sch_generic.c:1035 tbf_reset+0x41/0x110 net/sched/sch_tbf.c:339 qdisc_reset+0x12e/0x600 net/sched/sch_generic.c:1035 dev_reset_queue+0x100/0x1b0 net/sched/sch_generic.c:1311 netdev_for_each_tx_queue include/linux/netdevice.h:2590 [inline] dev_deactivate_many+0x7e5/0xe70 net/sched/sch_generic.c:1375 Reported-by: syzbot Fixes: 10685681bafc ("net_sched: sch_sfq: don't allow 1 packet limit") Signed-off-by: Octavian Purdila --- net/sched/sch_sfq.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 027a3fde2139..a9f20cc98a1a 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -664,10 +664,6 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, if (!p) return -ENOMEM; } - if (ctl->limit == 1) { - NL_SET_ERR_MSG_MOD(extack, "invalid limit"); - return -EINVAL; - } sch_tree_lock(sch); @@ -709,6 +705,12 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt, tmp.limit = min_t(u32, ctl->limit, tmp.maxdepth * tmp.maxflows); tmp.maxflows = min_t(u32, tmp.maxflows, tmp.limit); } + if (tmp.limit == 1) { + sch_tree_unlock(sch); + kfree(p); + NL_SET_ERR_MSG_MOD(extack, "invalid limit"); + return -EINVAL; + } /* commit configuration, no return from this point further */ q->limit = tmp.limit; From patchwork Fri Mar 28 20:16:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 14032415 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 741911E9B17 for ; Fri, 28 Mar 2025 20:16:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743193005; cv=none; b=iWrs2vQb2cxQ30wDvZNn9Fvb5yvtaL5W3IcHMHLiR9pQWNBy66KHt9X9QlhPNHNBUkKkGww5e9RKQ1bVMt3YBTAvrtgWXFuWB3dJR129YJts9ZF/ZCXFfyOfn4Vps0MXgi5Fc3/dithU65j9moTDPJBy+TVUN+t+tE4DrLBia6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743193005; c=relaxed/simple; bh=le48TpsLIXgwRUE7JK2oXHpEVjkDjeIk8bkxcrTUacQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mqfIJ4jChd6x6uxJ+Fylef9vn20QrrkKJTJxNAwK3O9i3qTH+8nRSPX1OBH/M3Xma3lKm2q1Z5vItt6VwNCaFSr4u9vKYC7Hmd0VzxTYu9XoCz2SN7mUQD0p6Vf2S0a1IJOywDVhk/PDOavGyAydgu0aI6ytbi1TUESE6jA4xhg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--tavip.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=CQc7cF5f; arc=none smtp.client-ip=209.85.214.202 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--tavip.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="CQc7cF5f" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2240a96112fso74872685ad.2 for ; Fri, 28 Mar 2025 13:16:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1743193003; x=1743797803; 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=WR5OMrXI1sfyljYWNGyiK+AjZvbJe/Y00ticFJRI05Y=; b=CQc7cF5fRIg/cVLPM418s4IZ7czghI291HBtM24bg9tG8Pr8jlmUw8bxvXISz5sQ8l 3YG7qv59Fj8bVLawjK83iYRQLFH79nng9SoarHQlQLMw/VLrYJOAR2cqbSQLAKWrwHek fWbseJNwM/sDM9zgmjV6qEhY3lE+ZJdf5Xnc4RW771Sy34QsA2iflM6tfxXh8vsF4PQ+ q5XS+2tJWF4OfuyAhipJbMIuM5ob98wzM37yDuMst3PWDvG2mUiXRDuHjKY0vkQmppn7 oKQATCg14Sk0Cm3JchC8ivGhF4dVbiDpLq38yrMTAIbq6aiVNWi1hkWIpreZmPIlv1R8 IeAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743193003; x=1743797803; 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=WR5OMrXI1sfyljYWNGyiK+AjZvbJe/Y00ticFJRI05Y=; b=WyU8YLyqYwE8WKwtVTyLSeJ8TYDtxRDHf+/yDAs2PIhluMzk3ovbg1dZh0YT5ugcgD L+iif57Xov2IVco2if48KNxRQJ9SULkWur/+Jp0CeMBRm55JabP/sPLdHemJgJtt20J2 3TfxvIlsWMz1lnbyVNy07r8bH2ZOeLTZSyZ9/uKC8SdnoqtVcjeHVOWcAzboY70r+03Z CVYYfjfU0wU9Pdh0icdU43IsZ/wlU64gGrJ5icN5qDMmmNzRq8Cx/I77YTKpXy0r/+4W fOYZ152mFLnSPm/r+IPRTZaA36THuJUAuYL82E1t4fIQ1FUllH9/4p40elfPHwNriRar UGrw== X-Forwarded-Encrypted: i=1; AJvYcCVk9g+5s2/XjOSlpl3y90cwrooGhw76oSFh+Wcwt6kdSpV1X1ajnejN9nhSl4+Q5mF9iHoBhpQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4yml3QR/ApY87yAaHUOBkhmo/SQm6Ih/q95nnSZulvNB2kZ0c TxHPbQN9dYci2A+6U5LArpKet8VgrRc9bI3OOJQHKmiReUH1e9CEnQdr/Zwo3G3yitLe2crHjQ= = X-Google-Smtp-Source: AGHT+IF/gmMBHEO5lFnJQmBUNEDIBqTm9oF7h64VgCkip8w3eGBGSWXUZKzfHz2IR6MvtfrZnBYeGVCPoQ== X-Received: from pfbit9.prod.google.com ([2002:a05:6a00:4589:b0:736:5b36:db8f]) (user=tavip job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:1309:b0:736:546c:eb69 with SMTP id d2e1a72fcca58-7398036fb06mr799581b3a.9.1743193002576; Fri, 28 Mar 2025 13:16:42 -0700 (PDT) Date: Fri, 28 Mar 2025 13:16:34 -0700 In-Reply-To: <20250328201634.3876474-1-tavip@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250328201634.3876474-1-tavip@google.com> X-Mailer: git-send-email 2.49.0.472.ge94155a9ec-goog Message-ID: <20250328201634.3876474-4-tavip@google.com> Subject: [PATCH net 3/3] selftests/tc-testing: sfq: check that a derived limit of 1 is rejected From: Octavian Purdila To: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, shuah@kernel.org, netdev@vger.kernel.org, Octavian Purdila X-Patchwork-Delegate: kuba@kernel.org Because the limit is updated indirectly when other parameters are updated, there are cases where even though the user requests a limit of 2 it can actually be set to 1. Add the following test cases to check that the kernel rejects them: - limit 2 depth 1 flows 1 - limit 2 depth 1 divisor 1 Signed-off-by: Octavian Purdila --- .../tc-testing/tc-tests/qdiscs/sfq.json | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json index 50e8d72781cb..28c6ce6da7db 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/sfq.json @@ -228,5 +228,41 @@ "matchCount": "0", "teardown": [ ] + }, + { + "id": "7f8f", + "name": "Check that a derived limit of 1 is rejected (limit 2 depth 1 flows 1)", + "category": [ + "qdisc", + "sfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [], + "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root sfq limit 2 depth 1 flows 1", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "sfq", + "matchCount": "0", + "teardown": [] + }, + { + "id": "5168", + "name": "Check that a derived limit of 1 is rejected (limit 2 depth 1 divisor 1)", + "category": [ + "qdisc", + "sfq" + ], + "plugins": { + "requires": "nsPlugin" + }, + "setup": [], + "cmdUnderTest": "$TC qdisc add dev $DUMMY handle 1: root sfq limit 2 depth 1 divisor 1", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "sfq", + "matchCount": "0", + "teardown": [] } ]