Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3797869rwa; Tue, 23 Aug 2022 10:15:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR4YtKZ4MaYnyPyZt2K29HL0H/XUb93rOUonBueqmHpIRWbk0l8m1OPKSApXdu2zEb1jqTz8 X-Received: by 2002:a62:bd03:0:b0:536:150c:a1c0 with SMTP id a3-20020a62bd03000000b00536150ca1c0mr20510171pff.19.1661274906439; Tue, 23 Aug 2022 10:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661274906; cv=none; d=google.com; s=arc-20160816; b=BIkCp226QFfHZRZ8NgFvJIPOMf8O0bi+tnelCvCcBzIEfdcBZb91aJisQQYWHcUY6R mU3E6Bs2wy/u091X3D+q3q41Ody0bmYboLJD2DKSY5ldk45PYhhRzUSqHJ12THNn1KF5 P7OuowoIw1rTZLKJbc1Q9rs3x3zRhI2DTzT1dVKhBCswCgB3hpqQH253rUHo+x1cVOnD xLuWkYAz1MHPj5hrWu1z77uSuop5YV4bOe3Rk3bi9hI8S25AEQr+XyubLdxFFo14xAsb ifOlrcnv0SvXmlxR7gX6M0YJnBBXL6QcE5ehA1Vkf1SPeGOMnBNxT/pEJcNq20zTr5i2 +6xA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=u6WCJy76wyGRQ/+mlD3iaHvNl3EBMPU7sOD/gN0Mivg=; b=wsZ54pcSDZESmEuzs7OsO02NeDJVDUXrjwJzafhfdC4NGJKOLuMu+Np4tAR78tR30H OiMOM2oGnG1221le6n/XqIIVFLhC8dQu38wlSYQZgHrj7jqTZqYqqQekZrl3D5pITTTV NsqVEwGN9z+/dIA4mPjF0Qc/IZfFUUEjGwz3GrGBMARdZWYe+hrRll+0RD+oVBd/1WgX siTYrM9hi9fRopNBfS3t9V93ORDstQqeetbr38kd9ZkIPDMaaXc/KPC98HbMS1NrVg/k ty0s5h+1sMby8nfjAW3wN+kgESmjP4ssC1Kl+EirDKPHhlxLforwoSp0i5aR+9u1qM0s M17A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="CNj0dw/l"; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a170903110d00b0016c4fc2de44si14156538plh.456.2022.08.23.10.14.54; Tue, 23 Aug 2022 10:15:06 -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=@redhat.com header.s=mimecast20190719 header.b="CNj0dw/l"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245031AbiHWQhK (ORCPT + 99 others); Tue, 23 Aug 2022 12:37:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244871AbiHWQgr (ORCPT ); Tue, 23 Aug 2022 12:36:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B52BFB5E46 for ; Tue, 23 Aug 2022 07:46:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661265993; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=u6WCJy76wyGRQ/+mlD3iaHvNl3EBMPU7sOD/gN0Mivg=; b=CNj0dw/lFaqDH06AHqq+ZjJDgZG2r/QuQYF0swIMDMCMzfJU7U2UCpALbBgI2MpoXhphJX cVOLLqgpZTsIj1RfIl6D2VT051irZP02+GMB/piLHbCRZz14IaRGn1VFugDzPZU3mdNrcE yOrn3SUC6ZxJvwppdWPNTdYdqZs0KYk= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-574-1Vcdei84NZeZqvq4WW8sOw-1; Tue, 23 Aug 2022 10:46:32 -0400 X-MC-Unique: 1Vcdei84NZeZqvq4WW8sOw-1 Received: by mail-pl1-f200.google.com with SMTP id h12-20020a170902f54c00b0016f8858ce9bso9133146plf.9 for ; Tue, 23 Aug 2022 07:46:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=u6WCJy76wyGRQ/+mlD3iaHvNl3EBMPU7sOD/gN0Mivg=; b=rkq1zKm5usTBxt8zVTJogubBPITDLdiSY9uRng6QX/H7K1NMcAHr/j2+NEfHj+CvDo kp/JIdfG+cdn3XS7frqDI5advKo5qUrtjvXF8Mwoq/LqhM5YRgORYBzmvLnwTRH1aAU/ bxQfTGF4wk/J0JMwKQr697cBHj+O9QVzhWmyjl+lwtnZf3DkR8f9h0yykUI+ERsysJ82 8Hutz1KQ41eKmhxEVMvl0uGQsrCv1KPykuVWLty4v6cogHCmSkCNtho97nzLBQPZdomO URCHARTla5USoKw3Fj4QKWMfBzvdNV7sfUkVtiqEcMQVOug5kRukBrPdSob26YDOJi1U BvPQ== X-Gm-Message-State: ACgBeo3uxWbGz28epzaYy2N+lQRjB/7jqlNdOD7VK3bPgl6l8hVjhJ7/ /PvGoQusb54ctqZYdavJvD9yvhfmrwsd7aWiW/GukVUuhBbeg86F++60chrUIpPeaf7FBDenUCV LQ0E3xsHCJwhz8Yi7LaT06dmQ X-Received: by 2002:a17:90a:bc47:b0:1fa:e634:739c with SMTP id t7-20020a17090abc4700b001fae634739cmr3595504pjv.120.1661265991316; Tue, 23 Aug 2022 07:46:31 -0700 (PDT) X-Received: by 2002:a17:90a:bc47:b0:1fa:e634:739c with SMTP id t7-20020a17090abc4700b001fae634739cmr3595488pjv.120.1661265991087; Tue, 23 Aug 2022 07:46:31 -0700 (PDT) Received: from xps13.. ([240d:1a:c0d:9f00:4f2f:926a:23dd:8588]) by smtp.gmail.com with ESMTPSA id l63-20020a622542000000b00535e49245d6sm10519824pfl.12.2022.08.23.07.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 07:46:30 -0700 (PDT) From: Shigeru Yoshida To: almaz.alexandrovich@paragon-software.com Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org, Shigeru Yoshida , "Author : Randy Dunlap" , syzbot+35b87c668935bb55e666@syzkaller.appspotmail.com Subject: [PATCH] fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst() Date: Tue, 23 Aug 2022 23:46:25 +0900 Message-Id: <20220823144625.1627736-1-syoshida@redhat.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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 syzbot reported UBSAN error as below: [ 76.901829][ T6677] ================================================================================ [ 76.903908][ T6677] UBSAN: shift-out-of-bounds in fs/ntfs3/super.c:675:13 [ 76.905363][ T6677] shift exponent -247 is negative This patch avoid this error. Link: https://syzkaller.appspot.com/bug?id=b0299c09a14aababf0f1c862dd4ebc8ab9eb0179 Fixes: a3b774342fa7 (fs/ntfs3: validate BOOT sectors_per_clusters) Cc: Author: Randy Dunlap Reported-by: syzbot+35b87c668935bb55e666@syzkaller.appspotmail.com Signed-off-by: Shigeru Yoshida --- fs/ntfs3/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 47012c9bf505..adc4f73722b7 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 << -(s8)boot->sectors_per_clusters; return -EINVAL; } -- 2.37.2