Skip to contentSkip to conversation

bpf, sockmap: convert to generic sk_msg interface

bug report Dan Carpenter 3 participants 3 messages Oct 14, 2019 BPF

lore
Share & tools
lore
#0 lore raw

Hello Daniel Borkmann,

This is a semi-automatic email about new static checker warnings.

The patch 604326b41a6f: "bpf, sockmap: convert to generic sk_msg interface" from Oct 13, 2018, leads to the following Smatch complaint:

net/core/skmsg.c:792 sk_psock_write_space()
error: we previously assumed 'psock' could be null (see line 790)

net/core/skmsg.c
789 psock = sk_psock(sk);
790 if (likely(psock && sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)))

                           ^^^^^

Check for NULL

   791			schedule_work(&psock->work);
   792		write_space = psock->saved_write_space;
                              ^^^^^^^^^^^^^^^^^^^^^^^^

793 rcu_read_unlock();

   794		write_space(sk);
                ^^^^^^^^^^^^^^

The warning is on the wrong line. The dereference is really here.

regards,
dan carpenter

#1 lore raw
Quoted 20 lines · Dan Carpenter

Hello Daniel Borkmann,

This is a semi-automatic email about new static checker warnings.

The patch 604326b41a6f: "bpf, sockmap: convert to generic sk_msg interface" from Oct 13, 2018, leads to the following Smatch complaint:

net/core/skmsg.c:792 sk_psock_write_space()
error: we previously assumed 'psock' could be null (see line 790)

net/core/skmsg.c

   789		psock = sk_psock(sk);
   790		if (likely(psock && sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)))
                           ^^^^^

Check for NULL

   791			schedule_work(&psock->work);
   792		write_space = psock->saved_write_space;
                              ^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 7 lines
   793		rcu_read_unlock();
   794		write_space(sk);
                ^^^^^^^^^^^^^^

The warning is on the wrong line. The dereference is really here.

regards,
dan carpenter

John, can you also take a look?

#2 lore raw
Quoted 21 lines · Martin Lau
Quoted 20 lines · Dan Carpenter

Hello Daniel Borkmann,

This is a semi-automatic email about new static checker warnings.

The patch 604326b41a6f: "bpf, sockmap: convert to generic sk_msg interface" from Oct 13, 2018, leads to the following Smatch complaint:

net/core/skmsg.c:792 sk_psock_write_space()
error: we previously assumed 'psock' could be null (see line 790)

net/core/skmsg.c

   789		psock = sk_psock(sk);
   790		if (likely(psock && sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)))
                           ^^^^^

Check for NULL

   791			schedule_work(&psock->work);
   792		write_space = psock->saved_write_space;
                              ^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 8 lines
Quoted 7 lines
   793		rcu_read_unlock();
   794		write_space(sk);
                ^^^^^^^^^^^^^^

The warning is on the wrong line. The dereference is really here.

regards,
dan carpenter

John, can you also take a look?

Thanks Dan, seems there is a chance we could have a null psock here so we need to wrap both dereferences in the 'if (psock)'. I'll send a patch.