net/mptcp/protocol.c:538:6: warning: 'dfrag_collapsed' may be used uninitialized in this function
From: kbuild test robot
Date: Sat May 09 2020 - 00:50:19 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d5eeab8d7e269e8cfc53b915bccd7bd30485bcbf
commit: 3b1d6210a9577369103330b0d802b0bf74b65e7f mptcp: implement and use MPTCP-level retransmission
date: 6 weeks ago
config: x86_64-randconfig-a003-20200509 (attached as .config)
compiler: gcc-6 (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
reproduce:
git checkout 3b1d6210a9577369103330b0d802b0bf74b65e7f
# save the attached .config to linux build tree
make ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@xxxxxxxxx>
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
net/mptcp/protocol.c: In function 'mptcp_sendmsg_frag':
>> net/mptcp/protocol.c:538:6: warning: 'dfrag_collapsed' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (!dfrag_collapsed) {
^
vim +/dfrag_collapsed +538 net/mptcp/protocol.c
18b683bff89d46ac Paolo Abeni 2020-03-27 422
6d0060f600adfdda Mat Martineau 2020-01-21 423 static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
3f8e0aae17963634 Paolo Abeni 2020-03-27 424 struct msghdr *msg, struct mptcp_data_frag *dfrag,
3f8e0aae17963634 Paolo Abeni 2020-03-27 425 long *timeo, int *pmss_now,
57040755a3e43a1e Paolo Abeni 2020-01-21 426 int *ps_goal)
6d0060f600adfdda Mat Martineau 2020-01-21 427 {
18b683bff89d46ac Paolo Abeni 2020-03-27 428 int mss_now, avail_size, size_goal, offset, ret, frag_truesize = 0;
18b683bff89d46ac Paolo Abeni 2020-03-27 429 bool dfrag_collapsed, can_collapse = false;
6d0060f600adfdda Mat Martineau 2020-01-21 430 struct mptcp_sock *msk = mptcp_sk(sk);
6d0060f600adfdda Mat Martineau 2020-01-21 431 struct mptcp_ext *mpext = NULL;
3f8e0aae17963634 Paolo Abeni 2020-03-27 432 bool retransmission = !!dfrag;
57040755a3e43a1e Paolo Abeni 2020-01-21 433 struct sk_buff *skb, *tail;
6d0060f600adfdda Mat Martineau 2020-01-21 434 struct page_frag *pfrag;
3f8e0aae17963634 Paolo Abeni 2020-03-27 435 struct page *page;
3f8e0aae17963634 Paolo Abeni 2020-03-27 436 u64 *write_seq;
6d0060f600adfdda Mat Martineau 2020-01-21 437 size_t psize;
6d0060f600adfdda Mat Martineau 2020-01-21 438
6d0060f600adfdda Mat Martineau 2020-01-21 439 /* use the mptcp page cache so that we can easily move the data
6d0060f600adfdda Mat Martineau 2020-01-21 440 * from one substream to another, but do per subflow memory accounting
3f8e0aae17963634 Paolo Abeni 2020-03-27 441 * Note: pfrag is used only !retransmission, but the compiler if
3f8e0aae17963634 Paolo Abeni 2020-03-27 442 * fooled into a warning if we don't init here
6d0060f600adfdda Mat Martineau 2020-01-21 443 */
6d0060f600adfdda Mat Martineau 2020-01-21 444 pfrag = sk_page_frag(sk);
3f8e0aae17963634 Paolo Abeni 2020-03-27 445 while ((!retransmission && !mptcp_page_frag_refill(ssk, pfrag)) ||
6d0060f600adfdda Mat Martineau 2020-01-21 446 !mptcp_ext_cache_refill(msk)) {
6d0060f600adfdda Mat Martineau 2020-01-21 447 ret = sk_stream_wait_memory(ssk, timeo);
6d0060f600adfdda Mat Martineau 2020-01-21 448 if (ret)
6d0060f600adfdda Mat Martineau 2020-01-21 449 return ret;
18b683bff89d46ac Paolo Abeni 2020-03-27 450
18b683bff89d46ac Paolo Abeni 2020-03-27 451 /* if sk_stream_wait_memory() sleeps snd_una can change
18b683bff89d46ac Paolo Abeni 2020-03-27 452 * significantly, refresh the rtx queue
18b683bff89d46ac Paolo Abeni 2020-03-27 453 */
18b683bff89d46ac Paolo Abeni 2020-03-27 454 mptcp_clean_una(sk);
18b683bff89d46ac Paolo Abeni 2020-03-27 455
8ab183deb26a3b79 Paolo Abeni 2020-01-21 456 if (unlikely(__mptcp_needs_tcp_fallback(msk)))
8ab183deb26a3b79 Paolo Abeni 2020-01-21 457 return 0;
6d0060f600adfdda Mat Martineau 2020-01-21 458 }
3f8e0aae17963634 Paolo Abeni 2020-03-27 459 if (!retransmission) {
3f8e0aae17963634 Paolo Abeni 2020-03-27 460 write_seq = &msk->write_seq;
3f8e0aae17963634 Paolo Abeni 2020-03-27 461 page = pfrag->page;
3f8e0aae17963634 Paolo Abeni 2020-03-27 462 } else {
3f8e0aae17963634 Paolo Abeni 2020-03-27 463 write_seq = &dfrag->data_seq;
3f8e0aae17963634 Paolo Abeni 2020-03-27 464 page = dfrag->page;
3f8e0aae17963634 Paolo Abeni 2020-03-27 465 }
6d0060f600adfdda Mat Martineau 2020-01-21 466
6d0060f600adfdda Mat Martineau 2020-01-21 467 /* compute copy limit */
6d0060f600adfdda Mat Martineau 2020-01-21 468 mss_now = tcp_send_mss(ssk, &size_goal, msg->msg_flags);
57040755a3e43a1e Paolo Abeni 2020-01-21 469 *pmss_now = mss_now;
57040755a3e43a1e Paolo Abeni 2020-01-21 470 *ps_goal = size_goal;
57040755a3e43a1e Paolo Abeni 2020-01-21 471 avail_size = size_goal;
57040755a3e43a1e Paolo Abeni 2020-01-21 472 skb = tcp_write_queue_tail(ssk);
57040755a3e43a1e Paolo Abeni 2020-01-21 473 if (skb) {
57040755a3e43a1e Paolo Abeni 2020-01-21 474 mpext = skb_ext_find(skb, SKB_EXT_MPTCP);
57040755a3e43a1e Paolo Abeni 2020-01-21 475
57040755a3e43a1e Paolo Abeni 2020-01-21 476 /* Limit the write to the size available in the
57040755a3e43a1e Paolo Abeni 2020-01-21 477 * current skb, if any, so that we create at most a new skb.
57040755a3e43a1e Paolo Abeni 2020-01-21 478 * Explicitly tells TCP internals to avoid collapsing on later
57040755a3e43a1e Paolo Abeni 2020-01-21 479 * queue management operation, to avoid breaking the ext <->
57040755a3e43a1e Paolo Abeni 2020-01-21 480 * SSN association set here
57040755a3e43a1e Paolo Abeni 2020-01-21 481 */
57040755a3e43a1e Paolo Abeni 2020-01-21 482 can_collapse = (size_goal - skb->len > 0) &&
3f8e0aae17963634 Paolo Abeni 2020-03-27 483 mptcp_skb_can_collapse_to(*write_seq, skb, mpext);
57040755a3e43a1e Paolo Abeni 2020-01-21 484 if (!can_collapse)
57040755a3e43a1e Paolo Abeni 2020-01-21 485 TCP_SKB_CB(skb)->eor = 1;
57040755a3e43a1e Paolo Abeni 2020-01-21 486 else
57040755a3e43a1e Paolo Abeni 2020-01-21 487 avail_size = size_goal - skb->len;
57040755a3e43a1e Paolo Abeni 2020-01-21 488 }
18b683bff89d46ac Paolo Abeni 2020-03-27 489
3f8e0aae17963634 Paolo Abeni 2020-03-27 490 if (!retransmission) {
3f8e0aae17963634 Paolo Abeni 2020-03-27 491 /* reuse tail pfrag, if possible, or carve a new one from the
3f8e0aae17963634 Paolo Abeni 2020-03-27 492 * page allocator
18b683bff89d46ac Paolo Abeni 2020-03-27 493 */
18b683bff89d46ac Paolo Abeni 2020-03-27 494 dfrag = mptcp_rtx_tail(sk);
18b683bff89d46ac Paolo Abeni 2020-03-27 495 offset = pfrag->offset;
18b683bff89d46ac Paolo Abeni 2020-03-27 496 dfrag_collapsed = mptcp_frag_can_collapse_to(msk, pfrag, dfrag);
18b683bff89d46ac Paolo Abeni 2020-03-27 497 if (!dfrag_collapsed) {
18b683bff89d46ac Paolo Abeni 2020-03-27 498 dfrag = mptcp_carve_data_frag(msk, pfrag, offset);
18b683bff89d46ac Paolo Abeni 2020-03-27 499 offset = dfrag->offset;
18b683bff89d46ac Paolo Abeni 2020-03-27 500 frag_truesize = dfrag->overhead;
18b683bff89d46ac Paolo Abeni 2020-03-27 501 }
18b683bff89d46ac Paolo Abeni 2020-03-27 502 psize = min_t(size_t, pfrag->size - offset, avail_size);
6d0060f600adfdda Mat Martineau 2020-01-21 503
57040755a3e43a1e Paolo Abeni 2020-01-21 504 /* Copy to page */
6d0060f600adfdda Mat Martineau 2020-01-21 505 pr_debug("left=%zu", msg_data_left(msg));
18b683bff89d46ac Paolo Abeni 2020-03-27 506 psize = copy_page_from_iter(pfrag->page, offset,
3f8e0aae17963634 Paolo Abeni 2020-03-27 507 min_t(size_t, msg_data_left(msg),
3f8e0aae17963634 Paolo Abeni 2020-03-27 508 psize),
6d0060f600adfdda Mat Martineau 2020-01-21 509 &msg->msg_iter);
6d0060f600adfdda Mat Martineau 2020-01-21 510 pr_debug("left=%zu", msg_data_left(msg));
6d0060f600adfdda Mat Martineau 2020-01-21 511 if (!psize)
6d0060f600adfdda Mat Martineau 2020-01-21 512 return -EINVAL;
6d0060f600adfdda Mat Martineau 2020-01-21 513
d027236c41fd024d Paolo Abeni 2020-03-27 514 if (!sk_wmem_schedule(sk, psize + dfrag->overhead))
d027236c41fd024d Paolo Abeni 2020-03-27 515 return -ENOMEM;
3f8e0aae17963634 Paolo Abeni 2020-03-27 516 } else {
3f8e0aae17963634 Paolo Abeni 2020-03-27 517 offset = dfrag->offset;
3f8e0aae17963634 Paolo Abeni 2020-03-27 518 psize = min_t(size_t, dfrag->data_len, avail_size);
3f8e0aae17963634 Paolo Abeni 2020-03-27 519 }
d027236c41fd024d Paolo Abeni 2020-03-27 520
57040755a3e43a1e Paolo Abeni 2020-01-21 521 /* tell the TCP stack to delay the push so that we can safely
57040755a3e43a1e Paolo Abeni 2020-01-21 522 * access the skb after the sendpages call
6d0060f600adfdda Mat Martineau 2020-01-21 523 */
3f8e0aae17963634 Paolo Abeni 2020-03-27 524 ret = do_tcp_sendpages(ssk, page, offset, psize,
6d0060f600adfdda Mat Martineau 2020-01-21 525 msg->msg_flags | MSG_SENDPAGE_NOTLAST);
6d0060f600adfdda Mat Martineau 2020-01-21 526 if (ret <= 0)
6d0060f600adfdda Mat Martineau 2020-01-21 527 return ret;
18b683bff89d46ac Paolo Abeni 2020-03-27 528
18b683bff89d46ac Paolo Abeni 2020-03-27 529 frag_truesize += ret;
3f8e0aae17963634 Paolo Abeni 2020-03-27 530 if (!retransmission) {
6d0060f600adfdda Mat Martineau 2020-01-21 531 if (unlikely(ret < psize))
6d0060f600adfdda Mat Martineau 2020-01-21 532 iov_iter_revert(&msg->msg_iter, psize - ret);
6d0060f600adfdda Mat Martineau 2020-01-21 533
18b683bff89d46ac Paolo Abeni 2020-03-27 534 /* send successful, keep track of sent data for mptcp-level
18b683bff89d46ac Paolo Abeni 2020-03-27 535 * retransmission
18b683bff89d46ac Paolo Abeni 2020-03-27 536 */
18b683bff89d46ac Paolo Abeni 2020-03-27 537 dfrag->data_len += ret;
18b683bff89d46ac Paolo Abeni 2020-03-27 @538 if (!dfrag_collapsed) {
18b683bff89d46ac Paolo Abeni 2020-03-27 539 get_page(dfrag->page);
18b683bff89d46ac Paolo Abeni 2020-03-27 540 list_add_tail(&dfrag->list, &msk->rtx_queue);
3f8e0aae17963634 Paolo Abeni 2020-03-27 541 sk_wmem_queued_add(sk, frag_truesize);
3f8e0aae17963634 Paolo Abeni 2020-03-27 542 } else {
3f8e0aae17963634 Paolo Abeni 2020-03-27 543 sk_wmem_queued_add(sk, ret);
18b683bff89d46ac Paolo Abeni 2020-03-27 544 }
18b683bff89d46ac Paolo Abeni 2020-03-27 545
d027236c41fd024d Paolo Abeni 2020-03-27 546 /* charge data on mptcp rtx queue to the master socket
d027236c41fd024d Paolo Abeni 2020-03-27 547 * Note: we charge such data both to sk and ssk
d027236c41fd024d Paolo Abeni 2020-03-27 548 */
d027236c41fd024d Paolo Abeni 2020-03-27 549 sk->sk_forward_alloc -= frag_truesize;
3f8e0aae17963634 Paolo Abeni 2020-03-27 550 }
d027236c41fd024d Paolo Abeni 2020-03-27 551
57040755a3e43a1e Paolo Abeni 2020-01-21 552 /* if the tail skb extension is still the cached one, collapsing
57040755a3e43a1e Paolo Abeni 2020-01-21 553 * really happened. Note: we can't check for 'same skb' as the sk_buff
57040755a3e43a1e Paolo Abeni 2020-01-21 554 * hdr on tail can be transmitted, freed and re-allocated by the
57040755a3e43a1e Paolo Abeni 2020-01-21 555 * do_tcp_sendpages() call
57040755a3e43a1e Paolo Abeni 2020-01-21 556 */
57040755a3e43a1e Paolo Abeni 2020-01-21 557 tail = tcp_write_queue_tail(ssk);
57040755a3e43a1e Paolo Abeni 2020-01-21 558 if (mpext && tail && mpext == skb_ext_find(tail, SKB_EXT_MPTCP)) {
57040755a3e43a1e Paolo Abeni 2020-01-21 559 WARN_ON_ONCE(!can_collapse);
57040755a3e43a1e Paolo Abeni 2020-01-21 560 mpext->data_len += ret;
57040755a3e43a1e Paolo Abeni 2020-01-21 561 goto out;
57040755a3e43a1e Paolo Abeni 2020-01-21 562 }
57040755a3e43a1e Paolo Abeni 2020-01-21 563
6d0060f600adfdda Mat Martineau 2020-01-21 564 skb = tcp_write_queue_tail(ssk);
6d0060f600adfdda Mat Martineau 2020-01-21 565 mpext = __skb_ext_set(skb, SKB_EXT_MPTCP, msk->cached_ext);
6d0060f600adfdda Mat Martineau 2020-01-21 566 msk->cached_ext = NULL;
6d0060f600adfdda Mat Martineau 2020-01-21 567
6d0060f600adfdda Mat Martineau 2020-01-21 568 memset(mpext, 0, sizeof(*mpext));
3f8e0aae17963634 Paolo Abeni 2020-03-27 569 mpext->data_seq = *write_seq;
6d0060f600adfdda Mat Martineau 2020-01-21 570 mpext->subflow_seq = mptcp_subflow_ctx(ssk)->rel_write_seq;
6d0060f600adfdda Mat Martineau 2020-01-21 571 mpext->data_len = ret;
6d0060f600adfdda Mat Martineau 2020-01-21 572 mpext->use_map = 1;
6d0060f600adfdda Mat Martineau 2020-01-21 573 mpext->dsn64 = 1;
6d0060f600adfdda Mat Martineau 2020-01-21 574
6d0060f600adfdda Mat Martineau 2020-01-21 575 pr_debug("data_seq=%llu subflow_seq=%u data_len=%u dsn64=%d",
6d0060f600adfdda Mat Martineau 2020-01-21 576 mpext->data_seq, mpext->subflow_seq, mpext->data_len,
6d0060f600adfdda Mat Martineau 2020-01-21 577 mpext->dsn64);
6d0060f600adfdda Mat Martineau 2020-01-21 578
57040755a3e43a1e Paolo Abeni 2020-01-21 579 out:
3f8e0aae17963634 Paolo Abeni 2020-03-27 580 if (!retransmission)
18b683bff89d46ac Paolo Abeni 2020-03-27 581 pfrag->offset += frag_truesize;
3f8e0aae17963634 Paolo Abeni 2020-03-27 582 *write_seq += ret;
6d0060f600adfdda Mat Martineau 2020-01-21 583 mptcp_subflow_ctx(ssk)->rel_write_seq += ret;
6d0060f600adfdda Mat Martineau 2020-01-21 584
6d0060f600adfdda Mat Martineau 2020-01-21 585 return ret;
6d0060f600adfdda Mat Martineau 2020-01-21 586 }
6d0060f600adfdda Mat Martineau 2020-01-21 587
:::::: The code at line 538 was first introduced by commit
:::::: 18b683bff89d46ace55f12d00c0440d44d6160c4 mptcp: queue data for mptcp level retransmission
:::::: TO: Paolo Abeni <pabeni@xxxxxxxxxx>
:::::: CC: David S. Miller <davem@xxxxxxxxxxxxx>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip