mptcp: pm: Return local variable instead of freed pointer
Subsystems (2)
PATCH v2 1/1 mptcp: pm: Return local variable instead of freed pointer
Commit e4c28e3d5c090 ("mptcp: pm: move generic PM helpers to pm.c") removed an unnecessary if-check, which resulted in returning a freed pointer.
This still works due to the implicit boolean conversion when returning the freed pointer from mptcp_remove_anno_list_by_saddr(), but it can be confusing and potentially error-prone. To improve clarity, add a local variable to explicitly return a boolean value instead.
---
Changes in v2:
- Remove the if-check again as suggested by Matthieu Baerts
- Rephrase the commit message
- Link to v1: https://lore.kernel.org/r/[email protected]/
--- net/mptcp/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/mptcp/pm.c +3 -1
@@ -151,10 +151,12 @@ bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr) {struct mptcp_pm_add_entry *entry; +bool ret; entry =mptcp_pm_del_add_timer (msk, addr, false); + ret = entry;kfree (entry); -return entry; +return ret; }bool mptcp_pm_sport_in_anno_list (struct mptcp_sock *msk,const struct sock *sk)
Hi Thorsten,
Quoted 8 lines · Thorsten Blum
Commit
e4c28e3d5c090("mptcp: pm: move generic PM helpers topm.c") removed an unnecessary if-check, which resulted in returning a freed pointer.This still works due to the implicit boolean conversion when returning the freed pointer from
mptcp_remove_anno_list_by_saddr(), but it can be confusing and potentially error-prone. To improve clarity, add a local variable to explicitly return a boolean value instead.
Thank you, the patch looks good to me!
It looks like the CI had some issues to apply your patch [1]. Strange, it was fine for me to apply it with 'b4 shazam'. I manually sent it to the CI, I will wait for it to validate it before applying it.
https://patchew.org/MPTCP/[email protected]/logs/git/
Quoted 16 lines
Signed-off-by Thorsten Blum <[email protected]>---
Changes in v2:
- Remove the if-check again as suggested by Matthieu Baerts
- Rephrase the commit message
- Link to v1: https://lore.kernel.org/r/[email protected]/--- net/mptcp/pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/mptcp/pm.c +0
-0
net/mptcp/pm.c bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk, · line 159
Quoted 10 lines
net/mptcp/pm.c +3
-1@@ -151,10 +151,12 @@ bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk, const struct mptcp_addr_info *addr) {struct mptcp_pm_add_entry *entry; +bool ret; entry =mptcp_pm_del_add_timer (msk, addr, false); + ret = entry;kfree (entry); -return entry; +return ret;
(detail: while at it, we can probably add a new line before the 'return'. I can add that when applying the patch)
net/mptcp/pm.c bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk, · line 162
Quoted 4 lines
net/mptcp/pm.c +0
-0}bool mptcp_pm_sport_in_anno_list (struct mptcp_sock *msk,const struct sock *sk)
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Quoted 6 lines · Matthieu Baerts
It looks like the CI had some issues to apply your patch [1]. Strange, it was fine for me to apply it with 'b4 shazam'. I manually sent it to the CI, I will wait for it to validate it before applying it.
I get a 404 Not Found when opening the link.
Weird, I made sure the patch applies to mptcp/export.
Thanks,
Thorsten
Matthieu Baerts
maintainerQuoted 9 lines · Thorsten Blum
Quoted 6 lines · Matthieu Baerts
It looks like the CI had some issues to apply your patch [1]. Strange, it was fine for me to apply it with 'b4 shazam'. I manually sent it to the CI, I will wait for it to validate it before applying it.
I get a 404 Not Found when opening the link.
Better with this one, then click on "apply log"?
https://patchew.org/MPTCP/[email protected]/
Here is the log:
Quoted 9 lines
Switched to a new branch '[email protected]'
Applying: mptcp: pm: Return local variable instead of freed pointer
error: corrupt patch at line 27
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 mptcp: pm: Return local variable instead of freed pointer When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
I didn't have that on my side.
Quoted 1 line
Weird, I made sure the patch applies to mptcp/export.
Yes, strange. There was an issue with the v1 as well apparently:
https://patchew.org/MPTCP/[email protected]/
I will check later if it was not an issue with Patchew.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Hi Thorsten,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Unstable: 1 failed test(s): bpftest_test_progs-no_alu32_mptcp 🔴
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/14067288712
Initiator: Matthieu Baerts (NGI0)
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/0852b4c9fbd3
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=947230
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Matthieu Baerts
maintainerHi Thorsten,
Quoted 8 lines · Thorsten Blum
Commit
e4c28e3d5c090("mptcp: pm: move generic PM helpers topm.c") removed an unnecessary if-check, which resulted in returning a freed pointer.This still works due to the implicit boolean conversion when returning the freed pointer from
mptcp_remove_anno_list_by_saddr(), but it can be confusing and potentially error-prone. To improve clarity, add a local variable to explicitly return a boolean value instead.
Thank you for your patch! Now in our tree (feat. for net-next):
New patches for t/upstream:
- 5172fc837d0c: mptcp: pm: Return local variable instead of freed pointer
- Results: c0c93d7a6bc6..7723f461d379 (export)
Tests are now in progress:
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.