Skip to contentSkip to conversation

bfs: add sanity check at bfs_fill_super()

PATCH Tigran Aivazian 1 participant 1 message Nov 15, 2018 15 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20181102224842.GHpbNSpGO%[email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAK+_RL=AYjER8ykh17b01ffp9BUnoTH5JRyELP+gnn1RS_+Y7Q@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CAHk-=wgz=bxLkDJxTjj6r05i6XkUYdJoEDSx5Q+x1XJcrrmcug@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAK+_RLmBA5gcvCySB+g=8cgEpJE8andqE7o7-zJBvxexeOJJ1g@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAHk-=wgrUhjp8vOMBykbSSW1qg7vOUWSFLogf8-3RfYuFt8Zdg@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAK+_RLkmh=eiMSx4oxUg+wWvZtyDRBbiY=BZKn04N1mpYd1qkQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAK+_RLkvYY-EO5OF4H75r+J5A=knD_FsTSRUBEhkshW=tHJ5Xg@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAHk-=wj9dR3Xe8gXOY+=MX=ya1gS+k8VzLzZxfW4j3+OuWAmNg@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAK+_RL=V+JRQjZikQ0JiqmHkWo1D0RvT-cLecBNv1kMyr3YRrg@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAHk-=wi0XkT8Em9J_TE+zT8Y5jm42ASLtwOyr0+wt8p0OCTr-w@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAK+_RLkBdzky0gB5XOaVkPrAAR0m03atJFrQ=UvBFTgMNqRaLw@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CAK+_RLko_OegOzySKHqyfkWMZG18nL3kcQ_QB4JrNo2O3at-xQ@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): [email protected]

#15 lore raw
Quoted 2 lines · Andrew Morton

Can you please resend it in the usual fashion? Changelogged, signed off, mailing list cc's etc?

Yes, sure, here it is again, attached both the 4.19.2 and 4.20-rc1 versions. It did (and still does) include the ChangeLog text, "Signed-off-by:" line and diffstat output. And now I've also cc'd the linux-kernel mailing list.

Kind regards,
Tigran

From: Tigran Aivazian <[email protected]>
Subject: bfs: extra sanity checking and static inode bitmap

Strengthen validation of BFS superblock against corruption. Make in-core inode bitmap static part of superblock info structure. Print a warning when mounting a BFS filesystem created with "-N 512" option as only 510 files can be created in the root directory. Make the kernel messages more uniform. Update the 'prefix' passed to bfs_dump_imap() to match the current naming of operations. White space and comments cleanup.

---

 fs/bfs/bfs.h                |   11 ++++++-
 fs/bfs/dir.c                |    4 +-
 fs/bfs/file.c               |    2 -
 fs/bfs/inode.c              |   65 ++++++++++++++++++--------------------------
 include/uapi/linux/bfs_fs.h |    2 -
 5 files changed, 41 insertions(+), 43 deletions(-)
uapi/linux/bfs_fs.h renamed from uapi/linux/bfs_fs.h.0 +1 -1
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 /*
  *	include/linux/bfs_fs.h - BFS data structures on disk.
- *	Copyright (C) 1999 Tigran Aivazian <[email protected]>
+ *	Copyright (C) 1999-2018 Tigran Aivazian <[email protected]>
  */
 
 #ifndef _LINUX_BFS_FS_H
bfs/bfs.h renamed from bfs/bfs.h.0 +9 -2
@@ -1,13 +1,20 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  *	fs/bfs/bfs.h
- *	Copyright (C) 1999 Tigran Aivazian <[email protected]>
+ *	Copyright (C) 1999-2018 Tigran Aivazian <[email protected]>
  */
 #ifndef _FS_BFS_BFS_H
 #define _FS_BFS_BFS_H
 
 #include <linux/bfs_fs.h>
 
+/* In theory BFS supports up to 512 inodes, numbered from 2 (for /) up to 513 inclusive.
+   In actual fact, attempting to create the 512th inode (i.e. inode No. 513 or file No. 511)
+   will fail with ENOSPC in bfs_add_entry(): the root directory cannot contain so many entries, counting '..'.
+   So, mkfs.bfs(8) should really limit its -N option to 511 and not 512. For now, we just print a warning
+   if a filesystem is mounted with such "impossible to fill up" number of inodes */
+#define BFS_MAX_LASTI	513
+
 /*
  * BFS file system in-core superblock info
  */
@@ -17,7 +24,7 @@
 	unsigned long si_freei;
 	unsigned long si_lf_eblk;
 	unsigned long si_lasti;
-	unsigned long *si_imap;
+	DECLARE_BITMAP(si_imap, BFS_MAX_LASTI+1);
 	struct mutex bfs_lock;
 };
 
bfs/inode.c renamed from bfs/inode.c.0 +28 -37

