From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EAF6200132 for ; Thu, 13 Feb 2025 10:13:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739441588; cv=none; b=vAmP23Lo5r8jQhLLPEUnSZyTpbnz7eZ6NHud03yEW0KO5ctS4Yca+crXNtBh2VJQLAFtG+BOauDhTUxr6OjxbqlrsKKWXR0t4SYQwdZWdhiN33antC+w4cmzxGUIbYWnOubhGVPWZxlsqzg7fDsJmfAikaYsalic+/odcYVBfLc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739441588; c=relaxed/simple; bh=TPJ/nTIknPS5cx18/Sqpw2qu6ixwnIbzogcI8kwGoP8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=XoibrIkoESsAAfezzhWGDAUX7bTpEuYCRTtKU4PrfKwgicGmkluyCpz2F57ZDfDOwC5bsHiHck0MkcNJnB+7zRnv20zYUruwDZktQzjJl2Grr3KmK8g4yV6m4vsSYV1zgTrtXG6892GoqPfp10IfpUSu6lzaq8LpLCKe8/DZIpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=UEtG5sMd; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="UEtG5sMd" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1739441586; 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=Kir0xP/eZn19J/5p1I2ZFGYt8Aw6idVAPW8577Id44g=; b=UEtG5sMdVaabwnNkpE+fweK0GZvaxOYNJ5PznfQqss50V0b9KeFylLnXMBsVOtqNp9n29h VHeC6cKMDDp3bXp1D/1zxS74koh8lnJG8IPXfZ1EttJ5m9tXMKWdXwoXsg7xIpBHPntTLl vfDeAIAr+lfO5yoz2PMDrdoI4vkU/Ck= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-395-Ah_uiyQENeeaLPemaZ2fyQ-1; Thu, 13 Feb 2025 05:13:04 -0500 X-MC-Unique: Ah_uiyQENeeaLPemaZ2fyQ-1 X-Mimecast-MFC-AGG-ID: Ah_uiyQENeeaLPemaZ2fyQ Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4395f1c4354so4999435e9.2 for ; Thu, 13 Feb 2025 02:13:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739441583; x=1740046383; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Kir0xP/eZn19J/5p1I2ZFGYt8Aw6idVAPW8577Id44g=; b=ZpFnjgLhfFAtMAfpzWGWh1SrAbOhGiwnH1pmVbf/3XLYRnAnpBl5LkD2H077V1JoYE wDAf5Hc7m4aCbpAdEwWVGEYwYMutAJXVww67/u0dNXXAgF19WW+1F3jkiNJFRgrUrUh4 pMPf1mrYCrf1FLBkyRcMZa60ExrWNnmgYxvbPvlVbzY9O9dmg9c4AtrFzQcYD/nX+gOa hIP0vqemiLfMfMZH1WX/GCZZet+8+KvR0FOF9aCSDHxGsSRtz1p+Qv2onvmO/Qcsn0rF BDEa9KcOmYAvgeywlXXYqUlYbqFZ0jaVaNmc+h/aD+MjRDbnnVr5ScPw783AvEyoCDRP p2mQ== X-Forwarded-Encrypted: i=1; AJvYcCUHdmjuWRlgoi1O6NBSEMDM8U98GXG9H6yu4rLzed8BX4liov7gBIrkrzViQImUb9A2L9ZWqdFDsPvLO1eI+to=@vger.kernel.org X-Gm-Message-State: AOJu0YyhqLN7CnmdRCfJ/l1pl4w8fQP8eDvVmjYEOlVUAm8vEO5tfZEB ayd42eN7w93TRRvJiw7OzdcWiZIR2fvhzzabrTwZRZX0MP46jgmWQIOe2mKRDp0BWwcChzG08aE 9Btkm6Rq95u5T0aZEqaGIisN0WM6uxK/MvPrxlO2Swqk2tkIs4bB25rKx7R7Np1Wa1w== X-Gm-Gg: ASbGncue+TfRV15uWiqYKr+nDhn1HdZaTTOgzR1kNP/aD172SHaCY8MShcIQ6RTMBJD w7urCC4004uha0BrI3HIhpMPl3aoKAySkG58/XfWU8eGBefEs+tW7//O65LS2Sszc/hDzrqEav+ hgSx9R0OkvRo326yzARUoH4jdv+7lXlyX9wBb8e2d9Ua8daSjIARL+K39Mnjg7vbqn5szYUJRmn rw5nxciNXxVeOFYUGz4EaSU6UFHcLw5w9ByffJy7+kxW9FY2XllH3OHcyEfoB5cAEQqw4qOPCWP JrSH1vMR7MHNpGkv/QkFtK/l//Hfdnijt3c= X-Received: by 2002:a05:600c:1d85:b0:436:f960:3428 with SMTP id 5b1f17b1804b1-439581c9cffmr67587435e9.29.1739441583335; Thu, 13 Feb 2025 02:13:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IEr/ZoioARrAtsjEX0T4uArnjm6HRk8PKz7oSXppRfbi28wR4BrFT3aKjCq8hOmcWroASjtgw== X-Received: by 2002:a05:600c:1d85:b0:436:f960:3428 with SMTP id 5b1f17b1804b1-439581c9cffmr67587045e9.29.1739441582954; Thu, 13 Feb 2025 02:13:02 -0800 (PST) Received: from [192.168.88.253] (146-241-31-160.dyn.eolo.it. [146.241.31.160]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-439618a9970sm12953035e9.33.2025.02.13.02.13.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Feb 2025 02:13:02 -0800 (PST) Message-ID: <3bd1622d-438a-4903-b87a-08987f98c449@redhat.com> Date: Thu, 13 Feb 2025 11:13:00 +0100 Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] net/mlx4_core: Avoid impossible mlx4_db_alloc() order value To: Justin Stitt , Tariq Toukan Cc: Kees Cook , Tariq Toukan , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Yishai Hadas , netdev@vger.kernel.org, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20250210174504.work.075-kees@kernel.org> <3biiqfwwvlbkvo5tx56nmcl4rzbq5w7u3kxn5f5ctwsolxpubo@isskxigmypwz> From: Paolo Abeni In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: F1NCVNXr06nhR1hV2c2a-Mf28hUoesyXhaQH8FqOxjc_1739441583 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 2/13/25 1:10 AM, Justin Stitt wrote: > On Tue, Feb 11, 2025 at 6:22 AM Tariq Toukan wrote: >> On 11/02/2025 2:01, Justin Stitt wrote: >>>> diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c >>>> index b330020dc0d6..f2bded847e61 100644 >>>> --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c >>>> +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c >>>> @@ -682,9 +682,9 @@ static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device) >>>> } >>>> >>>> static int mlx4_alloc_db_from_pgdir(struct mlx4_db_pgdir *pgdir, >>>> - struct mlx4_db *db, int order) >>>> + struct mlx4_db *db, unsigned int order) >>>> { >>>> - int o; >>>> + unsigned int o; >>>> int i; >>>> >>>> for (o = order; o <= 1; ++o) { >>> >>> ^ Knowing now that @order can only be 0 or 1 can this for loop (and >>> goto) be dropped entirely? >>> >> >> Maybe I'm missing something... >> Can you please explain why you think this can be dropped? > > I meant "rewritten to use two if statements" instead of "dropped". I > think "replaced" or "refactored" was the word I wanted. IMHO that would be a significant uglification, not worthy to address an issue that could be solved with the patch proposed here. @Tariq: are you ok with this patch? Thanks, Paolo