Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1613279

[PATCH 2/2] fs: reject unknown open flags

From Christoph Hellwig <hch@lst.de>
Newsgroups linux.kernel
Subject [PATCH 2/2] fs: reject unknown open flags
Date 2017-03-30 18:40 +0200
Message-ID <tqLh8-GX-15@gated-at.bofh.it> (permalink)
References <tqLh7-GX-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This way userspace can probe for actually supported flags.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/open.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/open.c b/fs/open.c
index 949cef29c3bb..9106ed7310f0 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -900,6 +900,9 @@ static inline int build_open_flags(int flags, umode_t mode, struct open_flags *o
 	int lookup_flags = 0;
 	int acc_mode = ACC_MODE(flags);
 
+	if (flags & ~VALID_OPEN_FLAGS)
+		return -EINVAL;
+
 	if (flags & (O_CREAT | __O_TMPFILE))
 		op->mode = (mode & S_IALLUGO) | S_IFREG;
 	else
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

RFC: reject unknown open flags Christoph Hellwig <hch@lst.de> - 2017-03-30 18:40 +0200
  [PATCH 1/2] fs: add a VALID_OPEN_FLAGS Christoph Hellwig <hch@lst.de> - 2017-03-30 18:40 +0200
  [PATCH 2/2] fs: reject unknown open flags Christoph Hellwig <hch@lst.de> - 2017-03-30 18:40 +0200
    Re: [PATCH 2/2] fs: reject unknown open flags Linus Torvalds <torvalds@linux-foundation.org> - 2017-03-30 19:10 +0200
  Re: RFC: reject unknown open flags Linus Torvalds <torvalds@linux-foundation.org> - 2017-03-30 19:10 +0200
    Re: RFC: reject unknown open flags Christoph Hellwig <hch@lst.de> - 2017-03-30 19:30 +0200
      Re: RFC: reject unknown open flags Linus Torvalds <torvalds@linux-foundation.org> - 2017-03-30 20:30 +0200
        Re: RFC: reject unknown open flags Christoph Hellwig <hch@lst.de> - 2017-03-30 20:30 +0200
          Re: RFC: reject unknown open flags Linus Torvalds <torvalds@linux-foundation.org> - 2017-03-30 20:50 +0200
            Re: RFC: reject unknown open flags Boaz Harrosh <boaz@plexistor.com> - 2017-03-30 22:10 +0200
        Re: RFC: reject unknown open flags Paul Eggert <eggert@cs.ucla.edu> - 2017-03-30 21:10 +0200
          Re: RFC: reject unknown open flags Linus Torvalds <torvalds@linux-foundation.org> - 2017-03-30 21:20 +0200
    Re: RFC: reject unknown open flags Florian Weimer <fw@deneb.enyo.de> - 2017-03-30 21:40 +0200

csiph-web