Commit 1f71ebedb3f8ce9108978168759c8551d873a912
Committed by
Linus Torvalds
1 parent
bd67ce0f66
Exists in
master
and in
4 other branches
devpts: correctly set default options
devpts_get_sb() calls memset(0) to clear mount options and calls parse_mount_options() if user specified any mount options. The memset(0) is bogus since the 'mode' and 'ptmxmode' options are non-zero by default. parse_mount_options() restores options to default anyway and can properly deal with NULL mount options. So in devpts_get_sb() remove memset(0) and call parse_mount_options() even for NULL mount options. Bug reported by Eric Paris: http://lkml.org/lkml/2009/5/7/448. Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com> Tested-by: Marc Dionne <marc.c.dionne@gmail.com> Reported-by: Eric Paris <eparis@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Acked-by: Serge Hallyn <serue@us.ibm.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Reviewed-by: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 12 additions and 6 deletions Side-by-side Diff
fs/devpts/inode.c
... | ... | @@ -90,6 +90,15 @@ |
90 | 90 | #define PARSE_MOUNT 0 |
91 | 91 | #define PARSE_REMOUNT 1 |
92 | 92 | |
93 | +/* | |
94 | + * parse_mount_options(): | |
95 | + * Set @opts to mount options specified in @data. If an option is not | |
96 | + * specified in @data, set it to its default value. The exception is | |
97 | + * 'newinstance' option which can only be set/cleared on a mount (i.e. | |
98 | + * cannot be changed during remount). | |
99 | + * | |
100 | + * Note: @data may be NULL (in which case all options are set to default). | |
101 | + */ | |
93 | 102 | static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) |
94 | 103 | { |
95 | 104 | char *p; |
... | ... | @@ -355,12 +364,9 @@ |
355 | 364 | struct pts_mount_opts opts; |
356 | 365 | struct super_block *s; |
357 | 366 | |
358 | - memset(&opts, 0, sizeof(opts)); | |
359 | - if (data) { | |
360 | - error = parse_mount_options(data, PARSE_MOUNT, &opts); | |
361 | - if (error) | |
362 | - return error; | |
363 | - } | |
367 | + error = parse_mount_options(data, PARSE_MOUNT, &opts); | |
368 | + if (error) | |
369 | + return error; | |
364 | 370 | |
365 | 371 | if (opts.newinstance) |
366 | 372 | s = sget(fs_type, NULL, set_anon_super, NULL); |