Skip to content

Fix kernel BUG in apm.c when tfw_apm_global_data is uninitialized (#2424) #2429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

WitalyAnisimov
Copy link

This PR fixes a kernel BUG triggered at apm.c:1050 when tfw_apm_global_data is not initialized.
Instead of crashing, the system now gracefully falls back to showing "n/a" for the APM stats in /proc output, similar to how SS statistics are handled.
Fixes: #2424

Copy link
Contributor

@krizhanovsky krizhanovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic seems good, but need to fix some senseless changes breaking identation

fw/procfs.c Outdated
unsigned int val[T_PSZ] = { 0 };
TfwPrcntlStats pstats = {.val = val};

if (!ss_stat)
T_WARN("Cannot allocate sync sockets statistics\n");
T_WARN("Cannot allocate sync sockets statistics\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces in identation, tabs must be used. Please check other places in the PR replacing tabs/spaces

seq_printf(seq, "%02d%%:\t%dms\n",
pstats.ith[i], pstats.val[i]);

skip_apm:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
skip_apm:
skip_apm:

And other identation issues

memset(pstats, 0, sizeof(*pstats));
return -ENODATA;
}
return __tfw_apm_stats(tfw_apm_global_data, pstats);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also identation issues

fw/apm.c Outdated
BUG_ON(!tfw_apm_global_data);
return __tfw_apm_stats(tfw_apm_global_data, pstats);
if (!tfw_apm_global_data) {
pr_warn("tfw_apm: global data not initialized, skipping stats\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use our logging facilities, e.g. T_WARN(). But it seems this is a normal case, so maybe we should use T_DBG instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kernel BUG at /root/tempesta/fw/apm.c:1050!
2 participants