[Linux-kernel-mentees] [RFC PATCH] checkpatch: add shebang check to EXECUTE_PERMISSIONS

Ujjwal Kumar ujjwalkumar0501 at gmail.com
Sun Oct 11 18:32:49 UTC 2020


On 11/10/20 11:49 pm, Lukas Bulwahn wrote:
> 
> 
> On Sun, 11 Oct 2020, Ujjwal Kumar wrote:
> 
>> On 11/10/20 11:20 pm, Lukas Bulwahn wrote:
>>>
>>>
>>> On Sun, 11 Oct 2020, Ujjwal Kumar wrote:
>>>
>>>> checkpatch script checks for invalid EXECUTE_PERMISSIONS on source
>>>> files. The script leverages filename extensions and its path in
>>>> the repository to decide whether to allow execute permissions on
>>>> the file or not.
>>>>
>>>> Based on current check conditions, a perl script file without
>>>> '.pl' extension in its filename and not belonging to 'scripts/'
>>>> directory is reported as ERROR which is a false-positive.
>>>>
>>>> The script can correctly handle patches with mode changes and
>>>> shebang line if shebang is taken into account. So, along with
>>>> the current check conditions, adding the shebang check in the
>>>> check conditions can improve the reports of the script.
>>>>
>>>
>>> I think one of the core design decisions of checkpatch.pl is:
>>>
>>> checkpatch.pl can run on a patch, even if the patch does not apply to the 
>>> current repository version that is checked out.
>>
>> From our past conversation I remember about this particular point.
>>
>>>
>>> It solely uses the information in the patch, and does not try to guess how 
>>> it could be applied etc.
>>
>> I am fetching the 'shebang' from the patch itself (therefore I do not 
>> understand how does the proposed change violate that design decision?).
>>
> 
> Okay, maybe I misread the patch; so, where those the first line come from?
> What if that first line is not part of the patch?

In that case there might be a false-positive. But I tried to handle such cases 
where the first line is in the patch itself.

Okay, so there are total of 4 cases with file mode change:
1. mode change + create + modify
2. mode change + create
3. mode change + modify
4. mode change

the patch will handle all cases of type 1 and some cases of type 3.
Other cases won't be handled because they cannot be handled without 
breaking the core design decision.

I do have references to say that the cases 2 and 4 are

Which I thought is an improvement over current logic used for the check.

Correct me if I am wrong.


Thanks
Ujjwal Kumar


More information about the Linux-kernel-mentees mailing list