Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4090829ybg; Fri, 25 Oct 2019 13:11:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpOhKsjQ1dC3WmlsZfQvfZ8bfXpziVZpT2O4Tp9EOkcDGDrOJpaIgkx5TZdSoX3rIoxgOh X-Received: by 2002:aa7:c484:: with SMTP id m4mr5987259edq.177.1572034267514; Fri, 25 Oct 2019 13:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572034267; cv=none; d=google.com; s=arc-20160816; b=BX46Rpo+O0Mjh5MAw3vcF3a7xAJt4uJUPx1ARloaP2S4wGmFPajWqooQBLq75kdK6K 4RuNq8DCZzJ02BQNt3hkJQ/MahVEh9LRM4K0UuRFWgSJZAUa0DKfxdx17oqSgqG3cZhB QYWawwZzBFLdZjt+h+EPnGz3ecTvL1++Nek2R2MchbR29jq+6egKEXP35VHeWPcf25ut GO9T3PJ3s5t6S4OrhtxCqK/1ONIzHgrz+2+D5zp8ZN7jkeOs6/NuG9UVB2TQ4Az/CVzQ PaWmqfP+ynqOAp+KAE8voNd6IAtpb4vsubVPji1T3uDkRfjudfUaLnoLK4yg8XDHomJN aycQ== 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=HNK6OSlvCajJYHNe0J41j0DLyThzDYUFKtHtR9v3Yd4=; b=EHQqxwV5cZ9s4LTcAUG2Ws0psvcBiQ64tKy9ze1qgiwEsWWGYlFFoUGBkWSXNDpm5w iX6fn7HDL/NnutlGHpNmcT0L3H9Va7S3tTjL4ijMxcJr0s+AbDJ+FEf8QjcxHjU0Ixff VHkg/nDhJFpnY4R6Z8s5EOCfT2vROlhmWDieG8dvdwspXIfXhd1LJBjMZ6jtbohCTzYv aI3f1OtFqxfOIWF+l/uQfIwzRouIWlAgTFkfNwdhQWkBBU7IIkKiv8il+dDfZked19iX Eymass/ayTBRJPtfUZeQvRuIzIkLT1IEJdtZBiu+QOrHUDUSkekwQmGg6jKX/i0LME1v D1wQ== 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 b28si2079008edc.400.2019.10.25.13.10.44; Fri, 25 Oct 2019 13:11:07 -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 S2409281AbfJYMnS (ORCPT + 99 others); Fri, 25 Oct 2019 08:43:18 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:44118 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407216AbfJYMnR (ORCPT ); Fri, 25 Oct 2019 08:43:17 -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 1iNyvz-0008LJ-IN; Fri, 25 Oct 2019 12:43:15 +0000 From: Colin King To: Alexander Viro , Jens Axboe , linux-fsdevel@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] io-wq: fix unintentional integer overflow on left shift Date: Fri, 25 Oct 2019 13:43:15 +0100 Message-Id: <20191025124315.21742-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.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 1U is evaluated with type unsigned int 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: 46134db8fdc5 ("io-wq: small threadpool implementation for io_uring") Signed-off-by: Colin Ian King --- fs/io-wq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/io-wq.c b/fs/io-wq.c index 35e94792d47c..ea5d37193f31 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -228,8 +228,8 @@ static struct io_wq_work *io_get_next_work(struct io_wqe *wqe, unsigned *hash) /* hashed, can run if not already running */ *hash = work->flags >> IO_WQ_HASH_SHIFT; - if (!(wqe->hash_map & (1U << *hash))) { - wqe->hash_map |= (1U << *hash); + if (!(wqe->hash_map & BIT_ULL(*hash))) { + wqe->hash_map |= BIT_ULL(*hash); list_del(&work->list); return work; } -- 2.20.1