Page MenuHomePhabricator

Files can recursively depend on one another, needing infinite policy checks
Closed, ResolvedPublic

Description

It's possible to attach files in a cycle (A -> B -> A) and possibly to themselves (A -> A) by commenting on file A with {Fbbbb} and on file B with {Faaaa}. The policy evaluation never exits.

A hacky fix would be to prevent files from being attached to files.

A cleaner fix would be to resolve cycles correctly, but this might be involved.

Event Timeline

epriestley raised the priority of this task from to Normal.
epriestley updated the task description. (Show Details)
epriestley added projects: Policy, Files.

Haha cool, just tested this out on my dev install and it maxes out the CPU on my VM.

epriestley added a subscriber: Unknown Object (User).

T8119 hit this in a non-theoretical way.

Unknown Object (User) added a comment.May 7 2015, 6:54 PM

Definitely my problem:

MariaDB [phabricator_file]> select * from edge order by dateCreated desc limit 5;
+--------------------------------+------+--------------------------------+-------------+-----+--------+
| src                            | type | dst                            | dateCreated | seq | dataID |
+--------------------------------+------+--------------------------------+-------------+-----+--------+
| PHID-FILE-qffup4ki3h7houulve3d |   26 | PHID-FILE-qffup4ki3h7houulve3d |  1430992455 |   1 |   NULL |
| PHID-FILE-qffup4ki3h7houulve3d |   25 | PHID-FILE-qffup4ki3h7houulve3d |  1430992455 |   0 |   NULL |
| PHID-FILE-qffup4ki3h7houulve3d |   21 | PHID-USER-j4owr5kdhj243qlkhu6l |  1430992319 |   0 |   NULL |
| PHID-FILE-qffup4ki3h7houulve3d |   26 | PHID-TASK-mirzruisn77tw4zow52a |  1430991972 |   0 |   NULL |
| PHID-FILE-7oogy4flcolzbmxzoqy7 |   26 | PHID-TASK-aktaetetss24d24lnzsu |  1430930202 |   0 |   NULL |
+--------------------------------+------+--------------------------------+-------------+-----+--------+
5 rows in set (0.00 sec)
Unknown Object (User) added a comment.May 7 2015, 6:55 PM

@epriestley, is it safe to just delete these last two rows?

Yep, should be safe (although the first two rows are probably the issue?).

I should have a patch shortly unless this turns out to be harder than I think.

Unknown Object (User) added a comment.May 7 2015, 6:58 PM

The query is order by dateCreated desc, so technically they're last. :)

Cool. D12756 should resolve this in the general case by terminating loops as soon as we try to re-load an object we're already loading.