Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2160633pxb; Fri, 25 Mar 2022 12:10:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxOH8V6rAlp1iAmlGTuBcMs7QZwTPSzDZcuZfD6BGTmrzE9DEQGJWBMTp84qKtv4tDExtL X-Received: by 2002:a63:2248:0:b0:382:1b3e:6336 with SMTP id t8-20020a632248000000b003821b3e6336mr781251pgm.271.1648235404108; Fri, 25 Mar 2022 12:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648235404; cv=none; d=google.com; s=arc-20160816; b=i7ChFXZHYOXUuvOyvMeGxOlWbH5tRYBccNHZJYBxvRtj/RRHd2pp1GA5qpoI6Xt43f EnKBPGqaHL/qorBEfbWzou3hhjrVZV3WkSm03o8Vvfrqcj2oUrfL4JGkOLc4RpOyHsIP DHhZxxP3++jLlB4NJSu06darXZFa+CgY37XfMb/EWryM3UHWKVASatqQcMzif66TZxHl uMsNt48OD701re48XKP/U2iMobNQtWpRAeRWAtzIrcxsAzgegmINrLHcXU7uSKSVG3z6 aqwOQcavgWQANPmuHmKA/0RlYL/NremC0nXzYfMgwNp9lRQF/64uDBi/1DIGccNTYpDM Afkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:references:in-reply-to:subject :cc:to:from:mime-version:content-transfer-encoding:dkim-signature :dkim-signature; bh=5wx0qIu9ySJlY3Psig10fHmn46QfAOeW8lCoFFHy1Wo=; b=JYzsZ06LVUtep4+mGbY1OJ5BThHM0ke+zMxTVnmuKRdXwumDF/9rH/NgjNsgZ1SYuX A8DrF/UULAHS44G2yuYWGZzwhHkxrROMnMSuMqZC9W39CqaaPpDH132fBn0yRtabAJ4p k/sIfjDQpEK5D/ZUajhfBLPaKSP6aD6UKV6Y+XwOeinuwNJkMeSBrO/3vAZCFtxuYzyE YHn1b/RT6/LXthBfNMatBRyVTVCNPODU+6m1pjkBhZRa0x/QNnF4TX+e1VjGfpFdtPa+ JdOLgirEprDuvot3XJNhfBcQdJQ6/ElCoSSwQ3TWJ0+U60+3GqdQCQ67UJ8YYZTq4fLy xC2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=unBvVjqS; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e2-20020a17090301c200b00153b2d16409si3561290plh.17.2022.03.25.12.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:10:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=unBvVjqS; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2D717208267; Fri, 25 Mar 2022 11:16:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245460AbiCYBur (ORCPT + 99 others); Thu, 24 Mar 2022 21:50:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243656AbiCYBuq (ORCPT ); Thu, 24 Mar 2022 21:50:46 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BFF865406 for ; Thu, 24 Mar 2022 18:49:13 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 895A3210F4; Fri, 25 Mar 2022 01:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1648172951; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5wx0qIu9ySJlY3Psig10fHmn46QfAOeW8lCoFFHy1Wo=; b=unBvVjqSCvyb94UVY2weTAdYj/JA4lpHrumr/UuyQKr4D9pHSYoQ5ierWsAphEkIDOBcD9 jAdWFeQJjiT3MZ8bE4HRYg1hpoGZIFzlBhU2wseZcVaJi8eUaqkfVTyCbRZMDj8TnCb1U3 RWqYiG7yvaqNF/QBqmTuFKydYX4QNzM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1648172951; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5wx0qIu9ySJlY3Psig10fHmn46QfAOeW8lCoFFHy1Wo=; b=l4vpKJdYiE9bntV1ayD4tpIwE//+1asXSJaHNnPhC5PNWiOfrhBHYtqDlc33p1KL/W7nd6 olCLli0BvZdoWBCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id ACAF51332D; Fri, 25 Mar 2022 01:49:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bFnGGZYfPWIadAAAMHmgww (envelope-from ); Fri, 25 Mar 2022 01:49:10 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: trondmy@kernel.org Cc: linux-nfs@vger.kernel.org Subject: Re: [PATCH v2 4/9] SUNRPC: Make the rpciod and xprtiod slab allocation modes consistent In-reply-to: <20220322011618.1052288-5-trondmy@kernel.org> References: <20220322011618.1052288-1-trondmy@kernel.org>, <20220322011618.1052288-2-trondmy@kernel.org>, <20220322011618.1052288-3-trondmy@kernel.org>, <20220322011618.1052288-4-trondmy@kernel.org>, <20220322011618.1052288-5-trondmy@kernel.org> Date: Fri, 25 Mar 2022 12:49:05 +1100 Message-id: <164817294549.6096.12941844979004220620@noble.neil.brown.name> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, 22 Mar 2022, trondmy@kernel.org wrote: > From: Trond Myklebust > > Make sure that rpciod and xprtiod are always using the same slab > allocation modes. > > Signed-off-by: Trond Myklebust .... > xs_stream_prepare_request(struct rpc_rqst *req) > { > xdr_free_bvec(&req->rq_rcv_buf); > - req->rq_task->tk_status = xdr_alloc_bvec(&req->rq_rcv_buf, GFP_KERNEL); > + req->rq_task->tk_status = xdr_alloc_bvec( > + &req->rq_rcv_buf, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); > } I did some testing of swap-over-NFS, and got a crash quite quickly, due to this change. The problem is that GFP_KERNEL allocations almost never fail. Multi-page allocations might occasionally fail, and others might fail for a process that has been killed by the OOM killer (or maybe just has a fatal signal pending), but in general GFP_KERNEL is more likely to wait (and wait and wait) than to fail. So the failure paths haven't been tested. xs_stream_prepare_request() is called from xprt_request_prepare(), which is called from xprt_request_enqueue_receive() which is called in call_encode() *after* ->tk_status has been tested. So when the above code sets ->tk_status to -ENOMEM - which is now more likely - that fact is ignored and we get a crash [ 298.911356] Workqueue: xprtiod xs_stream_data_receive_workfn [ 298.911696] RIP: 0010:_copy_to_iter+0x1cc/0x435 .. [ 298.918259] __skb_datagram_iter+0x64/0x225 [ 298.918507] skb_copy_datagram_iter+0xe9/0xf2 [ 298.918767] tcp_recvmsg_locked+0x653/0x77e [ 298.919015] tcp_recvmsg+0x100/0x188 [ 298.919226] inet_recvmsg+0x5d/0x86 [ 298.919431] xs_read_stream_request.constprop.0+0x247/0x378 [ 298.919754] xs_read_stream.constprop.0+0x1c2/0x39b [ 298.920038] xs_stream_data_receive_workfn+0x50/0x160 [ 298.920331] process_one_work+0x267/0x422 [ 298.920568] worker_thread+0x193/0x234 So we really need to audit all these places where we add __GFP_NORETRY and ensure errors are actually handled. For call_encode(), it might be easiest to move /* Add task to reply queue before transmission to avoid races */ if (rpc_reply_expected(task)) xprt_request_enqueue_receive(task); up before the /* Did the encode result in an error condition? */ if (task->tk_status != 0) { and change it to /* Add task to reply queue before transmission to avoid races */ if (task->tk_status == 0 && rpc_reply_expected(task)) xprt_request_enqueue_receive(task); I'll try a bit more testing and auditing. Thanks, NeilBrown