From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 607D7C433E0 for ; Thu, 6 Aug 2020 17:25:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2F3B23119 for ; Thu, 6 Aug 2020 17:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729840AbgHFRY5 (ORCPT ); Thu, 6 Aug 2020 13:24:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729842AbgHFRDY (ORCPT ); Thu, 6 Aug 2020 13:03:24 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D2D8C061A19; Thu, 6 Aug 2020 05:09:12 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1k3ehe-00ATwx-OM; Thu, 06 Aug 2020 12:08:58 +0000 Date: Thu, 6 Aug 2020 13:08:58 +0100 From: Al Viro To: linmiaohe Cc: davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] net: Set fput_needed iff FDPUT_FPUT is set Message-ID: <20200806120858.GA2497432@ZenIV.linux.org.uk> References: <1596714796-25298-1-git-send-email-linmiaohe@huawei.com> <20200806115915.GO1236603@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200806115915.GO1236603@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 06, 2020 at 12:59:16PM +0100, Al Viro wrote: > On Thu, Aug 06, 2020 at 07:53:16PM +0800, linmiaohe wrote: > > From: Miaohe Lin > > > > We should fput() file iff FDPUT_FPUT is set. So we should set fput_needed > > accordingly. > > > > Fixes: 00e188ef6a7e ("sockfd_lookup_light(): switch to fdget^W^Waway from fget_light") > > Explain, please. We are getting it from fdget(); what else can we get in flags there? FWIW, struct fd ->flags may have two bits set: FDPUT_FPUT and FDPUT_POS_UNLOCK. The latter is set only by __fdget_pos() and its callers, and that only for regular files and directories. Nevermind that sockfd_lookup_light() does *not* use ..._pos() family of primitives, even if it started to use e.g. fdget_pos() it *still* would not end up with anything other than FDPUT_FPUT to deal with on that path - it checks that what it got is a socket. Anything else is dropped right there, without leaving fput() to caller. So could you explain what exactly the bug is - if you are seeing some breakage and this patch fixes it, something odd is definitely going on and it would be nice to figure out what that something is.