Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5058058rdb; Sat, 16 Sep 2023 00:45:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE476TWng8Agh91FOcn9KDDcHygSeVRmmHq1HaxeyUz/BXiImODoUJFECjvv/O+LLpm82K+ X-Received: by 2002:a05:6a00:24ca:b0:686:6e90:a99b with SMTP id d10-20020a056a0024ca00b006866e90a99bmr4208045pfv.25.1694850352032; Sat, 16 Sep 2023 00:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694850352; cv=none; d=google.com; s=arc-20160816; b=mPzRWL8uEsVgIk2vN/Q8mZiqECMti4wwuJIEyIC9hPtgUqi4aJEXJLnx20SasdCFId avj1Tp4qtK4Xza3FjdJmabicfz2mvYX+4rQctivMSHIbBDevMJGdHqZT9bCozcUDOWbR dhhtamctIzdPmpWzP8fWKw6KW2lvAQxmYE+3LisFdkrFfSyS2QvTOKVnhXGjBzFw//uP DqNXfrF5rCz7AuJKj7oR+16haZ1anpqKgT1I2TZI5g7o+9DQUaAczLITNk7DfUzOCeKl g5ClmLmbEuk2BmmLaSxpJp6TDGV2AqFb+eBphvTCwvoOUY4W7R5Lu+xkKrFZYJswXYK0 TZgg== 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=gFE1F3+kydQTQojTUb7prmfEOCJq3WLONO+sPWEJMCo=; fh=PMR0vsAlPQdsLsVjXGSFXNv96tA5ClycP7tD9AZpk0I=; b=bilwcQN/t5pd+eW0ZRhPn7GSK94ODHSAonXEDd34NabIY+5NApmCHEG51OS25Edxla H51cuF3mxOl7/WJHiLUixT2cSF1XfwvvOLCbY5cGMQblr6rvorcvyprbKTLn6qmz5oyd 4bHYfTmWYifnzjejPBKL9sAoGJDJ/rNa90ShB1ty80wWeUJzRT2XEiV7czD5dttmTYvM 2i9DbbcNcH0fhDcLvVPX47ahR9QUuuGlCbIB96WhciIhg8/kGfX31gi6TSY4pXyqK3F3 P7T+94uYhy3qQ3IQ3nwqj9N569JzTl8EcYaQJvotK9y/asZdJGA6RuAD/eH+ezVoonEd V/cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=h38ZcxOq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id j70-20020a638b49000000b00563da455862si4368668pge.311.2023.09.16.00.45.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 00:45:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=h38ZcxOq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B132281DC792; Fri, 15 Sep 2023 12:43:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236643AbjIOTm3 (ORCPT + 99 others); Fri, 15 Sep 2023 15:42:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236638AbjIOTmU (ORCPT ); Fri, 15 Sep 2023 15:42:20 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ABD119BC for ; Fri, 15 Sep 2023 12:42:15 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68fbb10dec7so2328099b3a.3 for ; Fri, 15 Sep 2023 12:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694806935; x=1695411735; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gFE1F3+kydQTQojTUb7prmfEOCJq3WLONO+sPWEJMCo=; b=h38ZcxOqWwCMHk2cL65uE60F0C0YUQdFXGSjn5YM4z/sbkkqRAKpN7N8C0XpegO6cw c2UagfzmMXtWz3MuMZ9O3TEYaEWJfvjaI6qniL9tuqrfhXZampXd7WTX72bjb4h1LLPI 1u4LWhkpW4LmoBf7pprnlw6+1Zq1wWhGXTfeo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694806935; x=1695411735; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gFE1F3+kydQTQojTUb7prmfEOCJq3WLONO+sPWEJMCo=; b=iEYNATv5dgUdIZBaS1qxeTawrcHANKpqA171s67vsCqp75CVJkN9Yj/fAcpwtyfk6M HFxe71DkfhiHc81TKYc1eRNL4uJX6+y/0iGPMD2Ot+TKg/dXDq87tYZbKNBxry0LoekT /ShJIDLBHmFG/rJPW+kzSui53MqSgTVW73FvhyHf0PRHT/+GFBb4AhIEgJy7KR7qsuSU Q2eKwFHE2IUbaebuifpNs2kDwsQ9ZnOq+nmjpBVSwCpRQsu0NbYIUV3Pbop4+8dgj8No 38+Iwq1tqtbz2SJ4FUHkAjdEKvaAskxMyg18NZ/S/xbN5lgd1saBtVcPK0+MdwGApd8/ zK4Q== X-Gm-Message-State: AOJu0Yxs8AmmusuY3borLg8TShbcvEvk/4FXPpHOlKEhou/4NZXEuyDr zUqwVbyTKERCVubdtCtZj0x6Qg== X-Received: by 2002:a05:6a21:7189:b0:153:39d9:56fe with SMTP id wq9-20020a056a21718900b0015339d956femr2593392pzb.47.1694806934963; Fri, 15 Sep 2023 12:42:14 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id m22-20020aa78a16000000b0068fba0f5f32sm3417615pfa.90.2023.09.15.12.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:42:14 -0700 (PDT) Date: Fri, 15 Sep 2023 12:42:13 -0700 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Ido Schimmel , Petr Machata , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] mlxsw: Use size_mul() in call to struct_size() Message-ID: <202309151242.E732735FA@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 15 Sep 2023 12:43:00 -0700 (PDT) On Fri, Sep 15, 2023 at 01:01:23PM -0600, Gustavo A. R. Silva wrote: > If, for any reason, the open-coded arithmetic causes a wraparound, the > protection that `struct_size()` adds against potential integer overflows > is defeated. Fix this by hardening call to `struct_size()` with `size_mul()`. > > Fixes: 2285ec872d9d ("mlxsw: spectrum_acl_bloom_filter: use struct_size() in kzalloc()") > Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook -- Kees Cook