mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-09 10:51:03 +01:00

should_remove_suid into a seperate patch. The should_remove_suid patch isn't needed so it should probably be removed. Add first attempt at using lockdep typing to get rid of false irq inversion messages.
96 lines
3 KiB
Diff
96 lines
3 KiB
Diff
From: Andreas Gruenbacher <agruen@suse.de>
|
|
Subject: Pass struct file down to should_remove_suid and children
|
|
|
|
Pass struct path to should_remove_suid instead of only the dentry.
|
|
To make should_remove_suid consistent with changes made to
|
|
remove_suid.
|
|
|
|
Signed-off-by: Tony Jones <tonyj@suse.de>
|
|
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
|
|
Signed-off-by: John Johansen <jjohansen@suse.de>
|
|
|
|
---
|
|
fs/ocfs2/file.c | 2 +-
|
|
fs/open.c | 5 ++++-
|
|
fs/splice.c | 2 +-
|
|
include/linux/fs.h | 2 +-
|
|
mm/filemap.c | 6 +++---
|
|
5 files changed, 10 insertions(+), 7 deletions(-)
|
|
|
|
--- a/fs/ocfs2/file.c
|
|
+++ b/fs/ocfs2/file.c
|
|
@@ -1191,7 +1191,7 @@ static int ocfs2_prepare_inode_for_write
|
|
* inode. There's also the dinode i_size state which
|
|
* can be lost via setattr during extending writes (we
|
|
* set inode->i_size at the end of a write. */
|
|
- if (should_remove_suid(path->dentry)) {
|
|
+ if (should_remove_suid(path)) {
|
|
if (meta_level == 0) {
|
|
ocfs2_meta_unlock(inode, meta_level);
|
|
meta_level = 1;
|
|
--- a/fs/open.c
|
|
+++ b/fs/open.c
|
|
@@ -198,6 +198,7 @@ int do_truncate(struct dentry *dentry, s
|
|
{
|
|
int err;
|
|
struct iattr newattrs;
|
|
+ struct path path;
|
|
|
|
/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
|
|
if (length < 0)
|
|
@@ -211,7 +212,9 @@ int do_truncate(struct dentry *dentry, s
|
|
}
|
|
|
|
/* Remove suid/sgid on truncate too */
|
|
- newattrs.ia_valid |= should_remove_suid(dentry);
|
|
+ path.dentry = dentry;
|
|
+ path.mnt = mnt;
|
|
+ newattrs.ia_valid |= should_remove_suid(&path);
|
|
|
|
mutex_lock(&dentry->d_inode->i_mutex);
|
|
err = notify_change(dentry, mnt, &newattrs);
|
|
--- a/fs/splice.c
|
|
+++ b/fs/splice.c
|
|
@@ -842,7 +842,7 @@ generic_file_splice_write(struct pipe_in
|
|
ssize_t ret;
|
|
int err;
|
|
|
|
- err = should_remove_suid(out->f_path.dentry);
|
|
+ err = should_remove_suid(&out->f_path);
|
|
if (unlikely(err)) {
|
|
mutex_lock(&inode->i_mutex);
|
|
err = __remove_suid(&out->f_path, err);
|
|
--- a/include/linux/fs.h
|
|
+++ b/include/linux/fs.h
|
|
@@ -1698,7 +1698,7 @@ extern void clear_inode(struct inode *);
|
|
extern void destroy_inode(struct inode *);
|
|
extern struct inode *new_inode(struct super_block *);
|
|
extern int __remove_suid(struct path *, int);
|
|
-extern int should_remove_suid(struct dentry *);
|
|
+extern int should_remove_suid(struct path *);
|
|
extern int remove_suid(struct path *);
|
|
|
|
extern void __insert_inode_hash(struct inode *, unsigned long hashval);
|
|
--- a/mm/filemap.c
|
|
+++ b/mm/filemap.c
|
|
@@ -1882,9 +1882,9 @@ repeat:
|
|
* if suid or (sgid and xgrp)
|
|
* remove privs
|
|
*/
|
|
-int should_remove_suid(struct dentry *dentry)
|
|
+int should_remove_suid(struct path *path)
|
|
{
|
|
- mode_t mode = dentry->d_inode->i_mode;
|
|
+ mode_t mode = path->dentry->d_inode->i_mode;
|
|
int kill = 0;
|
|
|
|
/* suid always must be killed */
|
|
@@ -1915,7 +1915,7 @@ int __remove_suid(struct path *path, int
|
|
|
|
int remove_suid(struct path *path)
|
|
{
|
|
- int kill = should_remove_suid(path->dentry);
|
|
+ int kill = should_remove_suid(path);
|
|
|
|
if (unlikely(kill))
|
|
return __remove_suid(path, kill);
|