From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB9A4481DB; Mon, 1 Apr 2024 16:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711989720; cv=none; b=i4elPLNoNh2kmah4SiMrw7wmAsaPSldVf6lEMRy6C9KeKNC7LFG2R2RE7D7Vu1I/fu19f5ph6vTI9Z0gWrnP9RqMprlyHc9EnPXvhBXp/1V6yD0ldCRHC6/W6RzdkXGplWdU9vfc/LzumOnV0GTDr2KPorVdeWmPIjza8UcOzlI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711989720; c=relaxed/simple; bh=IefdcLszcTYQxawuvRjFNn9Wee+bOt06ubXblE9PL1M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=keubNq4NPRQbhdaGHMe0htgTiyPLXI8EpAH1q/0+3vStqXXUTt11zKgTSvICWJDyck3CNVK0cFLGKz6tDdpOssci45y7JvdWA877QbciDBSJEwKO0tmhnC+GdQjZv2AvhmLb77dGSnlgbmyXtBPNQiCreKvl7GFzAsS5PNWmevY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ry1uef9a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Ry1uef9a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA2DAC433C7; Mon, 1 Apr 2024 16:41:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711989720; bh=IefdcLszcTYQxawuvRjFNn9Wee+bOt06ubXblE9PL1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ry1uef9aylEXoFoxMQaK2Op4HDJyJTeWM1C/LSC7ZbKiT+PITUC6HkFtBgoej1jlg JhbK3ql3WVd69f6X0/W01e87Di2IWH7VPnZNzhFmtxfD1P5lvFUBIjSlSHmDVD6IIZ QksIMa1oRD8jaeVZACHTI3jM2ZTCwv2U0rv6q7Vo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marios Makassikis , Namjae Jeon , Steve French , Sasha Levin Subject: [PATCH 6.6 133/396] ksmbd: retrieve number of blocks using vfs_getattr in set_file_allocation_info Date: Mon, 1 Apr 2024 17:43:02 +0200 Message-ID: <20240401152551.881604389@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152547.867452742@linuxfoundation.org> References: <20240401152547.867452742@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marios Makassikis [ Upstream commit 34cd86b6632718b7df3999d96f51e63de41c5e4f ] Use vfs_getattr() to retrieve stat information, rather than make assumptions about how a filesystem fills inode structs. Cc: stable@vger.kernel.org Signed-off-by: Marios Makassikis Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/smb/server/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index f6cc5d2730ffb..199c31c275e5b 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -5809,15 +5809,21 @@ static int set_file_allocation_info(struct ksmbd_work *work, loff_t alloc_blks; struct inode *inode; + struct kstat stat; int rc; if (!(fp->daccess & FILE_WRITE_DATA_LE)) return -EACCES; + rc = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS, + AT_STATX_SYNC_AS_STAT); + if (rc) + return rc; + alloc_blks = (le64_to_cpu(file_alloc_info->AllocationSize) + 511) >> 9; inode = file_inode(fp->filp); - if (alloc_blks > inode->i_blocks) { + if (alloc_blks > stat.blocks) { smb_break_all_levII_oplock(work, fp, 1); rc = vfs_fallocate(fp->filp, FALLOC_FL_KEEP_SIZE, 0, alloc_blks * 512); @@ -5825,7 +5831,7 @@ static int set_file_allocation_info(struct ksmbd_work *work, pr_err("vfs_fallocate is failed : %d\n", rc); return rc; } - } else if (alloc_blks < inode->i_blocks) { + } else if (alloc_blks < stat.blocks) { loff_t size; /* -- 2.43.0