Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp806105imu; Tue, 11 Dec 2018 07:53:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/W3wsaph4vFTKwl56VLfNFVfvyA3Vn76vtGshs7gUqrhKEPc2waxqEencsrcDgjwZ9amqtx X-Received: by 2002:a62:7892:: with SMTP id t140mr16723165pfc.237.1544543596158; Tue, 11 Dec 2018 07:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544543596; cv=none; d=google.com; s=arc-20160816; b=rld/aTXHpHT3vAQxLwIRnRWeLeOjZyk99ZxSZWw7sO/ihR+i9441ZxUnL+sLmBtohs iCxPLjexB/flxYMhM4IsJBZzLyOowWD7uWWSseeZKNxRKvOP1ElvTl9debNCblLW1a0/ rdza/llrSfMYWQxVGRGvhtUbz9j7Msw59EccLNwR773EwF2tIXdJmJbCGpzepejIk92N OfhcyGRm9Y/Ne7nzQ4K66ClsZZZ9ag+p7WlHQ3B9jl4i92c3a+cUTrAVYvvBbYodtJuz vQCgeuxYZM1qEUb0j/45vo+lKfRIYyYM9N/Et8EeWMKxyR9gWgSVews9K9LYXkyDWYH8 Rm5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y1VkRll/vZdDwW7qtzlhAX8i8fHTKwZlnQ0u8viWJ+w=; b=06LgxjNhJxLSxOIaLwqce6GD3CPhSMuP1PUNalXuBFS7aqnomxkm/8BYRhE0nU5t63 eESvNPWsSfR66PDqKG62TqGP34Y8tMkEycrjDLA2fLoev96wG8qaGQGVVTU8nApxR5gT omlUG/BzgDUH0/H7TgB99REfOVXlBMvSq9eIdoNlzdD+uX26P4VoqWE8MQPukj9A/Hng PQpZ3oN5D5rkWycVlYjIeecRPE1Zelmv00WzuyuciEj6jvYefOuNOpmc2mNoxVnOt3lq XcqM6yiVXKOnnatQnOFUcjuEs0+birrsRRqtkUO9RmshefvvNZxnVyjW2/z578Lgk0Qv eX3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cSvULXdy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si12820448pgr.500.2018.12.11.07.53.01; Tue, 11 Dec 2018 07:53:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cSvULXdy; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729503AbeLKPv3 (ORCPT + 99 others); Tue, 11 Dec 2018 10:51:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:40070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728270AbeLKPv0 (ORCPT ); Tue, 11 Dec 2018 10:51:26 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 618C62084E; Tue, 11 Dec 2018 15:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543485; bh=GN7W4OAIQJImCtpARNKgATw13qsK4UxyBhweSNCwPTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cSvULXdyeh6vwV5/BvDEnfPehGh/zwpPihoyeEGoS1SCtNLCyOIUO7btOiOD4mHbS y9dYD0BtHNGKsOlG3UDlJLr+sN9kHLDm1RKh1EYnz1VMQlij5/m68zlgLkYNqSF9zt +DM6Wmyq/kCK/l5GKlnBOiR92E321N1gkNWI1+Do= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aya Levin , Tariq Toukan , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 17/67] net/mlx4: Fix UBSAN warning of signed integer overflow Date: Tue, 11 Dec 2018 16:41:17 +0100 Message-Id: <20181211151631.258636206@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151630.378216233@linuxfoundation.org> References: <20181211151630.378216233@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit a463146e67c848cbab5ce706d6528281b7cded08 ] UBSAN: Undefined behavior in drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:626:29 signed integer overflow: 1802201963 + 1802201963 cannot be represented in type 'int' The union of res_reserved and res_port_rsvd[MLX4_MAX_PORTS] monitors granting of reserved resources. The grant operation is calculated and protected, thus both members of the union cannot be negative. Changed type of res_reserved and of res_port_rsvd[MLX4_MAX_PORTS] from signed int to unsigned int, allowing large value. Fixes: 5a0d0a6161ae ("mlx4: Structures and init/teardown for VF resource quotas") Signed-off-by: Aya Levin Signed-off-by: Tariq Toukan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx4/mlx4.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index c68da1986e51..aaeb446bba62 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h @@ -541,8 +541,8 @@ struct slave_list { struct resource_allocator { spinlock_t alloc_lock; /* protect quotas */ union { - int res_reserved; - int res_port_rsvd[MLX4_MAX_PORTS]; + unsigned int res_reserved; + unsigned int res_port_rsvd[MLX4_MAX_PORTS]; }; union { int res_free; -- 2.19.1