Received: by 2002:a05:6a10:87d6:0:0:0:0 with SMTP id g22csp753109pxr; Mon, 11 Apr 2022 06:26:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznr3nu0oF4snM/BowNH9ZDpnEMTFMni3xKB4aNXnoMEMvxb5l1KNQV+qb+awPIbMNg9PHo X-Received: by 2002:aa7:d047:0:b0:41d:57cf:d588 with SMTP id n7-20020aa7d047000000b0041d57cfd588mr14984905edo.172.1649683614906; Mon, 11 Apr 2022 06:26:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649683614; cv=none; d=google.com; s=arc-20160816; b=Spt0adSUD7flIc+YEGDUOvqSqnCwP1O9CIxAuQmA6uUJ2/En5rjPn1W1kz4MWnyaTj LsExu6hGCV/CzwRq0LaK23lkA2BohJvUeUjlRhEd2Vmr7CSpo77ZGnhH5jcbg7IkWFRV neUQgczonjgLcZAL46ptyPr4JqjgHmPfEBUzkvhxXCB1vlU/MS3tGBoH8LhgnS4h76bM mGWbkJSvUZsqmO6jKXxDsB8tfgXcYM3M8YjsIhipu0eRr/c74GkWnZ1sARlazCBaQ+aO 0VKDHpzM48RscASZkpi842vzgGBDBm7AXoXaeu0Ld0aaraKx/m3ShvQXz2rdlkpZO2l7 taJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=xj9rNlmvCUpgWDGEsXJxpVSrmFrkxrjjtQuyonvd5qc=; b=Jv1P4YPiYsUGa4XlIrOYAZvv4Hd3/SCNKMpFGjLPEhVCQxpuvVif4MDMPwwDxBtkym wjIKVmmK8KQ+7GpevO7SD32OfLNFcdu22hQ2wZUzTK2SnW+bDPLF6x9KL6+UcrPTDzPL I4JRo/sldVhI2iizHVG/Q7SAD2+wRmV7I+9xVeViVaHw6HpNSL7E3yJ1+wcTkg2eS0iK VVjtZTanN2LPXm+kqd+xadUkpW9Ca3rt1gbZemt7DDKPguZvKvem8UuphOMa4OziF4QF TYRbMlYNjv18poDAfeEafHREeH5iU1keSEzLaEmHOuwTwx4XruRqsDIFyJ1FjJulnTfU fhLw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg7-20020a170906a04700b006dfad24c60csi5076420ejb.249.2022.04.11.06.26.28; Mon, 11 Apr 2022 06:26:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232341AbiDIVf6 (ORCPT + 99 others); Sat, 9 Apr 2022 17:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbiDIVf4 (ORCPT ); Sat, 9 Apr 2022 17:35:56 -0400 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98B2CEB8; Sat, 9 Apr 2022 14:33:48 -0700 (PDT) Received: by mail-pj1-f51.google.com with SMTP id h23-20020a17090a051700b001c9c1dd3acbso12970806pjh.3; Sat, 09 Apr 2022 14:33:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=xj9rNlmvCUpgWDGEsXJxpVSrmFrkxrjjtQuyonvd5qc=; b=pxgwE7gdypqSf3Nl/KgOQens2ziEPmCPehhJrsikvcaPi541pnOkMOyjrYKMM7OmsG JAHBYYZRYMbQ1LtytJAez/zROFN3iYUo7dMoJr/l261ZQ86ZBxrMrTvUCc0HP0hzUL2E yDqvj1ShFDj7qRyGo8YiEH80hbZsJe1Ipu9ukCND3xinMfZ9UMpNODbffIKutEim+xQO tzbHnwATY5/FNop1iBW5uINgsp0SVaERj4+QvJp1WDB3RAEEK4E9NX4OTW8VrCgf1nt3 wH02r1pDd7viFS+5AN+uXXk3XIneK9oC0y3GLDSmb1QUqHRx6m06Kh+F30TBEiUqwFTG c3tA== X-Gm-Message-State: AOAM530UHsDWJIHvmh3Rm/pw1WG5EhJ/JXeTC6tAN4ZTiWSoJbr+QHma sZoR9ARUkYNMIkkXwQaT+c/rICKaGlo= X-Received: by 2002:a17:902:e791:b0:151:dbbd:aeae with SMTP id cp17-20020a170902e79100b00151dbbdaeaemr25732522plb.171.1649540027613; Sat, 09 Apr 2022 14:33:47 -0700 (PDT) Received: from ?IPV6:2601:647:4000:d7:feaa:14ff:fe9d:6dbd? ([2601:647:4000:d7:feaa:14ff:fe9d:6dbd]) by smtp.gmail.com with ESMTPSA id pf2-20020a17090b1d8200b001c6f65ca66fsm15952799pjb.47.2022.04.09.14.33.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Apr 2022 14:33:46 -0700 (PDT) Message-ID: Date: Sat, 9 Apr 2022 14:33:45 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] block/compat_ioctl: fix range check in BLKGETSIZE Content-Language: en-US To: Khazhismel Kumykov , Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220408234707.2562835-1-khazhy@google.com> From: Bart Van Assche In-Reply-To: <20220408234707.2562835-1-khazhy@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On 4/8/22 16:47, Khazhismel Kumykov wrote: > 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. > > Signed-off-by: Khazhismel Kumykov > --- > block/ioctl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Noticed this one was sitting in my "not landed yet" pile, third time's > the charm? :) > > diff --git a/block/ioctl.c b/block/ioctl.c > index 4a86340133e4..959e93a90b29 100644 > --- a/block/ioctl.c > +++ b/block/ioctl.c > @@ -629,7 +629,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) > 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)0UL)) > return -EFBIG; > return compat_put_ulong(argp, bdev_nr_sectors(bdev)); A nit: the "UL" and two parentheses can be left out. Anyway: Reviewed-by: Bart Van Assche