Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1474201

Re: kernel BUG at net/unix/garbage.c:149!"

From Hannes Frederic Sowa <hannes@stressinduktion.org>
Newsgroups linux.kernel
Subject Re: kernel BUG at net/unix/garbage.c:149!"
Date 2016-09-01 11:20 +0200
Message-ID <scwk9-7Sa-3@gated-at.bofh.it> (permalink)
References <s9Hvr-3yl-3@gated-at.bofh.it> <s9Odz-8ev-9@gated-at.bofh.it> <saIz8-2Vv-15@gated-at.bofh.it> <sbDnJ-4Pc-79@gated-at.bofh.it> <sbNn3-2ST-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 30.08.2016 11:18, Miklos Szeredi wrote:
> On Tue, Aug 30, 2016 at 12:37 AM, Miklos Szeredi <mszeredi@redhat.com> wrote:
>> On Sat, Aug 27, 2016 at 11:55 AM, Miklos Szeredi <mszeredi@redhat.com> wrote:
> 
>> crash> list -H gc_inflight_list unix_sock.link -s unix_sock.inflight |
>> grep counter | cut -d= -f2 | awk '{s+=$1} END {print s}'
>> 130
>> crash> p unix_tot_inflight
>> unix_tot_inflight = $2 = 135
>>
>> We've lost track of a total of five inflight sockets, so it's not a
>> one-off thing.  Really weird...  Now off to sleep, maybe I'll dream of
>> the solution.
> 
> Okay, found one bug: gc assumes that in-flight sockets that don't have
> an external ref can't gain one while unix_gc_lock is held.  That is
> true because unix_notinflight() will be called before detaching fds,
> which takes unix_gc_lock.  Only MSG_PEEK was somehow overlooked.  That
> one also clones the fds, also keeping them in the skb.  But through
> MSG_PEEK an external reference can definitely be gained without ever
> touching unix_gc_lock.
> 
> Not sure whether the reported bug can be explained by this.  Can you
> confirm the MSG_PEEK was used in the setup?
> 
> Does someone want to write a stress test for SCM_RIGHTS + MSG_PEEK?
> 
> Anyway, attaching a fix that works by acquiring unix_gc_lock in case
> of MSG_PEEK also.  It is trivially correct, but I haven't tested it.

You can use spin_unlock_wait in unix_gc_barrier to make it a bit more
lightweight.

Anyway, all of the scans on the socket receive queues are actually
protected by the appropriate locks again, I didn't see a way were we
could result in such a crash because of concurrent modification of the
receive queue. Do you have any hints or looked into this more closely?

Thanks,
Hannes

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: kernel BUG at net/unix/garbage.c:149!" Miklos Szeredi <mszeredi@redhat.com> - 2016-08-27 12:00 +0200
  Re: kernel BUG at net/unix/garbage.c:149!" Miklos Szeredi <mszeredi@redhat.com> - 2016-08-30 00:40 +0200
    Re: kernel BUG at net/unix/garbage.c:149!" Miklos Szeredi <mszeredi@redhat.com> - 2016-08-30 11:20 +0200
      Re: kernel BUG at net/unix/garbage.c:149!" Nikolay Borisov <kernel@kyup.com> - 2016-08-30 11:40 +0200
        Re: kernel BUG at net/unix/garbage.c:149!" Miklos Szeredi <mszeredi@redhat.com> - 2016-08-30 11:50 +0200
      Re: kernel BUG at net/unix/garbage.c:149!" Hannes Frederic Sowa <hannes@stressinduktion.org> - 2016-09-01 11:20 +0200

csiph-web