diff options
Diffstat (limited to 'fs/fcntl.c')
-rw-r--r-- | fs/fcntl.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c index 1ad703150dee..f9c03ca3b2f4 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -198,15 +198,19 @@ static int setfl(int fd, struct file * filp, unsigned long arg) | |||
198 | } | 198 | } |
199 | 199 | ||
200 | static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, | 200 | static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, |
201 | uid_t uid, uid_t euid, int force) | 201 | int force) |
202 | { | 202 | { |
203 | write_lock_irq(&filp->f_owner.lock); | 203 | write_lock_irq(&filp->f_owner.lock); |
204 | if (force || !filp->f_owner.pid) { | 204 | if (force || !filp->f_owner.pid) { |
205 | put_pid(filp->f_owner.pid); | 205 | put_pid(filp->f_owner.pid); |
206 | filp->f_owner.pid = get_pid(pid); | 206 | filp->f_owner.pid = get_pid(pid); |
207 | filp->f_owner.pid_type = type; | 207 | filp->f_owner.pid_type = type; |
208 | filp->f_owner.uid = uid; | 208 | |
209 | filp->f_owner.euid = euid; | 209 | if (pid) { |
210 | const struct cred *cred = current_cred(); | ||
211 | filp->f_owner.uid = cred->uid; | ||
212 | filp->f_owner.euid = cred->euid; | ||
213 | } | ||
210 | } | 214 | } |
211 | write_unlock_irq(&filp->f_owner.lock); | 215 | write_unlock_irq(&filp->f_owner.lock); |
212 | } | 216 | } |
@@ -214,14 +218,13 @@ static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, | |||
214 | int __f_setown(struct file *filp, struct pid *pid, enum pid_type type, | 218 | int __f_setown(struct file *filp, struct pid *pid, enum pid_type type, |
215 | int force) | 219 | int force) |
216 | { | 220 | { |
217 | const struct cred *cred = current_cred(); | ||
218 | int err; | 221 | int err; |
219 | 222 | ||
220 | err = security_file_set_fowner(filp); | 223 | err = security_file_set_fowner(filp); |
221 | if (err) | 224 | if (err) |
222 | return err; | 225 | return err; |
223 | 226 | ||
224 | f_modown(filp, pid, type, cred->uid, cred->euid, force); | 227 | f_modown(filp, pid, type, force); |
225 | return 0; | 228 | return 0; |
226 | } | 229 | } |
227 | EXPORT_SYMBOL(__f_setown); | 230 | EXPORT_SYMBOL(__f_setown); |
@@ -247,7 +250,7 @@ EXPORT_SYMBOL(f_setown); | |||
247 | 250 | ||
248 | void f_delown(struct file *filp) | 251 | void f_delown(struct file *filp) |
249 | { | 252 | { |
250 | f_modown(filp, NULL, PIDTYPE_PID, 0, 0, 1); | 253 | f_modown(filp, NULL, PIDTYPE_PID, 1); |
251 | } | 254 | } |
252 | 255 | ||
253 | pid_t f_getown(struct file *filp) | 256 | pid_t f_getown(struct file *filp) |