Skip to content

Commit 89ba52b

Browse files
committed
Merge branch 'sctp_logspam'
Neil Horman says: ==================== sctp: Consolidate and ratelimit deprecation warnings The SCTP protocol has several deprecation warnings in its setsockopt path that can be triggered by unprivlidged users. Since these are not ratelimited, we can spam the logs quite easily here. Since these are all deprecation warnings, and that type of warning isn't uncommon in the rest of the kernel, lets make a common pr_warn_deprecated macro to produce somewhat generalized ratelimited deprecation warnings easily ==================== Signed-off-by: Neil Horman <nhorman@tuxdriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents c76f2a2 + 94f6519 commit 89ba52b

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

include/linux/printk.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ struct va_format {
8787
*/
8888
#define HW_ERR "[Hardware Error]: "
8989

90+
/*
91+
* DEPRECATED
92+
* Add this to a message whenever you want to warn user space about the use
93+
* of a deprecated aspect of an API so they can stop using it
94+
*/
95+
#define DEPRECATED "[Deprecated]: "
96+
9097
/*
9198
* Dummy printk for disabled debugging statements to use whilst maintaining
9299
* gcc's format and side-effect checking.

net/sctp/socket.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,8 +2578,9 @@ static int sctp_setsockopt_delayed_ack(struct sock *sk,
25782578
if (params.sack_delay == 0 && params.sack_freq == 0)
25792579
return 0;
25802580
} else if (optlen == sizeof(struct sctp_assoc_value)) {
2581-
pr_warn("Use of struct sctp_assoc_value in delayed_ack socket option deprecated\n");
2582-
pr_warn("Use struct sctp_sack_info instead\n");
2581+
pr_warn_ratelimited(DEPRECATED
2582+
"Use of struct sctp_assoc_value in delayed_ack socket option.\n"
2583+
"Use struct sctp_sack_info instead\n");
25832584
if (copy_from_user(&params, optval, optlen))
25842585
return -EFAULT;
25852586

@@ -2994,8 +2995,9 @@ static int sctp_setsockopt_maxseg(struct sock *sk, char __user *optval, unsigned
29942995
int val;
29952996

29962997
if (optlen == sizeof(int)) {
2997-
pr_warn("Use of int in maxseg socket option deprecated\n");
2998-
pr_warn("Use struct sctp_assoc_value instead\n");
2998+
pr_warn_ratelimited(DEPRECATED
2999+
"Use of int in maxseg socket option.\n"
3000+
"Use struct sctp_assoc_value instead\n");
29993001
if (copy_from_user(&val, optval, optlen))
30003002
return -EFAULT;
30013003
params.assoc_id = 0;
@@ -3252,8 +3254,9 @@ static int sctp_setsockopt_maxburst(struct sock *sk,
32523254
int assoc_id = 0;
32533255

32543256
if (optlen == sizeof(int)) {
3255-
pr_warn("Use of int in max_burst socket option deprecated\n");
3256-
pr_warn("Use struct sctp_assoc_value instead\n");
3257+
pr_warn_ratelimited(DEPRECATED
3258+
"Use of int in max_burst socket option deprecated.\n"
3259+
"Use struct sctp_assoc_value instead\n");
32573260
if (copy_from_user(&val, optval, optlen))
32583261
return -EFAULT;
32593262
} else if (optlen == sizeof(struct sctp_assoc_value)) {
@@ -4573,8 +4576,9 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
45734576
if (copy_from_user(&params, optval, len))
45744577
return -EFAULT;
45754578
} else if (len == sizeof(struct sctp_assoc_value)) {
4576-
pr_warn("Use of struct sctp_assoc_value in delayed_ack socket option deprecated\n");
4577-
pr_warn("Use struct sctp_sack_info instead\n");
4579+
pr_warn_ratelimited(DEPRECATED
4580+
"Use of struct sctp_assoc_value in delayed_ack socket option.\n"
4581+
"Use struct sctp_sack_info instead\n");
45784582
if (copy_from_user(&params, optval, len))
45794583
return -EFAULT;
45804584
} else
@@ -5218,8 +5222,9 @@ static int sctp_getsockopt_maxseg(struct sock *sk, int len,
52185222
struct sctp_association *asoc;
52195223

52205224
if (len == sizeof(int)) {
5221-
pr_warn("Use of int in maxseg socket option deprecated\n");
5222-
pr_warn("Use struct sctp_assoc_value instead\n");
5225+
pr_warn_ratelimited(DEPRECATED
5226+
"Use of int in maxseg socket option.\n"
5227+
"Use struct sctp_assoc_value instead\n");
52235228
params.assoc_id = 0;
52245229
} else if (len >= sizeof(struct sctp_assoc_value)) {
52255230
len = sizeof(struct sctp_assoc_value);
@@ -5310,8 +5315,9 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len,
53105315
struct sctp_association *asoc;
53115316

53125317
if (len == sizeof(int)) {
5313-
pr_warn("Use of int in max_burst socket option deprecated\n");
5314-
pr_warn("Use struct sctp_assoc_value instead\n");
5318+
pr_warn_ratelimited(DEPRECATED
5319+
"Use of int in max_burst socket option.\n"
5320+
"Use struct sctp_assoc_value instead\n");
53155321
params.assoc_id = 0;
53165322
} else if (len >= sizeof(struct sctp_assoc_value)) {
53175323
len = sizeof(struct sctp_assoc_value);

0 commit comments

Comments
 (0)