mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] af_unix: missing lock releases in af_unix.c
       [not found] <20220103135830.59118-1-ycaibb@gmail.com>
@ 2022-01-03 18:43 ` Shoaib Rao
  2022-01-05  9:19   ` Ryan Cai
  0 siblings, 1 reply; 2+ messages in thread
From: Shoaib Rao @ 2022-01-03 18:43 UTC (permalink / raw)
  To: Ryan Cai, davem, kuba, ast, daniel, andrii, kafai,
	songliubraving, yhs, john.fastabend, kpsingh, cong.wang, viro,
	edumazet, jiang.wang, christian.brauner, kuniyu
  Cc: netdev, linux-kernel, bpf


On 1/3/22 05:58, Ryan Cai wrote:
> In method __unix_dgram_recvmsg, the lock u->iolock is not released when skb is true and loop breaks.
>
> Signed-off-by: Ryan Cai <ycaibb@gmail.com>
> ---
>   net/unix/af_unix.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index b0bfc78e421c..b97972948d9d 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -2305,6 +2305,7 @@ int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size,
>   		if (skb) {
>   			if (!(flags & MSG_PEEK))
>   				scm_stat_del(sk, skb);
> +			mutex_unlock(&u->iolock);
>   			break;
>   		}
>   

It seems to me that the unlock at the end will release the mutex?

out_free:
         skb_free_datagram(sk, skb);
         mutex_unlock(&u->iolock);

Shoaib


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] af_unix: missing lock releases in af_unix.c
  2022-01-03 18:43 ` [PATCH] af_unix: missing lock releases in af_unix.c Shoaib Rao
@ 2022-01-05  9:19   ` Ryan Cai
  0 siblings, 0 replies; 2+ messages in thread
From: Ryan Cai @ 2022-01-05  9:19 UTC (permalink / raw)
  To: Shoaib Rao, davem, kuba, ast, daniel, andrii, kafai,
	songliubraving, yhs, john.fastabend, kpsingh, cong.wang, viro,
	edumazet, jiang.wang, christian.brauner, kuniyu
  Cc: netdev, linux-kernel, bpf

Hi, Shoaib

          After further checking, the lock is indeed released at the out_free. My patch is invalid. Sorry for the inconvenience.

Best,
Ryan

On 4/1/2022, 2:47 AM, "Shoaib Rao" <rao.shoaib@oracle.com> wrote:


    On 1/3/22 05:58, Ryan Cai wrote:
    > In method __unix_dgram_recvmsg, the lock u->iolock is not released when skb is true and loop breaks.
    >
    > Signed-off-by: Ryan Cai <ycaibb@gmail.com>
    > ---
    >   net/unix/af_unix.c | 1 +
    >   1 file changed, 1 insertion(+)
    >
    > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
    > index b0bfc78e421c..b97972948d9d 100644
    > --- a/net/unix/af_unix.c
    > +++ b/net/unix/af_unix.c
    > @@ -2305,6 +2305,7 @@ int __unix_dgram_recvmsg(struct sock *sk, struct msghdr *msg, size_t size,
    >   		if (skb) {
    >   			if (!(flags & MSG_PEEK))
    >   				scm_stat_del(sk, skb);
    > +			mutex_unlock(&u->iolock);
    >   			break;
    >   		}
    >   

    It seems to me that the unlock at the end will release the mutex?

    out_free:
             skb_free_datagram(sk, skb);
             mutex_unlock(&u->iolock);

    Shoaib




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-05  9:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220103135830.59118-1-ycaibb@gmail.com>
2022-01-03 18:43 ` [PATCH] af_unix: missing lock releases in af_unix.c Shoaib Rao
2022-01-05  9:19   ` Ryan Cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®