From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 2/8] xfs: Fix open flag handling in open_by_handle code
Date: Fri, 2 Mar 2012 15:11:41 +1100 [thread overview]
Message-ID: <1330661507-1121-3-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1330661507-1121-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
From: Dave Chinner <dchinner@redhat.com>
Sparse identified some unsafe handling of open flags in the xfs open
by handle ioctl code. Update the code to use the correct access
macros to ensure that we handle the open flags correctly.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/xfs_ioctl.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 76f3ca5..86c86d8 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -230,24 +230,19 @@ xfs_open_by_handle(
/* Put open permission in namei format. */
permflag = hreq->oflags;
- if ((permflag+1) & O_ACCMODE)
- permflag++;
- if (permflag & O_TRUNC)
- permflag |= 2;
-
if ((!(permflag & O_APPEND) || (permflag & O_TRUNC)) &&
- (permflag & FMODE_WRITE) && IS_APPEND(inode)) {
+ (OPEN_FMODE(permflag) & FMODE_WRITE) && IS_APPEND(inode)) {
error = -XFS_ERROR(EPERM);
goto out_dput;
}
- if ((permflag & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
+ if ((OPEN_FMODE(permflag) & FMODE_WRITE) && IS_IMMUTABLE(inode)) {
error = -XFS_ERROR(EACCES);
goto out_dput;
}
/* Can't write directories. */
- if (S_ISDIR(inode->i_mode) && (permflag & FMODE_WRITE)) {
+ if (S_ISDIR(inode->i_mode) && (OPEN_FMODE(permflag) & FMODE_WRITE)) {
error = -XFS_ERROR(EISDIR);
goto out_dput;
}
--
1.7.9
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-03-02 4:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 4:11 [PATCH 0/8] xfs: bug fixes for 3.4 Dave Chinner
2012-03-02 4:11 ` [PATCH 1/8] xfs: clean up minor sparse warnings Dave Chinner
2012-03-02 7:46 ` Christoph Hellwig
2012-03-02 7:59 ` Dave Chinner
2012-03-02 4:11 ` Dave Chinner [this message]
2012-03-02 7:47 ` [PATCH 2/8] xfs: Fix open flag handling in open_by_handle code Christoph Hellwig
2012-03-02 4:11 ` [PATCH 3/8] xfs: handle kmalloc failure when reading attrs Dave Chinner
2012-03-02 7:49 ` Christoph Hellwig
2012-03-02 9:49 ` Dave Chinner
2012-03-02 10:31 ` Christoph Hellwig
2012-03-02 4:11 ` [PATCH 4/8] xfs: avoid memory allocation failures in xfs_getbmap Dave Chinner
2012-03-02 7:49 ` Christoph Hellwig
2012-03-02 4:11 ` [PATCH 5/8] xfs: introduce an allocation workqueue Dave Chinner
2012-03-02 4:11 ` [PATCH 6/8] xfs: remove remaining scraps of struct xfs_iomap Dave Chinner
2012-03-02 4:11 ` [PATCH 7/8] xfs: fix inode lookup race Dave Chinner
2012-03-02 4:11 ` [PATCH 8/8] xfs: add a shrinker for quotacheck Dave Chinner
2012-03-02 7:51 ` Christoph Hellwig
2012-03-02 10:04 ` Dave Chinner
2012-03-02 10:38 ` Christoph Hellwig
2012-03-02 11:14 ` Christoph Hellwig
2012-03-05 1:49 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1330661507-1121-3-git-send-email-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox