From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ED66CD37A9 for ; Fri, 15 Sep 2023 19:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237031AbjIOTnj (ORCPT ); Fri, 15 Sep 2023 15:43:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237050AbjIOTnL (ORCPT ); Fri, 15 Sep 2023 15:43:11 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2011FCC for ; Fri, 15 Sep 2023 12:43:06 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-577fb90bbebso1747336a12.1 for ; Fri, 15 Sep 2023 12:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1694806985; x=1695411785; 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=KYJud1t9lPyuPjtdwBUAsD3BvXWOOoP+siQ8uzoHdDU=; b=lv1AMfeEfiHIn4vWjkJMk6a+yMVmMhhtfeZJjM3put5fvaifKq7g2lhVGwER0Daw93 ynoj6O+ATUqllHBeZro2u7NTsIzpaJVLN41BpjOzxK86MFYu8nPdhlfnc4Wpprd8egsv I1F+LPgHMza92k1ilz+o8T0LlusPuOj0FSAFI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694806985; x=1695411785; 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=KYJud1t9lPyuPjtdwBUAsD3BvXWOOoP+siQ8uzoHdDU=; b=SgJzYm4YEOMIU8938ZDn3yMLB3W392Ctln1F9NW1SJSAmqdtPuGtDNfTeOtYWUCaj5 NdEXgM2AZ4THl4tnqObY2kq9k7sTmygumAfECsxs3dgBLsoZg034jhN8smtTfMyw1Ose be8oelQrKu1zAq9n+KcMeVdbemF908sSarGktbDV8JCodbDimwZUyP6avP3WlG4WXQsR L8jwSwiSfeeDwzThF/K5/nQPA+COfsNHM4xTa61Ws++SmbgNXJQCrAyDDIUIEOs1IfFZ 9ProvybyfEPzX3MhThaVDdDE5GVgGIGHezOqXqKAIYQyVmPsd6q/aDO2Xj43Dwuv7C2s lNMg== X-Gm-Message-State: AOJu0Ywu0Ay0Y0j8bTl4uuDilatM2Y3Y9hW+03NxEKaHHbedfvN/xlrq zXjqDcGvf2EGNTmpi8Kii59YbQ== X-Google-Smtp-Source: AGHT+IFeG9K8dCFdWE7JO8su8gomrvm80dps740wxaqk3Qc6GiQQ8BQQx0l1yX49avLzT86ttQjnhw== X-Received: by 2002:a17:90b:38ce:b0:274:96a:5007 with SMTP id nn14-20020a17090b38ce00b00274096a5007mr2503313pjb.1.1694806985660; Fri, 15 Sep 2023 12:43:05 -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 ft7-20020a17090b0f8700b0026309d57724sm5200947pjb.39.2023.09.15.12.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:43:05 -0700 (PDT) Date: Fri, 15 Sep 2023 12:43:04 -0700 From: Kees Cook To: "Gustavo A. R. Silva" Cc: Jon Maloy , Ying Xue , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] tipc: Use size_add() in calls to struct_size() Message-ID: <202309151243.647E424@keescook> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 15, 2023 at 01:16:26PM -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_add()`. > > Fixes: e034c6d23bc4 ("tipc: Use struct_size() helper") > Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook -- Kees Cook