Skip to contentSkip to conversation

Backward compatibility issue

Cocci Denis Efremov 2 participants 5 messages Feb 11, 2021 – Feb 13, 2021

lore
Share & tools
lore
#0 lore raw

Hi, one of my patterns started to fail tests on latest coccinelle. I've bisected the commit that introduces "error". It's:
commit db60e916633d2cb3ae31140364783fdf85ed10f4
"make information about SmPL iterator and declarer names available to the C parser"

To reproduce the error:

$ cd linux
$ git checkout 5b01014759991887b1e450c9def01e58c02ab81b
$ wget https://raw.githubusercontent.com/evdenis/cvehound/master/cvehound/cve/CVE-2016-9793.cocci
$ spatch -D detect --cocci-file CVE-2016-9793.cocci net/core/sock.c
# spatch before db60e916633d2cb3ae31140364783fdf85ed10f4 will find the match
net/core/sock.c:718:16-17: ERROR: CVE-2016-9793
net/core/sock.c:754:16-17: ERROR: CVE-2016-9793
...
# spatch >= db60e916633d2cb3ae31140364783fdf85ed10f4 will not match the same code

Thanks,
Denis
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#1 lore raw
Quoted 6 lines · Denis Efremov

Hi, one of my patterns started to fail tests on latest coccinelle. I've bisected the commit that introduces "error". It's:
commit db60e916633d2cb3ae31140364783fdf85ed10f4
"make information about SmPL iterator and declarer names available to the C parser"

To reproduce the error:

Quoted 9 lines
$ cd linux
$ git checkout 5b01014759991887b1e450c9def01e58c02ab81b
$ wget https://raw.githubusercontent.com/evdenis/cvehound/master/cvehound/cve/CVE-2016-9793.cocci
$ spatch -D detect --cocci-file CVE-2016-9793.cocci net/core/sock.c
# spatch before db60e916633d2cb3ae31140364783fdf85ed10f4 will find the match
net/core/sock.c:718:16-17: ERROR: CVE-2016-9793
net/core/sock.c:754:16-17: ERROR: CVE-2016-9793
...
# spatch >= db60e916633d2cb3ae31140364783fdf85ed10f4 will not match the same code

Thanks for the report. Maybe sometimes making the parser work better actually makes it work worse... I'll check on it.

julia

Quoted 8 lines

Thanks,
Denis
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#2 lore raw
In reply to Denis Efremov
Quoted 6 lines · Denis Efremov

Hi, one of my patterns started to fail tests on latest coccinelle. I've bisected the commit that introduces "error". It's:
commit db60e916633d2cb3ae31140364783fdf85ed10f4
"make information about SmPL iterator and declarer names available to the C parser"

To reproduce the error:

Quoted 9 lines
$ cd linux
$ git checkout 5b01014759991887b1e450c9def01e58c02ab81b
$ wget https://raw.githubusercontent.com/evdenis/cvehound/master/cvehound/cve/CVE-2016-9793.cocci
$ spatch -D detect --cocci-file CVE-2016-9793.cocci net/core/sock.c
# spatch before db60e916633d2cb3ae31140364783fdf85ed10f4 will find the match
net/core/sock.c:718:16-17: ERROR: CVE-2016-9793
net/core/sock.c:754:16-17: ERROR: CVE-2016-9793
...
# spatch >= db60e916633d2cb3ae31140364783fdf85ed10f4 will not match the same code

If you change typedef u32 to symbol u32, it should be good. It is no use to Coccinelle to know that u32 is a typedef in this code.

julia

Quoted 8 lines

Thanks,
Denis
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#3 lore raw
Quoted 20 lines · Julia Lawall
Quoted 6 lines · Denis Efremov

Hi, one of my patterns started to fail tests on latest coccinelle. I've bisected the commit that introduces "error". It's:
commit db60e916633d2cb3ae31140364783fdf85ed10f4
"make information about SmPL iterator and declarer names available to the C parser"

To reproduce the error:

Quoted 9 lines
$ cd linux
$ git checkout 5b01014759991887b1e450c9def01e58c02ab81b
$ wget https://raw.githubusercontent.com/evdenis/cvehound/master/cvehound/cve/CVE-2016-9793.cocci
$ spatch -D detect --cocci-file CVE-2016-9793.cocci net/core/sock.c
# spatch before db60e916633d2cb3ae31140364783fdf85ed10f4 will find the match
net/core/sock.c:718:16-17: ERROR: CVE-2016-9793
net/core/sock.c:754:16-17: ERROR: CVE-2016-9793
...
# spatch >= db60e916633d2cb3ae31140364783fdf85ed10f4 will not match the same code
Quoted 2 lines

If you change typedef u32 to symbol u32, it should be good. It is no use to Coccinelle to know that u32 is a typedef in this code.

After changing typedef to symbol, git version starts to match the code, but coccinelle 1.0.8 starts to fail the detection. Well, this doesn't solve the problem for me.

What's the difference between symbol and typedef? How can I understand when to use one or another?

Thanks,
Denis
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

#4 lore raw
Quoted 23 lines · Denis Efremov
Quoted 20 lines · Julia Lawall
Quoted 15 lines · Denis Efremov

Hi, one of my patterns started to fail tests on latest coccinelle. I've bisected the commit that introduces "error". It's:
commit db60e916633d2cb3ae31140364783fdf85ed10f4
"make information about SmPL iterator and declarer names available to the C parser"

To reproduce the error:

$ cd linux
$ git checkout 5b01014759991887b1e450c9def01e58c02ab81b
$ wget https://raw.githubusercontent.com/evdenis/cvehound/master/cvehound/cve/CVE-2016-9793.cocci
$ spatch -D detect --cocci-file CVE-2016-9793.cocci net/core/sock.c
# spatch before db60e916633d2cb3ae31140364783fdf85ed10f4 will find the match
net/core/sock.c:718:16-17: ERROR: CVE-2016-9793
net/core/sock.c:754:16-17: ERROR: CVE-2016-9793
...
# spatch >= db60e916633d2cb3ae31140364783fdf85ed10f4 will not match the same code
Quoted 5 lines
Quoted 2 lines

If you change typedef u32 to symbol u32, it should be good. It is no use to Coccinelle to know that u32 is a typedef in this code.

After changing typedef to symbol, git version starts to match the code, but coccinelle 1.0.8 starts to fail the detection.

Strange, I'll check.

Quoted 5 lines

Well, this doesn't
solve the problem for me.

What's the difference between symbol and typedef? How can I understand when to use one or another?

Typedef allows the thing to be used as a type. But in semantic patch that oyu have, there is no way for Coccinelle to know that u32 is being used as a type. It's just the argument to a macro. It could be any identifier.

Symbol just means "this is an identifier I want to match exactly, and I don't want the semantic patch parser to ask me if it should be a metavariable". It actually has no impact on the matching process.

julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci