Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2335261rwb; Wed, 30 Nov 2022 05:31:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7UtoNE5urBBdM2qxPvNMYAuH/8pwxuZJdtNLVogZjZgnHHXjwr2wOc1g3HlGupP2xhQvWx X-Received: by 2002:a05:6402:3ce:b0:469:40c:ecfb with SMTP id t14-20020a05640203ce00b00469040cecfbmr52489673edw.164.1669815117660; Wed, 30 Nov 2022 05:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669815117; cv=none; d=google.com; s=arc-20160816; b=HsZI0EEQNd1H7rMRsZCQhDXkviK36dO1b0v77M/tZaZZKMNGOlXGaP4Eh8OsHvVg7k LejILN4RF3rWa+v6SVrH6+vdYaAldB6RyfiJ7ga8taA0gKrk+TomupnDH18laVug6S4c hbxwwHdFdn8BT78enj7LuDgGGZs6MpWwkSpOoDwvwA2r5XQlzd730rTp4r1a+gekSDNu dLkv6v4lTmv4Zpz2EswU8Uo13brXBPmBejRdNredPfOAm+/jvblGmALPckP2OR69U64z VUMas0xMogmMUKpiU0A8nNKwf7dV8oaY3HcQMdT48JkVprnWLBI1CXhnxX1AGiIPBteO o4pw== 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 :dkim-signature; bh=sh34+7lh2fTDO49r8VZu83HKmBn9XRjerEgAkN6tIEM=; b=OE7VhZzbDSmGxw2LRL2v4LivkqVRzuNPNe62GJavFWXp5QFVadPYxXPiitQSzW7965 lMuuZXVWzkIr1tD51aHRLyA1tvcbtDUdrgDN1DCsOdfeFlG9/s6CEnDFOqeoGLdkV/z8 1Ia2LVVH+TVINIouxjvo56ehi3AMmsJQUK7ICq0Qcy94SvKcG72/G4RJ0w73XsHA27gg /HnBU284WE9Cy2FTn1qU+qPkNj/hrN2U6YIKyd00rXh7ogan3vSgq8KMELG84XgUiO6v cjTc+baWxtXUZH15kkfHY9VBtrRZm1DBeBgQI2Gvsd6GTa0SIUemz4Pp6PQztzkR42Da 1X2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=R2VgATjg; dkim=pass header.i=@codewreck.org header.s=2 header.b=PlvD8W9R; 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=NONE sp=NONE dis=NONE) header.from=codewreck.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t7-20020a056402524700b00463d1e263b1si1463208edd.364.2022.11.30.05.31.36; Wed, 30 Nov 2022 05:31:57 -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=@codewreck.org header.s=2 header.b=R2VgATjg; dkim=pass header.i=@codewreck.org header.s=2 header.b=PlvD8W9R; 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=NONE sp=NONE dis=NONE) header.from=codewreck.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234600AbiK3Mys (ORCPT + 84 others); Wed, 30 Nov 2022 07:54:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234005AbiK3Myr (ORCPT ); Wed, 30 Nov 2022 07:54:47 -0500 Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7957D2A73E; Wed, 30 Nov 2022 04:54:45 -0800 (PST) Received: by nautica.notk.org (Postfix, from userid 108) id 3CE7DC023; Wed, 30 Nov 2022 13:54:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1669812892; bh=sh34+7lh2fTDO49r8VZu83HKmBn9XRjerEgAkN6tIEM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R2VgATjg/c6jZM/DKWUgnTwqUhg4Iwzc++IgGL9WrmXAmwyGDAeVgwkxGu6ON/YzN TllaExd+gHQjTCxTazomBDH4yZhS7BBgRfn/VCyD6q+nedWv7jz2YYG0jjEEavVbtS Lw+LQwVuwOrsNKmr8eEu/rk8xN7DleACoabN+HVIwJOiEh2Ozt9THL81Fh0j8GJ/N8 b4QisLvJZhhAY6QpGAxNtCxZyY59MOce/5C8J/xr8MvCUoeDZODDfaZ1Fa7nbVj8WM lAOBTulcBk4X/mLWHXrrRKdz42ZqMqwTBAiZL9Z6IDaaeLhc6GXjFzP3eTEqPXcCu8 imVO41MpaZkwg== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: 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 Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 90068C009; Wed, 30 Nov 2022 13:54:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1669812891; bh=sh34+7lh2fTDO49r8VZu83HKmBn9XRjerEgAkN6tIEM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PlvD8W9RyN0fV4z/kaCPpO0kwyi1JN/osxPTTd1SqRNduaoGuq63sXCTO6nNppvqd LhGBm/Ka2zP085wZl1iIHCaS8YjYN1ZfqrJvm56AuFD/0e/GXh2Deu9IQ9f9V02bcB kT9aiL1C4cqGntPctSSyCju/Wlxv2zLyYHS8Y4pJymXtFBDTRNNTmhBdu5MKsdhv2Z /zCWQ31/sFTCx+FG8gwibjWwOXLR2C8Flu7I94Zix2Gh3z+HyI3TEq79gQxnqx1z6e 8DzVmocSBn4WM14GyUXBZjYdrvOVZETnAVpjD00FF5Ae68jOQSflMEUKwZzZQ6XAdN 4Pm9oIZvE+wDQ== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id 3fe9ae05; Wed, 30 Nov 2022 12:54:36 +0000 (UTC) Date: Wed, 30 Nov 2022 21:54:21 +0900 From: asmadeus@codewreck.org To: Christian Schoenebeck 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 Message-ID: References: <20221129162251.90790-1-schspa@gmail.com> <2356667.R3SNuAaExM@silver> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2356667.R3SNuAaExM@silver> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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... -- Dominique