Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2348847rwb; Wed, 30 Nov 2022 05:41:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fxJmEgn1obM47F3KZKOKci858UGfSPWvrptc72uhhz4dMoxcxmuxsmgQAhNRpi2CZjLlT X-Received: by 2002:a17:902:b407:b0:186:9c25:7ef0 with SMTP id x7-20020a170902b40700b001869c257ef0mr54379846plr.164.1669815687456; Wed, 30 Nov 2022 05:41:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815687; cv=none; d=google.com; s=arc-20160816; b=VVosNca8eK6BKO+QQCoJeCxNVWSPE3gWTirQXH0A/1hONtQHzfpn+82qCgkgiR70V5 aAAy6I+KhNimt7EcoFy0CudLD2CJ+Llr7G2BgZzl8d5l4rH/3Smlb0+KpLacqgGxxP+8 mkm8kh/1ln+SFDhoTfA1XJ/XC8fgy5GQ28znlYOIOaGI4E+hI0F8cX53QuaHR+oyX++x ii73LT+oH8JRBU57RBBdTgRIC0dOsk5juDqsVaFvWY6i8tCcYyFCiJzoG6EdvzG2PqcH YnK+oojWjwTWOBoejDJ6dzOhIhs4Ni/imHDBUHaHo0t5vGFEDk2kTh/RN0lOCJ/bzBeY +Wbg== 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=a26lIzJ4dptbrOGi0GFPN+IgCtoaj1aHi7+e9iGicfE=; b=gzyvI+Ptyz1yTDIuGn0kEa6kY6fN2KGtIzy0/3sP29TfOye4ccxPzfOX7HpFwmwCWs OD/kXjamuZSbQ/e6zWV29cziunG76KPvUGFgrTd94fBltVc1yp/mo887X/++PWxzAd9f Fhc6gzFix+QgGG4BVG0Cnp5wiiPEHmTaDGpRvIDMQnTtNKMhHQ6b/0mzbHJxPaKeImGU f8k80vjlWltQcptz/yO5ehBcq3J4FDl9TDbUbcGL7sASQwgAMU9smu19IA57QY5avykn RPPcMP/IvxVpFEFbhOPPhgUfwhAB74/jXjK+3Wwe4x0MSEgY8lK+mYbQLRjcg6YKdchD iW9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crudebyte.com header.s=kylie header.b="Kh/Dn3L6"; 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 w21-20020a17090aea1500b0020087bc6415si4384305pjy.16.2022.11.30.05.41.14; Wed, 30 Nov 2022 05:41:27 -0800 (PST) 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="Kh/Dn3L6"; 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 S232757AbiK3N0Q (ORCPT + 85 others); Wed, 30 Nov 2022 08:26:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiK3N0P (ORCPT ); Wed, 30 Nov 2022 08:26:15 -0500 Received: from kylie.crudebyte.com (kylie.crudebyte.com [5.189.157.229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EC7450D41; Wed, 30 Nov 2022 05:26:13 -0800 (PST) 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=a26lIzJ4dptbrOGi0GFPN+IgCtoaj1aHi7+e9iGicfE=; b=Kh/Dn3L6ycIIXU8wsJwzKY4WSB n+TEVb/X6z4AQG7GQETxE4KLClWaBBdYGqh3moY/8eXeLWYyzYVdJYrKl9VwdRA5DqNr6UvAkwmfU 1mhRdHE7RYfBbJch9V3b0RNBzWimGXhpAw2ALBYb+9msmuVLi5dfZJtLF6F2LjHZq0yZE+chlJARm 8uXqBLI+5D9/1knP7f3r62PqMHC2o4v9QLjHSAXjAQL8hcGvIqCYxOxZpdGAGaMPBo+LQu+4dAISS T6Vyfh3srdvx9KXruov3YrsZ3KfK1jyGrENJZKCjruMqWNQwVTNgLrCsOTZFfNXi2jtxV+ZOusJPq ynaNQii5LHhImkDbtw5BUzCAaCQ569TzySiksa4vynILiD9/WD1AlTFQH5cREfi8eBeLycPrild1X NlDRCAQQjE7dM7MYT8ULcvKcCmzn6ZG70UncJlxMitrUfKlCGxN09UO2PP31I1xgbm/kY44vRqyNc jwMRvUtQL/h1tBPwHktbtGBCj1xnyFBi7flXuDcrBLnOhWCEvUzX7jBRE6Y7TJPtt6flhTqzPAAuK q054eLNaGDGQCbPxRpoHATanim4e1XBYxMswLuxOo2Ho28gqyBgxYJu5IZhkeBMTkm7JFt6kGD4kV l/m7NFeqp6tLl4Q0DtONOEybY/kpXJGTn+4OeakxE=; From: Christian Schoenebeck To: asmadeus@codewreck.org Cc: Schspa Shi , ericvh@gmail.com, lucho@ionkov.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+8f1060e2aaf8ca55220b@syzkaller.appspotmail.com Subject: Re: [PATCH] 9p: fix crash when transaction killed Date: Wed, 30 Nov 2022 14:25:59 +0100 Message-ID: <4084178.bTz7GqEF8p@silver> In-Reply-To: References: <20221129162251.90790-1-schspa@gmail.com> <2356667.R3SNuAaExM@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 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 Wednesday, November 30, 2022 1:54:21 PM CET asmadeus@codewreck.org wrote: > Christian Schoenebeck wrote on Wed, Nov 30, 2022 at 01:43:20PM +0100: > > > > As for the release case, the next request will have the same tag with > > > > high probability. It's better to make the tag value to be an increase > > > > sequence, thus will avoid very much possible req reuse. > > > > > > I'd love to be able to do this, but it would break some servers that > > > assume tags are small (e.g. using it as an index for a tag array) > > > ... I thought nfs-ganesha was doing this but they properly put in in > > > buckets, so that's one less server to worry about, but I wouldn't put > > > it past some simple servers to do that; having a way to lookup a given > > > tag for flush is an implementation requirement. > > > > I really think it's time to emit tag number sequentially. If it turns out that > > it's a server that is broken, we could then simply ignore replies with old/ > > unknown tag number. It would also help a lot when debugging 9p issues in > > general when you know tag numbers are not re-used (in near future). > > > > A 9p server must not make any assumptions how tag numbers are generated by > > client, whether dense or sparse, or whatever. If it does then server is > > broken, which is much easier to fix than synchronization issues we have to > > deal with like this one. > > Well, it's a one line change: just replace the idr_alloc in the else > branch of p9_tag_alloc with idr_alloc_cyclic. > But linux has an history of not breaking userspace, even if it's broken. > One could argue that the server side of a networked protocol isn't > as tightly coupled but I still think we should be careful with it -- > adding a new mount option to rever to the old behaviour at the very > least. +1 for the mount option. > I'm also not convinced it'd fix anything here, we're not talking about a > real server but about a potential attacker -- if a reply comes in with > the next tag while we're allocating it, we'll get the exact same problem > as we have right now. > Frankly, 9p has no security at all so I'm not sure this is something we > really need to worry about, but bugs are bugs so we might as well fix > them if someone has the time for that... > > Anyway, I can appreciate that logs will definitely be easier to read, so > an option to voluntarily switch to cyclic allocation would be more than > welcome as a first step and shouldn't be too hard to do... I would actually do it the other way around: generating continuous sequential tags by default and only reverting back to dense tags if requested by mount option. Is there any server implementation known to rely on current dense tag generation? If there is really some exotic server somewhere that uses e.g. a simple constant size array to lookup tags and nobody is able to replace that array by a hash table or something for whatever reason, then I am pretty sure that server is limited at other ends as well (e.g. small 'msize'). So what we could do is adjusting the default behaviour according to the other side and allow to explicitly set both sequential and dense tags by mount option (i.e. not just a boolean mount option). Best regards, Christian Schoenebeck