Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp151896rdb; Tue, 5 Dec 2023 01:08:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLQFYKO+pTXFBp0FJfsSVv60se9Ib8FVzC7io8mXROk1deA2uOY6dOq0kTWiiD/Imy2AM8 X-Received: by 2002:a05:6870:2b0e:b0:1fa:1c89:c656 with SMTP id ld14-20020a0568702b0e00b001fa1c89c656mr6551334oab.56.1701767285405; Tue, 05 Dec 2023 01:08:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701767285; cv=none; d=google.com; s=arc-20160816; b=rc+97kvfRYuaoW/AmzJIfltkB9gyNJi6j3s1pUHUbJaH1L5LV/xqHeBVI8uYJ7xpXE DQl6Jqz87l7pFNIOt+BjQEhlfgf8pPY53Z+7pxPe8e6jb83LdO9NIrFEZBAfYjKlZ0BC 1du1UoVsfTjOIfVKy1qNsm3evEhBX63HKuvdqSu3tD6yOapUDOb1+HtbTD+9wlw5xtsG F4laqF8kc7x04CPgHWs/yDjl+5EeO2d3QiOUqpB+k2smZybNOiPCVBLaNYFZ5qmaaZY+ vItOLhzT2CFHyMbcEyW2O4xly+grSVXcF8YhgAtIdDYW5Pgrfj5LK2liLATEeZMREpgF s4Zw== 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=Zcza2koUNlQSollLV/Bg+N9kW0zXA9vz++qJ4d4v5fY=; fh=ST9c7d1NNFMAllCneQjILSwqdlzEyBWsh6yDqF0l1e8=; b=KBfWI1YkfbFUAs6Dj4kQtFFyypppOLmrv0hyJ3HBwW+l2iZ6HSSq6HVnwhW7fDwMco 8JmaN13z/W6+ZG3Yrpu5g5ZwZYdGGtKbMQSYPnfqwCazLBNbb8uJfTCco/aLv9IAIZRj CmZF1st8XAjuwfS4YIt84/Lf4QHZBoaiW4eLQ/szIEWjndbAjKrBQtC5+5DIoupJgRqs Inyeu0ufzJF+6P6Cx+bO7hjE/UNMINvn74BuJS8QYXowo4qnEZ/Ufi7UpJqFdH/s+qJQ ofRCA/UswkRPWv25skd4NSQ/24OCWLdRI8ApjtstoAy3coNFLNMjCbWEVt1pPpeD8G9Z iyew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=PuHhqmIq; dkim=pass header.i=@codewreck.org header.s=2 header.b=PLtCjPBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bx25-20020a056a02051900b005c693ea6618si2834308pgb.523.2023.12.05.01.08.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 01:08:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=PuHhqmIq; dkim=pass header.i=@codewreck.org header.s=2 header.b=PLtCjPBo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id A7381801B4B1; Tue, 5 Dec 2023 01:08:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231750AbjLEJHq (ORCPT + 99 others); Tue, 5 Dec 2023 04:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbjLEJHp (ORCPT ); Tue, 5 Dec 2023 04:07:45 -0500 Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0A5B10F for ; Tue, 5 Dec 2023 01:07:49 -0800 (PST) Received: by nautica.notk.org (Postfix, from userid 108) id 32467C01C; Tue, 5 Dec 2023 10:07:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1701767268; bh=Zcza2koUNlQSollLV/Bg+N9kW0zXA9vz++qJ4d4v5fY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PuHhqmIq4di8uyLbStLheCAmnT2OqjGGfT0vH774lVgOF817jT/ttbkkT0GQP+szo 4BVrLZyHEK0f2hlA3tKEzdGUhMO9bt01HFIJ2qHcjcAJf03hkZNwdA2ZgWYHojOhBU DIwlIpxw/tyTXbNZ2DpRdgY52brbwMOiv8emPejdXzVayHrhglZq9xa/cY52mMLzCK jHFk65ERMrDG7wGCYdEALG5fDdB1dkeb7SWfwIoYtot2JsApyejh937yVUDS6oE+xX zGObTQweyErTA4hiXfiqxTJZHAN2yQr6b0oE0tqPzE4IEm+5L5lY8Be4gzujA34c1Z tNhZuAWWHN+TA== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from gaia (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 586B3C009; Tue, 5 Dec 2023 10:07:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1701767258; bh=Zcza2koUNlQSollLV/Bg+N9kW0zXA9vz++qJ4d4v5fY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PLtCjPBoN6k82Qh/P8T2TOhDgZvxpkF4U4kHR6pFz9b9ScBcRsgHpeLIzbA4YrCrS ihetjFpGVvB0wwUEnrkRTotWZu8oWwiYfSGl1AtcsBOC+07aYbbaAsUyIEvfTVAUhQ NQzWpdnEYr/f0V2iOmmagyCddECvEK7zofcknbkjksaBc/YwcVbZ5goUZCH4b7joia hue6N17SNSCzzxEGyGEm58HBOXVoLYmp4eJVrOEjC4yt0vtQElwjV0Z2nJ6uBU+Uj+ AvJHZAyjctSbABrVdFp0KDUhFOeUlqs0GZbC3QQOaAmZqNIZUjPF2eUSaxibK0pWN8 hbv5Hp2nRmncQ== Received: from localhost (gaia [local]) by gaia (OpenSMTPD) with ESMTPA id 0564bc80; Tue, 5 Dec 2023 09:07:30 +0000 (UTC) Date: Tue, 5 Dec 2023 18:07:15 +0900 From: Dominique Martinet To: Fedor Pchelkin Cc: Eric Van Hensbergen , Latchesar Ionkov , Christian Schoenebeck , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , v9fs@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: Re: [PATCH] net: 9p: avoid freeing uninit memory in p9pdu_vreadf Message-ID: References: <20231205080524.6635-1-pchelkin@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231205080524.6635-1-pchelkin@ispras.ru> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 05 Dec 2023 01:08:02 -0800 (PST) Fedor Pchelkin wrote on Tue, Dec 05, 2023 at 11:05:22AM +0300: > If an error occurs while processing an array of strings in p9pdu_vreadf > then uninitialized members of *wnames array are freed. > > Fix this by iterating over only lower indices of the array. > > Found by Linux Verification Center (linuxtesting.org). You might want to mark that as Reported-by: somehow instead of a free form comment > > Fixes: ace51c4dd2f9 ("9p: add new protocol support code") > Signed-off-by: Fedor Pchelkin That aside, it looks good to me -- good find! I'll push this to Linus with the other pending fix we have next week > --- > net/9p/protocol.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/net/9p/protocol.c b/net/9p/protocol.c > index 4e3a2a1ffcb3..d33387e74a66 100644 > --- a/net/9p/protocol.c > +++ b/net/9p/protocol.c > @@ -393,6 +393,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, > case 'T':{ > uint16_t *nwname = va_arg(ap, uint16_t *); > char ***wnames = va_arg(ap, char ***); > + int i; > > errcode = p9pdu_readf(pdu, proto_version, > "w", nwname); > @@ -406,8 +407,6 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, > } > > if (!errcode) { > - int i; > - > for (i = 0; i < *nwname; i++) { > errcode = > p9pdu_readf(pdu, > @@ -421,9 +420,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, > > if (errcode) { > if (*wnames) { > - int i; > - > - for (i = 0; i < *nwname; i++) > + while (--i >= 0) > kfree((*wnames)[i]); > } > kfree(*wnames); -- Dominique Martinet | Asmadeus