Commit 2e67122
sctp: set frag_point in sctp_setsockopt_maxseg correctly
commit ecca8f8 upstream.
Now in sctp_setsockopt_maxseg user_frag or frag_point can be set with
val >= 8 and val <= SCTP_MAX_CHUNK_LEN. But both checks are incorrect.
val >= 8 means frag_point can even be less than SCTP_DEFAULT_MINSEGMENT.
Then in sctp_datamsg_from_user(), when it's value is greater than cookie
echo len and trying to bundle with cookie echo chunk, the first_len will
overflow.
The worse case is when it's value is equal as cookie echo len, first_len
becomes 0, it will go into a dead loop for fragment later on. In Hangbin
syzkaller testing env, oom was even triggered due to consecutive memory
allocation in that loop.
Besides, SCTP_MAX_CHUNK_LEN is the max size of the whole chunk, it should
deduct the data header for frag_point or user_frag check.
This patch does a proper check with SCTP_DEFAULT_MINSEGMENT subtracting
the sctphdr and datahdr, SCTP_MAX_CHUNK_LEN subtracting datahdr when
setting frag_point via sockopt. It also improves sctp_setsockopt_maxseg
codes.
Suggested-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reported-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 8555288 commit 2e67122
2 files changed
+21
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
| 437 | + | |
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3125 | 3125 | | |
3126 | 3126 | | |
3127 | 3127 | | |
| 3128 | + | |
3128 | 3129 | | |
3129 | 3130 | | |
3130 | | - | |
3131 | 3131 | | |
3132 | 3132 | | |
3133 | 3133 | | |
| |||
3143 | 3143 | | |
3144 | 3144 | | |
3145 | 3145 | | |
3146 | | - | |
| 3146 | + | |
3147 | 3147 | | |
| 3148 | + | |
3148 | 3149 | | |
3149 | | - | |
3150 | | - | |
| 3150 | + | |
| 3151 | + | |
3151 | 3152 | | |
3152 | | - | |
3153 | | - | |
3154 | | - | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
3155 | 3158 | | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
3156 | 3164 | | |
3157 | 3165 | | |
3158 | | - | |
3159 | | - | |
| 3166 | + | |
3160 | 3167 | | |
3161 | | - | |
| 3168 | + | |
3162 | 3169 | | |
3163 | 3170 | | |
3164 | 3171 | | |
3165 | 3172 | | |
| 3173 | + | |
| 3174 | + | |
3166 | 3175 | | |
3167 | 3176 | | |
3168 | 3177 | | |
| |||
0 commit comments