Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1912346ybb; Thu, 2 Apr 2020 09:34:07 -0700 (PDT) X-Google-Smtp-Source: APiQypJoEPN4h2mcmXEGrlU1HPYGcL8hcXvE1JYhy+TMMYjDibHExWvQQG5NPcuzulZ+VX71RbSF X-Received: by 2002:aca:f288:: with SMTP id q130mr2957022oih.33.1585845246936; Thu, 02 Apr 2020 09:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585845246; cv=none; d=google.com; s=arc-20160816; b=xeLVd9Bj8p1yGnvdBjDBTJe4HhI6zQ+3huYOeg+/oFU8Uxlm38IL8Av+7/aqsteVq0 S+zA72JApoMcEK2F7c7uCDPxh/DPHYD7qJIuMsnz2NVh8L54mzOTPcC3l4DztfD545h0 2uwZgGJ0vjjoD02VKfS5xM3Wvpk9EQFeuue21UBWOZpBs+ZyqHew2v5eCa6c3K2228RA I9ZktrvyZK9kCM/6F3uT2Q96o4ngX4jTtVm/5SggoGk/8sK1NNLh8mzIh0tChr8AAFov 5Uq1YS9SVXrAEr+mv++ksPE6VUkFnF4EvBqpEzmiI3cU1WcirAM14t6NzajM5TbJHjh9 e+kw== 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 :message-id:date:subject:cc:to:from; bh=ldZTg/PjD4Ysv5CHVl07wd8whgMvnBSFBJ40FcIaAV0=; b=oh/4/3sjX79qELDHY292ek8hRRwkARDuLLVg8a/zixp3F3Q2VtNSYR5oKGTZOJ+fDB db746w7eo1goeXrscGLqkLFe1pbrr9FrHB93edXkBHVXcG9AmwZuWxGp22uw/VGHGygw gxp/wmXxaYKcncOUwrcsAfnkgIjSzZUHFNcBj35f3dQJasc2MXV87bCHTJ5B/T80S4eT us2ghSpFvzH0nNVBUtASQDfL38WtJQAApNBR69pzn2QFyTZ8hEGzPlDOvrvUNRRB4X5p zlK+Brn8WS0eqQyupVYuOA2xF6GoY5cbtXXYhkWhsoKjpgpufRODj1COja003zloKj7t 6VBw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j15si2624013oos.59.2020.04.02.09.33.54; Thu, 02 Apr 2020 09:34:06 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388794AbgDBOv0 (ORCPT + 99 others); Thu, 2 Apr 2020 10:51:26 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:43473 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388689AbgDBOv0 (ORCPT ); Thu, 2 Apr 2020 10:51:26 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jK19H-0003mR-HP; Thu, 02 Apr 2020 14:48:51 +0000 From: Colin King To: Jiri Pirko , Ido Schimmel , "David S . Miller" , netdev@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] mlxsw: spectrum_trap: fix unintention integer overflow on left shift Date: Thu, 2 Apr 2020 15:48:51 +0100 Message-Id: <20200402144851.565983-1-colin.king@canonical.com> X-Mailer: git-send-email 2.25.1 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 From: Colin Ian King Shifting the integer value 1 is evaluated using 32-bit arithmetic and then used in an expression that expects a 64-bit value, so there is potentially an integer overflow. Fix this by using the BIT_ULL macro to perform the shift and avoid the overflow. Addresses-Coverity: ("Unintentional integer overflow") Fixes: 13f2e64b94ea ("mlxsw: spectrum_trap: Add devlink-trap policer support") Signed-off-by: Colin Ian King --- drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c index 9096ffd89e50..fbf714d027d8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_trap.c @@ -643,7 +643,7 @@ static int mlxsw_sp_trap_policer_bs(u64 burst, u8 *p_burst_size, { int bs = fls64(burst) - 1; - if (burst != (1 << bs)) { + if (burst != (BIT_ULL(bs))) { NL_SET_ERR_MSG_MOD(extack, "Policer burst size is not power of two"); return -EINVAL; } -- 2.25.1