From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97D53C433E1 for ; Wed, 19 Aug 2020 12:17:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 776012075E for ; Wed, 19 Aug 2020 12:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597839439; bh=MpRFopvD/hrFxRwqGZ20/I6x6gVn2niYzhbQaY8ogl8=; h=Subject:To:Cc:From:Date:List-ID:From; b=unqEe6wjt+MP37IWknW7bO29vb2V/Pp0M+6MfHFmZ+wqMTDv/IaTYcZDXSocLiHMb wg2EcCara0WafXToOPyYfYw7GCJFF1tYQj3OXzzcy8sSTrzU5/33FfY0Dj7Qe938Iz u+tJgfFmIPs5jc9uQ3w4nRVOiTP5pswb9KuISogc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726794AbgHSMRT (ORCPT ); Wed, 19 Aug 2020 08:17:19 -0400 Received: from wforward3-smtp.messagingengine.com ([64.147.123.22]:58107 "EHLO wforward3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727944AbgHSMRN (ORCPT ); Wed, 19 Aug 2020 08:17:13 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailforward.west.internal (Postfix) with ESMTP id C739DA13; Wed, 19 Aug 2020 08:17:11 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 19 Aug 2020 08:17:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=VXwQ70 v9AI9FSzOoPBjyFYBjplHzcIhdGM/Av7dL84c=; b=gksUbhxcfNDJDDT3iiBbm9 7GxYLYnguHWCocpUw8v+SvzaGLlmfkuhAl1LqHR1ZLFbYFFhzEChGLYDOGWb2L4W 0cjSTVVk2FtoOlRG+wmy9OZ+9k2s7tzeKrlaF33lrc7mVIY+s2a5DnKpiYWhCRTv nH+qWkJ2GxkbWQeDQiVCOafHmzOF9m/gnRZwmX6m/eH9MCgmqa6lOcmUQhEHO7xh 1xczwXgjl4ajwTfxaCbkryNauLdaw3T2+vFgNeygaJiye9ff/IJzhmlOS05A9uWw yUtoSUjVwQCHlgqqtiqhM4g6EleisTqFV1Hz4hLXlvhWVRVSOFSVryfr41tFOXbQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedruddtkedgfeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefuvffhfffkgggtgfesthekredttd dtlfenucfhrhhomhepoehgrhgvghhkhheslhhinhhugihfohhunhgurghtihhonhdrohhr gheqnecuggftrfgrthhtvghrnhepgfehgeeiteeufeekfeffffegjeevteejkeekgfejud efieduueduveegjefhudeinecuffhomhgrihhnpehrvgguhhgrthdrtghomhenucfkphep keefrdekiedrkeelrddutdejnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpe hmrghilhhfrhhomhepghhrvghgsehkrhhorghhrdgtohhm X-ME-Proxy: Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) by mail.messagingengine.com (Postfix) with ESMTPA id 1743D30600B1; Wed, 19 Aug 2020 08:17:10 -0400 (EDT) Subject: FAILED: patch "[PATCH] bcache: avoid nr_stripes overflow in bcache_device_init()" failed to apply to 5.4-stable tree To: colyli@suse.de, axboe@kernel.dk, raeburn@redhat.com Cc: From: Date: Wed, 19 Aug 2020 14:17:26 +0200 Message-ID: <1597839446156203@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 65f0f017e7be8c70330372df23bcb2a407ecf02d Mon Sep 17 00:00:00 2001 From: Coly Li Date: Sat, 25 Jul 2020 20:00:21 +0800 Subject: [PATCH] bcache: avoid nr_stripes overflow in bcache_device_init() For some block devices which large capacity (e.g. 8TB) but small io_opt size (e.g. 8 sectors), in bcache_device_init() the stripes number calcu- lated by, DIV_ROUND_UP_ULL(sectors, d->stripe_size); might be overflow to the unsigned int bcache_device->nr_stripes. This patch uses the uint64_t variable to store DIV_ROUND_UP_ULL() and after the value is checked to be available in unsigned int range, sets it to bache_device->nr_stripes. Then the overflow is avoided. Reported-and-tested-by: Ken Raeburn Signed-off-by: Coly Li Cc: stable@vger.kernel.org Link: https://bugzilla.redhat.com/show_bug.cgi?id=1783075 Signed-off-by: Jens Axboe diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 4a77bfd4009f..0f90616dc8d3 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -835,19 +835,19 @@ static int bcache_device_init(struct bcache_device *d, unsigned int block_size, struct request_queue *q; const size_t max_stripes = min_t(size_t, INT_MAX, SIZE_MAX / sizeof(atomic_t)); - size_t n; + uint64_t n; int idx; if (!d->stripe_size) d->stripe_size = 1 << 31; - d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size); - - if (!d->nr_stripes || d->nr_stripes > max_stripes) { - pr_err("nr_stripes too large or invalid: %u (start sector beyond end of disk?)\n", - (unsigned int)d->nr_stripes); + n = DIV_ROUND_UP_ULL(sectors, d->stripe_size); + if (!n || n > max_stripes) { + pr_err("nr_stripes too large or invalid: %llu (start sector beyond end of disk?)\n", + n); return -ENOMEM; } + d->nr_stripes = n; n = d->nr_stripes * sizeof(atomic_t); d->stripe_sectors_dirty = kvzalloc(n, GFP_KERNEL);