Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1518667iog; Tue, 14 Jun 2022 07:38:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s9SI6xHiTlb9WtcyVZ9jLtbbp+M0cVYVAsQSpxBqvVCCpHHSW6mJ6H0NGAmnLSehzvj55Q X-Received: by 2002:a05:6a00:2390:b0:51c:21e1:782 with SMTP id f16-20020a056a00239000b0051c21e10782mr5069732pfc.21.1655217536201; Tue, 14 Jun 2022 07:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655217536; cv=none; d=google.com; s=arc-20160816; b=u6NLmAiKMExFXAfD5jW89XwhHA/4YLXg3FxX5TV4U7cXgXioza9C5braf3IE1Ndjzf isdbgSZ/tl2iMwhKQe0OSnTOLZCk78qrugvsBIYc2CxikBZXQM+pZCQS0QAN/iivBFi9 s+LBKER6ldtY/4WdBCwvzWUM1S0hsb8+lkS0RREp0mU5v+IvnaY/NRzqmRiLUHksa2Yr QwfJR5bMvKDP4OoNdp0jPkyOI7+L0W03eKrSzSghRl4mVv4V6Ag+QEsbbRo2D1o9Tqr4 MvUHoekKEIp9tzvpQaGGUtK7OmvplNMNHCcnZqYaUPuEgBbZuXrQ+YAArx5fFswHGvya 0gMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0up0HQhrsxc90C88YMmJQmlVHMrBI86sKQklFU28KR8=; b=O3v8nLuj8vSIaHjup0/vqtgVYhS3iBJxicGLYLkL9QXIglG8dixEQZzInQj/K8EXXo byJ0rf6+dtobX79yLDjUen8/r28bsgUZg56ii68aZz7ru6kXMtdHvPLdQd8WqWYoI4Zw k8y6PzS7aTBqWdA7LAYTy+Ej2t5hUMYCZXx8SlKAmZJSGOacMiXLZsSJTJl3N3X1cEuR ZddsMXL4V1MzZdYWLg9feJHcCbCKwBZxr1zzuRWLNP7Q+q6k3b0eVBGxyYLT9DfWLEAI Q1X1fQ9l15y2wSTQEIEJLA8B49eA8uGJIkpnmSMl9pq4T8toB9ClmHr3KHZYBxSzgaD4 0RBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crudebyte.com header.s=kylie header.b=Hp1+8w4P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j11-20020a63230b000000b004019a45b5easi13622286pgj.747.2022.06.14.07.38.42; Tue, 14 Jun 2022 07:38:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@crudebyte.com header.s=kylie header.b=Hp1+8w4P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=crudebyte.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237980AbiFNOLr (ORCPT + 99 others); Tue, 14 Jun 2022 10:11:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236262AbiFNOLq (ORCPT ); Tue, 14 Jun 2022 10:11:46 -0400 Received: from kylie.crudebyte.com (kylie.crudebyte.com [5.189.157.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC6F344C8; Tue, 14 Jun 2022 07:11:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Content-Type:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Content-ID:Content-Description; bh=0up0HQhrsxc90C88YMmJQmlVHMrBI86sKQklFU28KR8=; b=Hp1+8w4PUY58i0Tlkd3yeyLr1t d+416tMt71AkGKbx1PRjrgGubVu2CXrnBDpBbOFaBdEqpkvYB8C6w0aNophxcs4gWQR/KIi23kUYS eqjPJOORRCQ6F8TvdPT1A4BrmbM94f4UU15NqaO8OhfRs9kLxSkms6mHkPz0uGdIBaAkgiPHvSLs4 ODNsEb4eEx0Z5cMEzrgDmqfDAA9slhFg/jpbigImbW9YKf+EKQHLrU961QQpO96oP5oz4GgzE9G0Y rSE0lUykUF5rhIZ/Mtf2q8mCxqjJO5cfB2r/YAeutwggT/qTVApUrNSQtSyZk1V0iOte8BdAD1PQc yvesVwal19dT9zYIdQ56uNLn9Kurfr7tiBLrfQC1upVxd/OkXfVJJ3OMskAf8O61wVRlGWUwH8exR MUge0IC5VloTMaquBTx2Ar46bMg1RyoRrYfyeLUj+MwtwbvwN3SdgGRXwbjS6nQ6/DnS9cC8RuCeT NuSia+FFUU/KTMyKGeQQ4t1ufx4/736ogVnN3cIkPnDkm+jnMVMpdElh9vrOQeOw1DrUxSs81vwyJ h4PRMK2TxpwLa+4YAkGqSNjsSr5tmjpddr7jWVsakCBVVZcaVjRpq/shELYc6KDRLkvWr1jRQds5L VzX8eOOz15rMBARpKWHy3gPVUNq1YCLWDmZv6YE9c=; From: Christian Schoenebeck To: Dominique Martinet Cc: Eric Van Hensbergen , Latchesar Ionkov , David Howells , linux-fsdevel@vger.kernel.org, stable@vger.kernel.org, v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] 9p: fix EBADF errors in cached mode Date: Tue, 14 Jun 2022 16:11:35 +0200 Message-ID: <1796737.mFSqR1lx0c@silver> In-Reply-To: References: <19026878.01OTk6HtWb@silver> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Dienstag, 14. Juni 2022 14:45:38 CEST Dominique Martinet wrote: > Christian Schoenebeck wrote on Tue, Jun 14, 2022 at 02:10:01PM +0200: > > It definitely goes into the right direction, but I think it's going a bit > > too far by using writeback_fid also in cases where it is not necessary > > and wasn't used before in the past. > > Would help if I had an idea of what was used where in the past.. :) > > From a quick look at the code, checking out v5.10, > v9fs_vfs_writepage_locked() used the writeback fid always for all writes > v9fs_vfs_readpages is a bit more complex but only seems to be using the > "direct" private_data fid for reads... > It took me a bit of time but I think the reads you were seeing on > writeback fid come from v9fs_write_begin that does some readpage on the > writeback fid to populate the page before a non-filling write happens. Yes, the overall picture in the past was not clear to me either. To be more specific, I was reading your patch as if it would e.g. also use the writeback_fid if somebody explicitly called read() (i.e. not an implied read caused by a partial write back), and was concerned about a potential privilege escalation. Maybe it's just a theoretical issue, as this case is probably already catched on a higher, general fs handling level, but worth consideration. > > What about something like this in v9fs_init_request() (yet untested): > > /* writeback_fid is always opened O_RDWR (instead of just O_WRONLY) > > > > * explicitly for this case: partial write backs that require a read > > * prior to actual write and therefore requires a fid with read > > * capability. > > */ > > > > if (rreq->origin == NETFS_READ_FOR_WRITE) > > > > fid = v9inode->writeback_fid; > > ... Which seems to be exactly what this origin is about, so if that > works I'm all for it. > > > If desired, this could be further constrained later on like: > > if (rreq->origin == NETFS_READ_FOR_WRITE && > > > > (fid->mode & O_ACCMODE) == O_WRONLY) > > > > { > > > > fid = v9inode->writeback_fid; > > > > } > > That also makes sense, if the fid mode has read permissions we might as > well use these as the writeback fid would needlessly be doing root IOs. > > > I will definitely give these options some test spins here, a short > > feedback > > ahead would be appreciated though. > > Please let me know how that works out, I'd be happy to use either of > your versions instead of mine. > If I can be greedy though I'd like to post it together with the other > couple of fixes next week, so having something before the end of the > week would be great -- I think even my first overkill version early and > building on it would make sense at this point. > > But I think you've got the right end, so hopefully won't be needing to > delay I need a day or two for testing, then I will report back for sure. So it should perfectly fit into your intended schedule. Thanks! Best regards, Christian Schoenebeck