lkml.org 
[lkml]   [2024]   [Apr]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH 2/4] binder: migrate ioctl to new PF_SPAM_DETECTION
    From
    Carlos Llamas <cmllamas@google.com> writes:
    > @@ -5553,7 +5553,8 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
    > goto err;
    > }
    > binder_inner_proc_lock(proc);
    > - proc->oneway_spam_detection_enabled = (bool)enable;
    > + proc->flags &= ~PF_SPAM_DETECTION;
    > + proc->flags |= enable & PF_SPAM_DETECTION;

    The bitwise and in `enable & PF_SPAM_DETECTION` only works because
    PF_SPAM_DETECTION happens to be equal to 1. This seems pretty fragile to
    me. Would you be willing to do this instead?

    proc->flags &= ~PF_SPAM_DETECTION;
    if (enable)
    proc->flags |= PF_SPAM_DETECTION;


    Carlos Llamas <cmllamas@google.com> writes:
    > - if (proc->oneway_spam_detection_enabled &&
    > - w->type == BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)
    > + if (proc->flags & PF_SPAM_DETECTION &&
    > + w->type == BINDER_WORK_TRANSACTION_ONEWAY_SPAM_SUSPECT)

    Maybe I am just not sufficiently familiar with C, but I had to look up
    the operator precedence rules for this one. Could we add parenthesises
    around `proc->flags & PF_SPAM_DETECTION`? Or even define a macro for it?

    Alice

    \
     
     \ /
      Last update: 2024-04-18 10:12    [W:6.216 / U:0.012 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site