diff options
Diffstat (limited to 'security/apparmor/include/file.h')
-rw-r--r-- | security/apparmor/include/file.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/security/apparmor/include/file.h b/security/apparmor/include/file.h index 967b2deda376..2c922b86bd44 100644 --- a/security/apparmor/include/file.h +++ b/security/apparmor/include/file.h | |||
@@ -186,11 +186,6 @@ static inline void aa_free_file_rules(struct aa_file_rules *rules) | |||
186 | aa_free_domain_entries(&rules->trans); | 186 | aa_free_domain_entries(&rules->trans); |
187 | } | 187 | } |
188 | 188 | ||
189 | #define ACC_FMODE(x) (("\000\004\002\006"[(x)&O_ACCMODE]) | (((x) << 1) & 0x40)) | ||
190 | |||
191 | /* from namei.c */ | ||
192 | #define MAP_OPEN_FLAGS(x) ((((x) + 1) & O_ACCMODE) ? (x) + 1 : (x)) | ||
193 | |||
194 | /** | 189 | /** |
195 | * aa_map_file_perms - map file flags to AppArmor permissions | 190 | * aa_map_file_perms - map file flags to AppArmor permissions |
196 | * @file: open file to map flags to AppArmor permissions | 191 | * @file: open file to map flags to AppArmor permissions |
@@ -199,8 +194,13 @@ static inline void aa_free_file_rules(struct aa_file_rules *rules) | |||
199 | */ | 194 | */ |
200 | static inline u32 aa_map_file_to_perms(struct file *file) | 195 | static inline u32 aa_map_file_to_perms(struct file *file) |
201 | { | 196 | { |
202 | int flags = MAP_OPEN_FLAGS(file->f_flags); | 197 | int flags = file->f_flags; |
203 | u32 perms = ACC_FMODE(file->f_mode); | 198 | u32 perms = 0; |
199 | |||
200 | if (file->f_mode & FMODE_WRITE) | ||
201 | perms |= MAY_WRITE; | ||
202 | if (file->f_mode & FMODE_READ) | ||
203 | perms |= MAY_READ; | ||
204 | 204 | ||
205 | if ((flags & O_APPEND) && (perms & MAY_WRITE)) | 205 | if ((flags & O_APPEND) && (perms & MAY_WRITE)) |
206 | perms = (perms & ~MAY_WRITE) | MAY_APPEND; | 206 | perms = (perms & ~MAY_WRITE) | MAY_APPEND; |