Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp496443rwd; Wed, 31 May 2023 01:01:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7n4ygsk5ZtcPGTwGBo3EAmr8tMyBH5GCef46x04GofI/ub7rqyphR63PbmLvttvn0jq6yH X-Received: by 2002:a9d:7443:0:b0:6af:9e5b:54c1 with SMTP id p3-20020a9d7443000000b006af9e5b54c1mr1443182otk.34.1685520090230; Wed, 31 May 2023 01:01:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685520090; cv=none; d=google.com; s=arc-20160816; b=z2XpOZXW+VNkmeY1HKQuDT9RZyo09JXh8Uika0d4zh1QZkCyZ5TPXg6dTsqY/kZdjd mSOdg+CU9magw7185B8VoJoQKpw/juXCdcA4V0wtnQqKf5+mbepGgK5VYrifmw6xSYSt VqDuXIKffq7BgmmhPRpjQfqe92uOSWxpc7ZkEaxc71ZdZIAshP/kH4CVRuzJd74WApuu CzM3rmK/5IaFusc8jr4eNiBrYB0f3A6/rNl6uvNBdrWXbeyYKg99YpyB4H90Kg9FmC/2 p+UuuCyfGQfce9comDMV3nmUcSUj7Pqfj5iLEAfgFc1Pb6SOAvZlgoTNiCjPTl65mowM i+ZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LGoVMkHiLGD64s03Y6+AFjuEJ/YkfPkSNgwpozijN6E=; b=OIulfmL4mq+FGVGvDSngJfWiwKvMhFmgtvH5hVJyEsbc5/i/QmM5Uv4NrzZucwSC9t MILWiCo8rq9CAs08WgWSmEnJNDWvR9/tbzNd8LcuywP7hSDIKC6TYbMFTZWGj+2J8R3l 7K9Vf/l0+spi2kKVwUiLEBrno5i15Y07jVjr1p60d71EnKch72DOtNUz+tL2ipPPWt+s zZUYEBRKlxX9iGQJ3Jst1mlH9qawn4iDzBYwoCTmYmpExwa3uvW/qLqLnd3XJ3IrQapL 5fIwtqjPcdBXJs6b4yUsgSj3vGSQbFi/vgXeFWvSgkrlef+45zZx1FnASa2pvERyhpT4 Sxtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qpRVmSbM; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020aa793d1000000b0063b872934a4si3070909pff.340.2023.05.31.01.01.13; Wed, 31 May 2023 01:01:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qpRVmSbM; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234122AbjEaIBI (ORCPT + 99 others); Wed, 31 May 2023 04:01:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235095AbjEaH72 (ORCPT ); Wed, 31 May 2023 03:59:28 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E32E4C for ; Wed, 31 May 2023 00:58:58 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f623adec61so56959855e9.0 for ; Wed, 31 May 2023 00:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1685519937; x=1688111937; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LGoVMkHiLGD64s03Y6+AFjuEJ/YkfPkSNgwpozijN6E=; b=qpRVmSbM34qqrH3gCx8n/suiBR131xb9ZKYYmYExMuWV3Awb1ou96gvKFE8WKkLtWy 6ynBunEvz5k0ixVtgEpDcABbi1n57mZJZbs6ilqM8FMO+P5RzD2xBAjeKJT02Fq8lyfK POpe/MwOY4D58UyuaPJAhgZNxm0+O+Cqpoa5ZlQd2tE9wXmfHOo0EIRcB4zG7RDWNRs1 FZDRZlEJA/fMYbTUzYf8RlOvpAodqgxr//acmFAASaD8EcKa1CaqNfrccXDETzaLWwn4 P5WUgvzSn630/95baknVapsYOZTwgIrev04E6KJ6IBCY0NENQIewnXwSNuHnEcr4d08A UXgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685519937; x=1688111937; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LGoVMkHiLGD64s03Y6+AFjuEJ/YkfPkSNgwpozijN6E=; b=J5KTEvReSwi+k2eIQngyJLll9gKiNkR6bZgpWWNv4466jsAPmlFtnxuYA47uayzh67 KWTODzoDgSz1B3LMfHW8VNzEbiaEVfFhywRGpdALQCCaFzIT7TdDG71rTUPLzFZL02+a 1YO+fsIRJp0xu3cNlAAfEMiZd9yWqwBfODZgfVBL7y4XoBUOti2P+mvtSkSU3FB2mWFp v9lZZhewSO7kG+DOk2nvKyq9iJbwpIksMrxZR4SSRm6B3YKYoxvjNSvy8cL7w9/lOdUb XYHqKxrOhcPxUMzW95K9ceobEov4Vt2WD0XKeZB0I1QgQ8I+ZPu0otClSS1I9FXCYmyX +vnA== X-Gm-Message-State: AC+VfDziBEg7cihDwtaMjKESLPgcOfrwjXE4mK5N1HL/ZsO7XDgqBVn9 ISUrm3UyW8utt24qibpOzfuzlg== X-Received: by 2002:a05:600c:b44:b0:3f2:48dc:5e02 with SMTP id k4-20020a05600c0b4400b003f248dc5e02mr3192671wmr.27.1685519937097; Wed, 31 May 2023 00:58:57 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id s26-20020a7bc39a000000b003f42328b5d9sm19765106wmj.39.2023.05.31.00.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 00:58:54 -0700 (PDT) Date: Wed, 31 May 2023 10:58:51 +0300 From: Dan Carpenter To: NeilBrown Cc: Stanislav Kinsbursky , Chuck Lever , Jeff Layton , Trond Myklebust , Anna Schumaker , "J. Bruce Fields" , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] nfsd: fix double fget() bug in __write_ports_addfd() Message-ID: <9279444f-b113-41ad-afaa-c6b550104906@kili.mountain> References: <9c90e813-c7fb-4c90-b52b-131481640a78@kili.mountain> <168548566376.23533.14778348024215909777@noble.neil.brown.name> <58fd7e35-ba6c-432e-8e02-9c5476c854b4@kili.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <58fd7e35-ba6c-432e-8e02-9c5476c854b4@kili.mountain> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, May 31, 2023 at 10:48:09AM +0300, Dan Carpenter wrote: > err = nfsd_create_serv(net); > if (err != 0) > - return err; > + goto out_put_sock; > > - err = svc_addsock(nn->nfsd_serv, fd, buf, SIMPLE_TRANSACTION_LIMIT, cred); > + err = svc_addsock(nn->nfsd_serv, so, buf, SIMPLE_TRANSACTION_LIMIT, cred); > + if (err) > + goto out_put_net; Oops. This change is wrong. svc_addsock() actually does return positive values on success. > > - if (err >= 0 && > - !nn->nfsd_serv->sv_nrthreads && !xchg(&nn->keep_active, 1)) > + if (!nn->nfsd_serv->sv_nrthreads && !xchg(&nn->keep_active, 1)) > svc_get(nn->nfsd_serv); > > nfsd_put(net); > + return 0; Also wrong (same bug). > + > +out_put_net: > + nfsd_put(net); > +out_put_sock: > + sockfd_put(so); > return err; > } regards, dan carpenter