From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752268AbcJDBvI (ORCPT ); Mon, 3 Oct 2016 21:51:08 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:52738 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751259AbcJDBvH (ORCPT ); Mon, 3 Oct 2016 21:51:07 -0400 Date: Mon, 03 Oct 2016 21:51:03 -0400 (EDT) Message-Id: <20161003.215103.2267442887041931968.davem@davemloft.net> To: mszeredi@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, hannes@stressinduktion.org, kernel@kyup.com Subject: Re: [PATCH] af_unix: fix garbage collect vs. MSG_PEEK From: David Miller In-Reply-To: <1475150954-10152-1-git-send-email-mszeredi@redhat.com> References: <1475150954-10152-1-git-send-email-mszeredi@redhat.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 03 Oct 2016 18:51:07 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi Date: Thu, 29 Sep 2016 14:09:14 +0200 > @@ -1550,6 +1550,17 @@ static int unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb) > return max_level; > } > > +static void unix_peek_fds(struct scm_cookie *scm, struct sk_buff *skb) > +{ > + scm->fp = scm_fp_dup(UNIXCB(skb).fp); > + /* > + * During garbage collection it is assumed that in-flight sockets don't > + * get a new external reference. So we need to wait until current run > + * finishes. > + */ > + unix_gc_barrier(); > +} ... > @@ -266,6 +266,11 @@ void wait_for_unix_gc(void) > wait_event(unix_gc_wait, gc_in_progress == false); > } > > +void unix_gc_barrier(void) > +{ > + spin_unlock_wait(&unix_gc_lock); > +} Can you explain why wait_for_unix_gc() isn't appropriate? I'm a little bit uncomfortable with a spinlock wait like this, and would rather see something like the existing helper used. Thanks.