From patchwork Fri Apr 6 22:23:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Khazhy Kumykov X-Patchwork-Id: 10327641 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A34760545 for ; Fri, 6 Apr 2018 22:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1070A20700 for ; Fri, 6 Apr 2018 22:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00A8727FAC; Fri, 6 Apr 2018 22:25:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY, MIME_NO_TEXT,RCVD_IN_DNSWL_HI,T_TVD_MIME_NO_HEADERS autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8751920700 for ; Fri, 6 Apr 2018 22:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752090AbeDFWZM (ORCPT ); Fri, 6 Apr 2018 18:25:12 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:44054 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751779AbeDFWZL (ORCPT ); Fri, 6 Apr 2018 18:25:11 -0400 Received: by mail-pl0-f68.google.com with SMTP id b6-v6so1453161pla.11 for ; Fri, 06 Apr 2018 15:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=rgdi/lfugWOvmhDM/A8CSYsSFTIET2iHmWyWJ9I0jKA=; b=jv+xXeA0uDFYu4Iowzi9FbnfARY/zxRHWYf/2n9pvd6xk/gC5+n0n58Dzx9VShYopt uT8Se4zvCg2xFL/6+YY3fLTN4pB+kbLNKp+T28varCpqPYO4NThxL8R4BTGcfaNetIEu AwQSf+czZ4fmFhL1O3Kh4XGvihyHvaiNbvkoQepzfv1FavvBlDVtgsztSS90YScEpC5I ZlIFxCqbNDCgrRANBoJSk66wfS/8PxoDWGQpQGrDFOAwYd0002D8haULpxI7pIe6RvQn jCO5xur2FinD/6Mw2AseUk4bojwwFEw0s0glUB5bfP58JQyzFYL0T1Jpfh//kHTape5J nYjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rgdi/lfugWOvmhDM/A8CSYsSFTIET2iHmWyWJ9I0jKA=; b=pGRRViG/5KkKZBXhqvuCX19/Ei5f9k20kuqxXG+BJTnTPP7k4lxkNGnkXUdGGU2aXo 5ziOHWkI6SETNt8QqAzI8VpbAK08n3YndJ0MPsjUcKgaa3HIDqffmw2hvQ8q03qKUN0E lX+M/hhNM+gVreTfM/RwFg/CKwX74kxXCG61GzC0Sawttfy/8bP+TKUp5FzAhDojpu+G 5+n535tyLq1ru53e4gZiZSbrSm0p+5NU0UnykuSbAnSTb1DEXFpqgWmoVqnRlzz8wtO5 DVbaLJm7YsyG4Z1h2CO2EqHNVUL72HHbsC+JcNa4aA6pOupP4BNepgb6Z5kK4ummol2B itFQ== X-Gm-Message-State: AElRT7FZzBUaW/0mMAIoD8StPikMajsomBQtpui64B1KTvkURPzYNDru O0dkcqDM9rGf+Kw718NMifdrMA== X-Google-Smtp-Source: AIpwx4+bP14+2pL1PcLijI9lwy2R0zgP6m9XlmXzeQ23wMJM4/SIbgb5Qnt9+51/BdlX5Mz9u8TThQ== X-Received: by 2002:a17:902:4d45:: with SMTP id o5-v6mr29900902plh.84.1523053510839; Fri, 06 Apr 2018 15:25:10 -0700 (PDT) Received: from khazhy.svl.corp.google.com ([2620:15c:2cd:203:478f:57ef:e0f2:999d]) by smtp.gmail.com with ESMTPSA id b73sm19190466pga.62.2018.04.06.15.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 15:25:09 -0700 (PDT) From: Khazhismel Kumykov To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Khazhismel Kumykov Subject: [PATCH] block/compat_ioctl: fix range check in BLKGETSIZE Date: Fri, 6 Apr 2018 15:23:50 -0700 Message-Id: <20180406222350.174104-1-khazhy@google.com> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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/compat_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 6ca015f92766..3a2c77f07da8 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c @@ -388,7 +388,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) return 0; case BLKGETSIZE: size = i_size_read(bdev->bd_inode); - if ((size >> 9) > ~0UL) + if ((size >> 9) > ~((compat_ulong_t)0UL)) return -EFBIG; return compat_put_ulong(arg, size >> 9);