Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4175747rwb; Tue, 20 Sep 2022 09:49:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5l21MkAXMSaRKs3RRCDEp7Gn7iDzgNsRP7rYCTxjkRdMxqn1UCaKi5JyhadWuYTEEmhGs5 X-Received: by 2002:a05:6a00:180a:b0:540:a7f6:4393 with SMTP id y10-20020a056a00180a00b00540a7f64393mr24976369pfa.65.1663692594445; Tue, 20 Sep 2022 09:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663692594; cv=none; d=google.com; s=arc-20160816; b=nuIA3PwDryvEfMGUrU/CQvGpWTxgiw6bKsYnG0sN4PPKIpMTH9O4tvl2qwe0D7CXOc o+ULayL0AHcaf0OhvE/eWHAEi6fP4pc2nMmZUMmUwBBCn58Bpy1vJ8soBYgTMB+YHf80 Ai9fV6UZNrpoIdwqAFaU3KKGJngYb6X3DQLGOaoFtBGpZTugxeGEGBiwP0wU3gJ0qKYk fSEd0pSp9++efg9U8Ywem1x2zV6mSJ0x031Ylp2v7rltCg8yLJu9WRbC8lrY9def3he/ X/niEw1EYu42q+LCf1zAXslm1wFXIgz0HfwcDP2kwmBW4F/pfYV1miXcabtxZlfMGgLQ G5iQ== 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:cc :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=WP8fd74pfXTdzJSotMJ6VmMR/tKsDyQGZxQsMInpNTw=; b=qNUE5NL+qx8GKTcFFnN4TW6xm47s2GOTwoNkQB/sE+VC8+4mrmQVfVGrTPFxb1Iaz8 2Pxd7rCETPxEaOJjPIxjOBhFdq+L7+VUUA6ez9w4v3K1x6iz9PuxeO3zbWeG4ZEONN3X 0MT6QngA04Nr/1XFse1UQKhAxVKH8GwRC3/aZiTgWy/9KT6CfS9kd+kPszSjg6L+5caX 98+0DJt84762C6FpS428VQ59RsDGzcpuK86THHqPsdgib+m31kWYykzHT59sKVNypi52 4XWalqwGlkeex9lXH9H3e4MgwA+Klr3/h/K36uoqPowIdV9K3quETOT93RwNi7aAc8AX vQ9Q== 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 n8-20020a63f808000000b00439f026cf5dsi170929pgh.612.2022.09.20.09.49.42; Tue, 20 Sep 2022 09:49: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 S229676AbiITP7g (ORCPT + 99 others); Tue, 20 Sep 2022 11:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiITP7e (ORCPT ); Tue, 20 Sep 2022 11:59:34 -0400 Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 646AAD9A for ; Tue, 20 Sep 2022 08:59:32 -0700 (PDT) Received: from fsav119.sakura.ne.jp (fsav119.sakura.ne.jp [27.133.134.246]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 28KFxUm8092946; Wed, 21 Sep 2022 00:59:30 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav119.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav119.sakura.ne.jp); Wed, 21 Sep 2022 00:59:30 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav119.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 28KFxTq7092942 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Wed, 21 Sep 2022 00:59:30 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: <4b37f037-3b10-b4e4-0644-73441c8fa0af@I-love.SAKURA.ne.jp> Date: Wed, 21 Sep 2022 00:59:27 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: [PATCH] fs/ntfs3: fix negative shift size in true_sectors_per_clst() Content-Language: en-US To: Konstantin Komarov , Andrew Morton , Namjae Jeon , Randy Dunlap References: <000000000000f8b5ef05dd25b963@google.com> Cc: syzbot , syzkaller-bugs@googlegroups.com, ntfs3@lists.linux.dev, LKML From: Tetsuo Handa In-Reply-To: <000000000000f8b5ef05dd25b963@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 syzbot is reporting shift-out-of-bounds in true_sectors_per_clst() [1], for commit a3b774342fa752a5 ("fs/ntfs3: validate BOOT sectors_per_clusters") did not address that (0 - boot->sectors_per_clusters) < 0 because "u8" was chosen for type of boot->sectors_per_clusters because 0x80 needs to be positive in order to support 64K clusters. Use "s8" cast in order to make sure that (0 - (s8) boot->sectors_per_clusters) > 0. Link: https://syzkaller.appspot.com/bug?extid=1631f09646bc214d2e76 [1] Reported-by: syzbot Signed-off-by: Tetsuo Handa Tested-by: syzbot Fixes: a3b774342fa752a5 ("fs/ntfs3: validate BOOT sectors_per_clusters") diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 47012c9bf505..c7ffd21fb255 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -672,7 +672,7 @@ static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot) if (boot->sectors_per_clusters <= 0x80) return boot->sectors_per_clusters; if (boot->sectors_per_clusters >= 0xf4) /* limit shift to 2MB max */ - return 1U << (0 - boot->sectors_per_clusters); + return 1U << (0 - (s8) boot->sectors_per_clusters); return -EINVAL; } -- 2.18.4