diff options
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r-- | fs/proc/base.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c index ec158dd02b3a..a721acfd4fdc 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -1448,10 +1448,28 @@ static const struct file_operations proc_fd_operations = { | |||
1448 | }; | 1448 | }; |
1449 | 1449 | ||
1450 | /* | 1450 | /* |
1451 | * /proc/pid/fd needs a special permission handler so that a process can still | ||
1452 | * access /proc/self/fd after it has executed a setuid(). | ||
1453 | */ | ||
1454 | static int proc_fd_permission(struct inode *inode, int mask, | ||
1455 | struct nameidata *nd) | ||
1456 | { | ||
1457 | int rv; | ||
1458 | |||
1459 | rv = generic_permission(inode, mask, NULL); | ||
1460 | if (rv == 0) | ||
1461 | return 0; | ||
1462 | if (task_pid(current) == proc_pid(inode)) | ||
1463 | rv = 0; | ||
1464 | return rv; | ||
1465 | } | ||
1466 | |||
1467 | /* | ||
1451 | * proc directories can do almost nothing.. | 1468 | * proc directories can do almost nothing.. |
1452 | */ | 1469 | */ |
1453 | static const struct inode_operations proc_fd_inode_operations = { | 1470 | static const struct inode_operations proc_fd_inode_operations = { |
1454 | .lookup = proc_lookupfd, | 1471 | .lookup = proc_lookupfd, |
1472 | .permission = proc_fd_permission, | ||
1455 | .setattr = proc_setattr, | 1473 | .setattr = proc_setattr, |
1456 | }; | 1474 | }; |
1457 | 1475 | ||