176 lines not on this page · raw message

bfs/dir.c renamed from bfs/dir.c.0 +2 -2
@@ -2,8 +2,8 @@
 /*
  *	fs/bfs/dir.c
  *	BFS directory operations.
- *	Copyright (C) 1999,2000  Tigran Aivazian <[email protected]>
- *      Made endianness-clean by Andrew Stribblehill <[email protected]> 2005
+ *	Copyright (C) 1999-2018  Tigran Aivazian <[email protected]>
+ *  Made endianness-clean by Andrew Stribblehill <[email protected]> 2005
  */
 
 #include <linux/time.h>
bfs/file.c renamed from bfs/file.c.0 +1 -1
@@ -2,7 +2,7 @@
 /*
  *	fs/bfs/file.c
  *	BFS file operations.
- *	Copyright (C) 1999,2000 Tigran Aivazian <[email protected]>
+ *	Copyright (C) 1999-2018 Tigran Aivazian <[email protected]>
  *
  *	Make the file block allocation algorithm understand the size
  *	of the underlying block device.

From: Tigran Aivazian <[email protected]>
Subject: bfs: extra sanity checking and static inode bitmap

Strengthen validation of BFS superblock against corruption. Make in-core inode bitmap static part of superblock info structure. Print a warning when mounting a BFS filesystem created with "-N 512" option as only 510 files can be created in the root directory. Make the kernel messages more uniform. Update the 'prefix' passed to bfs_dump_imap() to match the current naming of operations. White space and comments cleanup.

---

 fs/bfs/bfs.h                |   11 ++++++-
 fs/bfs/dir.c                |    4 +-
 fs/bfs/file.c               |    2 -
 fs/bfs/inode.c              |   66 ++++++++++++++++++++------------------------
 include/uapi/linux/bfs_fs.h |    2 -
 5 files changed, 43 insertions(+), 42 deletions(-)
uapi/linux/bfs_fs.h renamed from uapi/linux/bfs_fs.h.0 +1 -1
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 /*
  *	include/linux/bfs_fs.h - BFS data structures on disk.
- *	Copyright (C) 1999 Tigran Aivazian <[email protected]>
+ *	Copyright (C) 1999-2018 Tigran Aivazian <[email protected]>
  */
 
 #ifndef _LINUX_BFS_FS_H
bfs/bfs.h renamed from bfs/bfs.h.0 +9 -2
@@ -1,13 +1,20 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  *	fs/bfs/bfs.h
- *	Copyright (C) 1999 Tigran Aivazian <[email protected]>
+ *	Copyright (C) 1999-2018 Tigran Aivazian <[email protected]>
  */
 #ifndef _FS_BFS_BFS_H
 #define _FS_BFS_BFS_H
 
 #include <linux/bfs_fs.h>
 
+/* In theory BFS supports up to 512 inodes, numbered from 2 (for /) up to 513 inclusive.
+   In actual fact, attempting to create the 512th inode (i.e. inode No. 513 or file No. 511)
+   will fail with ENOSPC in bfs_add_entry(): the root directory cannot contain so many entries, counting '..'.
+   So, mkfs.bfs(8) should really limit its -N option to 511 and not 512. For now, we just print a warning
+   if a filesystem is mounted with such "impossible to fill up" number of inodes */
+#define BFS_MAX_LASTI	513
+
 /*
  * BFS file system in-core superblock info
  */
@@ -17,7 +24,7 @@
 	unsigned long si_freei;
 	unsigned long si_lf_eblk;
 	unsigned long si_lasti;
-	unsigned long *si_imap;
+	DECLARE_BITMAP(si_imap, BFS_MAX_LASTI+1);
 	struct mutex bfs_lock;
 };
 
bfs/dir.c renamed from bfs/dir.c.0 +2 -2
@@ -2,8 +2,8 @@
 /*
  *	fs/bfs/dir.c
  *	BFS directory operations.
- *	Copyright (C) 1999,2000  Tigran Aivazian <[email protected]>
- *      Made endianness-clean by Andrew Stribblehill <[email protected]> 2005
+ *	Copyright (C) 1999-2018 Tigran Aivazian <[email protected]>
+ *  Made endianness-clean by Andrew Stribblehill <[email protected]> 2005
  */
 
 #include <linux/time.h>
bfs/file.c renamed from bfs/file.c.0 +1 -1
@@ -2,7 +2,7 @@
 /*
  *	fs/bfs/file.c
  *	BFS file operations.
- *	Copyright (C) 1999,2000 Tigran Aivazian <[email protected]>
+ *	Copyright (C) 1999-2018 Tigran Aivazian <[email protected]>
  *
  *	Make the file block allocation algorithm understand the size
  *	of the underlying block device.
bfs/inode.c renamed from bfs/inode.c.0 +30 -36

178 lines not on this page · raw message