Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Stats: Ignore fraudulent posts #18792

Closed

Conversation

muramura
Copy link
Contributor

I was able to set the BOOT COUNT in APM PLANNER2.
I was not able to set FLIGHT TIME and RUN TIME.
I think that BOOT COUNT is the same as FLIGHT TIME and RUN TIME.

Copy link
Contributor

@khancyr khancyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, maybe we should also mark all the parameters as AP_PARAM_FLAG_INTERNAL_USE_ONLY ?

@muramura
Copy link
Contributor Author

muramura commented Oct 7, 2021

@khancyr san.
Config Parameters RESET is written to initialize other parameters.
The other parameters are READ ONLY.

@magicrub
Copy link
Contributor

magicrub commented Oct 8, 2021

In the old days we used boot_count=0 to trigger a factory reset.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muramura this should also be marked as @ReadOnly in the parameter metadata

As far as I can see this PR simply doesn't work; I can reset the parameters just fine. The crucial thing with flttime and runtime is that these stats are updated within the stats library so are periodically rewritten. Technically there's a race condition between someone setting the parameters by hand and us writing fresh statistics out. This wasn't ever supposed to be protection against malicious actors....

We should probably add the internal-use-only flag as @khancyr suggests. Note that still won't stop users changing the parameter if they really want to - it makes it less likely to be overwritten, 'though.

@peterbarker
Copy link
Contributor

In the old days we used boot_count=0 to trigger a factory reset.

AFAIK ArduPilot's never done that :-)

@peterbarker
Copy link
Contributor

@amilcarlucas I think you're one of the few people who've provided feedback on stats. Do you see any problems in disallowing the set of STAT_BOOTCOUNT as a parameter?

@amilcarlucas
Copy link
Contributor

amilcarlucas commented Oct 18, 2021

Hello Peter. No, I see no drawbacks. I think it should have been a read-only parameter since day one.

I actually have a PR that only changes the stats only on very specific circunstances:

// Only reset statistics if the user explicitly sets AP_STATS_RESET parameter to zero.
// This allows users to load parameter files (in MP, MAVProxy or any other GCS) without
// accidentally reseting the statistics, because the AP_STATS_RESET value contained in
// the parameter file will be ignored (unless it is zero and it is usually not zero).
// The other statistics parameters are read-only, and the GCS should be clever enough to not set those.

but that never got merged.

@peterbarker
Copy link
Contributor

This approach is flawed. There's a race condition between the user writing the parameter and this code triggering, setting the thing back to the expected value.

As @amilcarlucas points out, this could probably be set to @readonly.

I'm going to close this one, but a PR along the other lines might be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants