Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp476545rdb; Tue, 19 Sep 2023 00:39:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7eG6ee+cCflCy8xwUXsajcQ+l8wlLzoql1/CFIvQS+WBB6F/UTWjdQvgmLzNnt4g1SDlr X-Received: by 2002:a05:6e02:1a8e:b0:34f:f4cd:1cde with SMTP id k14-20020a056e021a8e00b0034ff4cd1cdemr4297247ilv.32.1695109158215; Tue, 19 Sep 2023 00:39:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695109158; cv=none; d=google.com; s=arc-20160816; b=kpIJh5LkVQzhnDZVzH+WI1lYP9DmUaWNdYPOJ4XJqNmy6SIsDyEITB3zVC3md2t98q mDomJl+gRy1qLGxkjHmx4YbTiNhBkK1kUPZc7H/1maMhQJuWD6JsLtvwN4a2CwOA0UBM jU5jyYldGLbNg4QmuMLkyZBmg2q9FYwulYZkUQvvne8uSoYQey06e5Y5VrLycBtxwHzG G0po+EMLJVof5WaRivTzDTfk5sy7b9HVLoYPTqzM61UnoQzelwJcB2tB2TBILEGEMZkM 09d2xJQ8B1rpKFL+Lq193DKZb8z1PPwAj2ALtGUI1F1lB3WZ93+mHiFTx5y3cy7lb4cL vn5w== 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; bh=eAPBoi7QzOhbkK9EIUIjxUb6CFS7hCTDO/hzd5l5KBk=; fh=F6SmQdn6UWiXIqdpY4vwM0grytymbfTOvZP49qVV1r4=; b=N0UZEXqVpETMMWIwI8o1oRqR4hBNSJIO19LdZOgLxAQLo3NrM+JIfRo6tsVl2vwuUi ntXoXZbmItVV9SN7SAX6tu0aimLL/fBo6vx5ApC4JmmXJJhpXtnIVTFuNbHehgKF9LQJ kWZb6e2PhHiOXcHbUBhW5M24a4AH0PO37tRVyWgl1RIR/7dpo9jKZeIxdtILJj7y73ZF /nahXC+FZqiBICrqKU2YCnHVng9GqqQBIvn18DGz3wKyjyRaB9yMb9CcddkjCBdtzZbk osoB+BIHv8UePiXfvMdbmOwNdfhtFLOBX54NjpyJ4OrU7eGNLMY3dZYaFmTZHXFf1j4K RN7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k5fvtEl9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id 81-20020a630254000000b00565bcc15ee2si1251811pgc.815.2023.09.19.00.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 00:39:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k5fvtEl9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7DC18825A0CA; Tue, 19 Sep 2023 00:37:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231779AbjISHh2 (ORCPT + 99 others); Tue, 19 Sep 2023 03:37:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231678AbjISHh0 (ORCPT ); Tue, 19 Sep 2023 03:37:26 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3A0EFC; Tue, 19 Sep 2023 00:37:20 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 38D3BC433C8; Tue, 19 Sep 2023 07:37:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695109039; bh=hw/PLJo9AvSjPNxvgMGEVejD6C36fUyBhR/MMoCVeHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k5fvtEl9ChBlrZltiFvYSvVqhoV5N98VV0GUTqYhl+AvKTkhh9KoDS08YDijtbFRo R7klitQxOPsdjFS3p7TDe+AuRrQDBYCb2bjnGzqQcRqtnZVF1JorofaSBXPGXW0/Fx wG7+KT858xTqrOWxUTPJxozZRehPW+XZHoLC10WY+nGVrMePO6gMWSjK33UuuXFOdy 7DsVD2ijZqFZcUztIvCkUM/a71HrKdTUjqKv7TBpJoho6Usgx2kUh9KlN76/Nbsz1S vB40mIhP75HgoRahA4G++ii8Bg5XgRRvln6WOUfn6nU4XmjSviq+yqIuYOJ+/ACTBP CJhv9SdytzvyA== Date: Tue, 19 Sep 2023 10:37:15 +0300 From: Leon Romanovsky To: "Gustavo A. R. Silva" Cc: Jason Gunthorpe , Parav Pandit , Jack Morgenstein , "Gustavo A. R. Silva" , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v3][next] RDMA/core: Use size_{add,sub,mul}() in calls to struct_size() Message-ID: <20230919073715.GC4494@unreal> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Tue, 19 Sep 2023 00:37:30 -0700 (PDT) On Sun, Sep 17, 2023 at 03:21:36PM -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, The thing is that it doesn't. > the protection that `struct_size()` provides against potential integer > overflows is defeated. Fix this by hardening calls to `struct_size()` > with `size_add()`, `size_sub()` and `size_mul()`. > > Fixes: 467f432a521a ("RDMA/core: Split port and device counter sysfs attributes") > Fixes: a4676388e2e2 ("RDMA/core: Simplify how the gid_attrs sysfs is created") > Fixes: e9dd5daf884c ("IB/umad: Refactor code to use cdev_device_add()") > Fixes: 324e227ea7c9 ("RDMA/device: Add ib_device_get_by_netdev()") > Fixes: 5aad26a7eac5 ("IB/core: Use struct_size() in kzalloc()") > Signed-off-by: Gustavo A. R. Silva > --- > Changes in v3: > - Include changes to other files in drivers/infiniband/core/ > - Update changelog text with a more descriptive argument for the > changes. > - Add more `Fixes:` tags. I don't think that any of these Fixes are necessary, as nothing wrong in the code you changed. Thanks