Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7353970rwb; Mon, 12 Dec 2022 13:34:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf6aPNk3eTirpoxURXD703sywBxuDEBfR5FfFr76LbEQEXrvDWyKSXw/YlpaHbuNB6LId70+ X-Received: by 2002:a05:6a00:e8c:b0:575:f349:5971 with SMTP id bo12-20020a056a000e8c00b00575f3495971mr15332436pfb.33.1670880867085; Mon, 12 Dec 2022 13:34:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670880867; cv=none; d=google.com; s=arc-20160816; b=C8Bj9fZmExOungELgVBrcxOZ7vZO0TR68r6b5I4o8EcJbfbiWz3sj4Q+aThjboekEt ESPk1yRvynAbGU55MpQgliWQxbrK8oHDUjy1v9FsA8rT486Huc1svKMDm7qS85AeWdOy uXIGghdClt5WeFk2m5ZvCfeiWjegJqppUSak+XCMX592pnI9KkNqztZ10iSOVX9PMytS jWx03vD8R7tcKN6JckhGNGse1LvCGg+aEXw3QIgr4cq/3j9LkB+GGY20ined/D2vYwit 1d0ddaXEh3ouS6lPcQgCjVgwimkE9MFqtrGiIhVgeHOAwSsiEPj0mslznrQIeKY8Pg52 npiQ== 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:subject:cc:to:from:date :dkim-signature; bh=vVOsXiYfhtldvFw/kjr+7Dzn2ergikrIQYb5aL5M7AA=; b=cCz1tpwgT7B3ibWQXjZebD/1i0C3vhfcvf0R2xORx2hmY5aFmgHAKnVIeQhXf+2HL4 57Yzc7fqmp+W5tmDJs+IW+liR1mOjKUced6Df2pyZcDeV5KDAE1XfYX+ndI/NaJ5aZ4+ bBt5gU2Yk3ByZ4vw3cftTGWo1hETNLp2dV4efXk/RVUHl94Ts2/2d/315ZsjVd/b5X+s nNpfeFL8vuRnM/AWoJhPWvPj7+nN0IQZHGhljkpX9x34DFSWrt8+HkrBLG0rtPIhu0bT hq8ykfh+MqIy8ps/uzAQOsstrmibq2Sq6dJSliO3IRn92m5AdgOf1mJNPnJ4o52MTRZC QKWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m8WZb8Yk; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 201-20020a6214d2000000b005721983ea38si9728052pfu.48.2022.12.12.13.34.17; Mon, 12 Dec 2022 13:34: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=@kernel.org header.s=k20201202 header.b=m8WZb8Yk; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233361AbiLLVKe (ORCPT + 74 others); Mon, 12 Dec 2022 16:10:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232643AbiLLVKb (ORCPT ); Mon, 12 Dec 2022 16:10:31 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 004A813D72; Mon, 12 Dec 2022 13:10:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9ECBAB80E61; Mon, 12 Dec 2022 21:10:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDE97C433D2; Mon, 12 Dec 2022 21:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1670879428; bh=CCrikyLYWYoT8cMMMxS7RNkwk9Q+H7h5XTWP1Z9Mkyo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=m8WZb8YkLlqs7i3dWKX4ecQAQo6QdPXDnE5uQUJI3Ddv26dcSTsPTSles/EhvNP4b JKkX/Qb9xgaFJFbMxSd2fXt0p97fYEbpL4VHNtIA+ZqFmxHWVASxzoB96SMlV8eASo hUg6M15HO7SghHNzrzZzo32Ge6R2zXZ7cvBOvIPumGhOb0SxNulbjhZ736VTVurIzx jc7AI3hXqzvMrbD4TINJnSIRVbn/ssfM3EGoxZ7QIL+4aKY/oHQd9CXQwuG9L/z8k5 OK9DoEaOqK/PaIyrrIbipDEI1E7BJ6ehzAXK0rZWDT9hLDhuW+UuX9dPK+jE4lwPRs B+32g1/eqCegg== Date: Mon, 12 Dec 2022 13:10:26 -0800 From: Jakub Kicinski To: Christophe JAILLET Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Jacob Keller , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH net] genetlink: Fix an error handling path in ctrl_dumppolicy_start() Message-ID: <20221212131026.120bdd71@kernel.org> In-Reply-To: <7186dae6d951495f6918c45f8250e6407d71e88f.1670878949.git.christophe.jaillet@wanadoo.fr> References: <7186dae6d951495f6918c45f8250e6407d71e88f.1670878949.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Mon, 12 Dec 2022 22:03:06 +0100 Christophe JAILLET wrote: > If this memory allocation fails, some resources need to be freed. > Add the missing goto to the error handling path. > > Fixes: b502b3185cd6 ("genetlink: use iterator in the op to policy map dumping") > Signed-off-by: Christophe JAILLET > --- > This patch is speculative. > > This function is a callback and I don't know how the core works and handles > such situation, so review with care! It's fine, the function has pretty much two completely separate paths. Dump all ops and dump a single op. Anything that allocs state before this point is on the single op path, while the iterator is only allocated for dump all. This should be evident from the return 0; at the end of the if (tb[CTRL_ATTR_OP]) > More-over, should this kmalloc() be a kzalloc()? > genl_op_iter_init() below does not initialize all fields, be they are maybe > set correctly before uses. It's fine, op_iters are put on the stack without initializing, iter init must (and currently does) work without depending on zeroed memory.