On Mon, Nov 27, 2017 at 05:21:31PM +0100, Jiri Olsa wrote:
> +static int __modify_user_hw_breakpoint(struct perf_event *bp, struct 
> perf_event_attr *attr)
> +{
> +     u64 old_addr = bp->attr.bp_addr;
> +     u64 old_len  = bp->attr.bp_len;
> +     int old_type = bp->attr.bp_type;
> +     bool modify  = attr->bp_type != old_type;
> +     int err = 0;
> +
> +     bp->attr.bp_addr = attr->bp_addr;
> +     bp->attr.bp_type = attr->bp_type;
> +     bp->attr.bp_len  = attr->bp_len;
> +
> +     err = validate_hw_breakpoint(bp);
> +     if (!err && modify)
> +             err = modify_bp_slot(bp, old_type);
> +
> +     if (err) {
> +             bp->attr.bp_addr = old_addr;
> +             bp->attr.bp_type = old_type;
> +             bp->attr.bp_len  = old_len;
> +             return err;
> +     }
> +
> +     bp->attr.disabled = attr->disabled;
> +     return 0;
> +}

I think this function is failing to check if anything else in the attr
changes.

For example, someone could have added PERF_SAMPLE_BRANCH_STACK. That's
something you'll fail to create breakpoints with, but this modification
would 'accept'.

Reply via email to