Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3493169ioa; Tue, 26 Apr 2022 04:48:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXERMfUwNO+b6uG/taxMZhEfnWZnNzKMXtwQBZMYEsWmg0WWncBT6DDy0qQxVxwnNo+TYS X-Received: by 2002:a17:907:7810:b0:6e7:ef73:8326 with SMTP id la16-20020a170907781000b006e7ef738326mr20583213ejc.429.1650973684941; Tue, 26 Apr 2022 04:48:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650973684; cv=none; d=google.com; s=arc-20160816; b=hNGM1ogLdpG5tjze4HnqIHfGHIHzt7cVbtfLPwUH75v8jY/NUGDuRGEV/h4VxeJBl4 nzhrRD2QMSHwHBnq8G5JthUrTmnYbPHwn9PLWiI/FXMkzIbeK2M8PG0kCbXwtJt0mB+m JNyTd0uKrq5B8emDHfVnMUGuH3rpysgKpnw7HX/IR03g+7PL23xfx8KXyEHZjwyPtAWW wOe5wJih/P7uyKJQNvOFNBZpS4kj7g0yxwvpagE5xAdmDhPrF6LSPk1DnblbeBJn+rxP ug3/dl7/hwdNGM2rOSm0VVrund+v4r34F0i8VNCyViS7p7+Jjjzlvvv0ccpXGD+WOcWz UZRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IGy8m5IrdW6kD/ceZFVCklshtON6AMixqc/k+eCmQtA=; b=LetbnKBWe6RrP06Yvw09SYZoQFcShZDPrO2uLcFtbHL1LmJSlGQ9ZvHZVIGAjZUq63 hh2K8XckaZNFgwH5ueG5tlX+h8YOLNqTkYss81kZfIqL8QNPzGPJhIGtcJ5iqgE3P9sG mmWtupT85vFASUTHbCkc3bnuuV8me7MhrO6CocBjnG5HRdnxKUZN/4kTmIUqKH3JWQtO AIgJ1bDG+NVk1jh3iDcA8yD1EcK2vQUMiDAiBMqz5CgrFviBqjuunju6QrqYVnG4M4e1 KEMBx8InqLSPuvqojGYsTo4ngyTnGmASR6D/65iaZRg1YdVDRgzTZyvlrC00rLfiZlsJ L82w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2FArstRP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g20-20020a170906c19400b006f38d8c0e72si5847532ejz.268.2022.04.26.04.47.40; Tue, 26 Apr 2022 04:48:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2FArstRP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345841AbiDZJWa (ORCPT + 99 others); Tue, 26 Apr 2022 05:22:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345723AbiDZI5o (ORCPT ); Tue, 26 Apr 2022 04:57:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3C563F4; Tue, 26 Apr 2022 01:42:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 259F9B81CFA; Tue, 26 Apr 2022 08:42:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 742FFC385AC; Tue, 26 Apr 2022 08:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962538; bh=5LIZ/1e221/eZNMH009XDwuBO9lGABuwHPc/8OUDcug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2FArstRPAOeV6hDQzNOYLgqYXYBZtCml8HupI7vyNABbDFmlykza6reHq4J9mndNG mU+gjFThFKhwOnyXeAHVUuK6zKVTOssbqpsnZgvgwNQMjyFqWxf0P8140eHqAIK3Jz 4LeLu0EzQ8bW7qiuX9wMzz2IPs1IS9bw4p9dIIFY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Khazhismel Kumykov , Chaitanya Kulkarni , Jens Axboe Subject: [PATCH 5.15 123/124] block/compat_ioctl: fix range check in BLKGETSIZE Date: Tue, 26 Apr 2022 10:22:04 +0200 Message-Id: <20220426081750.784976477@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Khazhismel Kumykov commit ccf16413e520164eb718cf8b22a30438da80ff23 upstream. kernel ulong and compat_ulong_t may not be same width. Use type directly to eliminate mismatches. This would result in truncation rather than EFBIG for 32bit mode for large disks. Reviewed-by: Bart Van Assche Signed-off-by: Khazhismel Kumykov Reviewed-by: Chaitanya Kulkarni Link: https://lore.kernel.org/r/20220414224056.2875681-1-khazhy@google.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/block/ioctl.c +++ b/block/ioctl.c @@ -645,7 +645,7 @@ long compat_blkdev_ioctl(struct file *fi (bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512); case BLKGETSIZE: size = i_size_read(bdev->bd_inode); - if ((size >> 9) > ~0UL) + if ((size >> 9) > ~(compat_ulong_t)0) return -EFBIG; return compat_put_ulong(argp, size >> 9);