Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4464973ioa; Wed, 27 Apr 2022 04:35:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnND1KlZA4ssmNkyFhcRMDiYLEqfjtSv4w4qx4/ml7G3YDZay1SCNVxeH1ki9fceLNvQWI X-Received: by 2002:a05:6a00:238b:b0:50d:7e99:86d4 with SMTP id f11-20020a056a00238b00b0050d7e9986d4mr3533357pfc.8.1651059326989; Wed, 27 Apr 2022 04:35:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651059326; cv=none; d=google.com; s=arc-20160816; b=aYIVSygIgJqWZRqQ7rqNhzGPLWTg4PUJLunUCmdDjgCV3KitkKEBIhRoeknFlIVGUz dQfAhFVK23yiCVlbbz1S0aRQhMgDglPyxTItpnW/fl+jj4JkevbSeOr2N63ujjqk5H+r MNDToeg3i028rmMrW26FyqI9tkW/XSWQ/RC+P7E8OhApKu8w8XB5uqjj6Sn/Og6fvO7S VocFIwWFDXcG/2ZyiB2MKb3Pibyh1tptn6riWj+N/EbibR/DOBY3UXKOvcPQ+ZKUM7Hd YITJ/TzYQ1arIeQ6kizFsy6LZd38Q444tqSHj4A4BkAdux9u/vBSyBzBwFAddMKvNKdT pCzw== 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=lkVHpDmUFSL7XHsQaCfZfnA7FjUWJQJfGey04njcbzU=; b=iaCHmoDTfYG7jL+BSEi2NlROa6zngBYnpoYE+bb3/DKwiZ8JnCKOx/2fZYsIGhBJE3 pFDrjTm+3/VTUqPRd+0oOyCTwfM+HpPkttug0eJVt1/i9bXcvBnkG9ax86Zk6rjsKSrY OEOQaPkQ0Af44dogRj1JV+01i3blSfpO8VeQ4Od6Z8Eh2RwKY37DrQ+mXE6sYxyl7Ws1 wCZULE6oF3mLeCeyLYoHSLVNtkb52qWRXBv4IV4sbna1GLuPuHulayqStL16y4qz94zv VKfbdvzSPJa9xCnPbX65iJW5yLUcCMEs19HyGDWsZUjdQCZnEwxJEIBfm7Df8sg+/0Uu l/cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Da4WgEYi; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d3-20020a170902aa8300b0015d07fa22edsi1295351plr.182.2022.04.27.04.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:35:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Da4WgEYi; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 22F1A44BAF0; Wed, 27 Apr 2022 03:24:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347699AbiDZJYg (ORCPT + 99 others); Tue, 26 Apr 2022 05:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345700AbiDZI5o (ORCPT ); Tue, 26 Apr 2022 04:57:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2762564C4; Tue, 26 Apr 2022 01:42:47 -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 D1A12B81CED; Tue, 26 Apr 2022 08:42:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3511CC385A0; Tue, 26 Apr 2022 08:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962564; bh=J+4i1vcd5/XjbgPWY6oEshrMLJ1WCfrhyL0vvFwQMNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Da4WgEYiKXmnPFimqfHP0eQYS+QLQ3jfYEgt7pPOBicZBL1tIXBo4yZyvE0oDx6ii Cck24CtF1hVAJdRwshG+zW4RGh7h0eWfopREq2APsZrYbhFc4/DEKtahumjXhbJcSN eTVkG604nLAQsFJfjhe4OWNgR0mLsvgX4q2vUWN8= 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.17 004/146] block/compat_ioctl: fix range check in BLKGETSIZE Date: Tue, 26 Apr 2022 10:19:59 +0200 Message-Id: <20220426081750.184589989@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081750.051179617@linuxfoundation.org> References: <20220426081750.051179617@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=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 @@ -629,7 +629,7 @@ long compat_blkdev_ioctl(struct file *fi return compat_put_long(argp, (bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512); case BLKGETSIZE: - if (bdev_nr_sectors(bdev) > ~0UL) + if (bdev_nr_sectors(bdev) > ~(compat_ulong_t)0) return -EFBIG; return compat_put_ulong(argp, bdev_nr_sectors(bdev));