[Patch2] Re: DoS with tmpfs #3

From: Christoph Rohland (cr@sap.com)
Date: Tue Aug 07 2001 - 04:09:47 EST


Hi ,

On 06 Aug 2001, Christoph Rohland wrote:
> Since there are enough persons having trouble with the current
> behaviour I append a patch (against 2.4.8-pre4) to implement the
> default to be ram/2.

The following patch is needed on top of the previous one to compile
without CONFIG_TMPFS.

Greetings
                Christoph

--- 8-pre4-def/mm/shmem.c Tue Aug 7 10:43:14 2001
+++ m8-pre4/mm/shmem.c Tue Aug 7 10:47:38 2001
@@ -537,6 +537,30 @@
         return inode;
 }
 
+static int shmem_set_size(struct shmem_sb_info *info,
+ unsigned long max_blocks, unsigned long max_inodes)
+{
+ int error;
+ unsigned long blocks, inodes;
+
+ spin_lock(&info->stat_lock);
+ blocks = info->max_blocks - info->free_blocks;
+ inodes = info->max_inodes - info->free_inodes;
+ error = -EINVAL;
+ if (max_blocks < blocks)
+ goto out;
+ if (max_inodes < inodes)
+ goto out;
+ error = 0;
+ info->max_blocks = max_blocks;
+ info->free_blocks = max_blocks - blocks;
+ info->max_inodes = max_inodes;
+ info->free_inodes = max_inodes - inodes;
+out:
+ spin_unlock(&info->stat_lock);
+ return error;
+}
+
 #ifdef CONFIG_TMPFS
 static ssize_t
 shmem_file_write(struct file *file,const char *buf,size_t count,loff_t *ppos)
@@ -1001,30 +1025,6 @@
                         return 1;
         }
         return 0;
-}
-
-static int shmem_set_size(struct shmem_sb_info *info,
- unsigned long max_blocks, unsigned long max_inodes)
-{
- int error;
- unsigned long blocks, inodes;
-
- spin_lock(&info->stat_lock);
- blocks = info->max_blocks - info->free_blocks;
- inodes = info->max_inodes - info->free_inodes;
- error = -EINVAL;
- if (max_blocks < blocks)
- goto out;
- if (max_inodes < inodes)
- goto out;
- error = 0;
- info->max_blocks = max_blocks;
- info->free_blocks = max_blocks - blocks;
- info->max_inodes = max_inodes;
- info->free_inodes = max_inodes - inodes;
-out:
- spin_unlock(&info->stat_lock);
- return error;
 }
 
 static int shmem_remount_fs (struct super_block *sb, int *flags, char *data)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 07 2001 - 21:00:43 EST