Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp917522pxf; Wed, 7 Apr 2021 15:02:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPazlxA2twukMsGt5s/IF/UfujS6FShFZ3UIHeaE4KBIdK+q9AKYnKn6+g7Lzq0VGmzuKn X-Received: by 2002:a17:903:18a:b029:e6:7fc1:1c2a with SMTP id z10-20020a170903018ab02900e67fc11c2amr4792474plg.5.1617832933014; Wed, 07 Apr 2021 15:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617832933; cv=none; d=google.com; s=arc-20160816; b=ijIo/dH1UnSHPJxO3bgj1sIqfHqHEHlz0THQWjnQOKIzsGKpa9QrEpq5/PW2Kc0pa4 LATPGUQjZZpxMhkqJcqX9DqvzQ8JLVmBy0oy1hFUoIceTQyFLu39x0w+1gjsqDGLJZg8 PSo+BhzzgdqlDmEINYqmjIM59qBpQ6X/o3Qs0HT9FaBHwBMYZiNqFr6bd0LkgYdQm1Lv bw3R8BkHL3RW6yGL6jZ2snt+aes14THx5qdsc7bJj2u9e8gtWOWVtvPr9R6ioo2Fxstv TYmdMMX1hB3MsztwT73fdHhlVxchsSJrNuBrJf/FHcrkRTs93yKLOP+wonwCPssFEpPB 1Z1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:user-agent :mime-version:date:organization:references:in-reply-to:cc:to:from :subject:message-id:dkim-signature; bh=WLJvdPFUIJ5ny5ARwp+JcVCf2mi3H4Cm9mgG+8OeioY=; b=kOVJfvvzRKO+cE+PIxSahKk3aO28lJEca5OVB2JJnmrsM0iEI1R2ImlU0B2qSj7u0N /4ey0xvzKdp3WkpI+SOe6VeOMu8ie694b7jQahR/z0FrWo1aFHxqYHynZmxndkwy7Bu0 B01X2keHmaCmApfjSFdtB9S/c3qMQZCXYErP5BoW7trgLgmVm56yzIsJcJyQZ/KWmUNZ HM7jWyZwaOusvCG6azxKSSq68sAlDgPMhY44kO2R/saFUDCvu97NkTXmhnRUaacictKf oEQH+rgdRRj/0MUMlJexY0rdjuWLwpuyodaezWdpUKyDfym/9npIBcO+ZYdyLzzzPDkU jdjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y1HUqiWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si24977122plr.236.2021.04.07.15.02.00; Wed, 07 Apr 2021 15:02:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y1HUqiWN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356051AbhDGUUb (ORCPT + 99 others); Wed, 7 Apr 2021 16:20:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50092 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238340AbhDGUUa (ORCPT ); Wed, 7 Apr 2021 16:20:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617826820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WLJvdPFUIJ5ny5ARwp+JcVCf2mi3H4Cm9mgG+8OeioY=; b=Y1HUqiWNikdqNJprpoaJYPb60asaD9zirQ1O8P8CRuySgwGEchN7XELom7ZEVdjuOUV4jE 3TWG5UrVqEm9yuKwJfI6a78DB/ha9FiW+rN8Uj9UQwd9YnjAc0FooUoVBWLFkdaCmbeZZa e/q0Zcp+tX7q91KzqjB31PQcwj3w1u0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-590-DsyDga9MN9a9jyUCfVov6Q-1; Wed, 07 Apr 2021 16:20:16 -0400 X-MC-Unique: DsyDga9MN9a9jyUCfVov6Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 54A0E91272; Wed, 7 Apr 2021 20:20:14 +0000 (UTC) Received: from [10.40.193.103] (unknown [10.40.193.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F7B519CAD; Wed, 7 Apr 2021 20:20:09 +0000 (UTC) Message-ID: <4396d0b86d66afa1d3211403b48a15a4d0a03e55.camel@redhat.com> Subject: Re: [PATCH] net: sched: Fix potential infinite loop From: Davide Caratti To: Colin King , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S . Miller" , Gautam Ramakrishnan , "Sachin D . Patil" , Mohit Bhasi , Leslie Monis , "Mohit P . Tahiliani" , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210407163808.499027-1-colin.king@canonical.com> References: <20210407163808.499027-1-colin.king@canonical.com> Organization: red hat Content-Type: text/plain; charset="UTF-8" Date: Wed, 07 Apr 2021 22:20:08 +0200 MIME-Version: 1.0 User-Agent: Evolution 3.38.4 (3.38.4-1.fc33) Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hello Colin, and thanks for your patch! On Wed, 2021-04-07 at 17:38 +0100, Colin King wrote: > From: Colin Ian King > > The for-loop iterates with a u16 loop counter idx and compares this > with the loop upper limit of q->flows_cnt that is a u32 type. the value of 'flows_cnt' has 65535 as an upper bound in the ->init() function, so it should be safe to use an u16 for 'idx'. (BTW, the infinite loop loop was a real thing, see [1] :) ). > There is a potential infinite loop if q->flows_cnt is larger than > the u8 loop counter. (u16 loop counter, IIUC) > Fix this by making the loop counter the same > type as q->flows_cnt. the same 'for' loop is in fq_pie_init() and fq_pie_reset(): so, in my opinion just changing fq_pie_timer() to fix an infinite loop is not very useful: 'idx' is also used as an index for q->flows[], that's allocated in [2]. Maybe (but I might be wrong) just allowing bigger values might potentially cause other covscan warnings. WDYT? > Addresses-Coverity: ("Infinite loop") > Fixes: ec97ecf1ebe4 ("net: sched: add Flow Queue PIE packet scheduler") > Signed-off-by: Colin Ian King thanks! -- davide [1] https://lore.kernel.org/netdev/416eb03a8ca70b5dfb5e882e2752b7fc13c42f92.1590537338.git.dcaratti@redhat.com/ [2] https://elixir.bootlin.com/linux/latest/source/net/sched/sch_fq_pie.c#L417