Message ID | ZQSuboEIhvATAdxN@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1279111vqi; Fri, 15 Sep 2023 12:41:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFxZK9GoM8siavchSCq/aA+vqEQLE8z4rssEUnGOQFIAz0QaU8R77NBNDpAVuy65uxabyZ3 X-Received: by 2002:a05:6e02:1526:b0:34f:1fee:496d with SMTP id i6-20020a056e02152600b0034f1fee496dmr3786187ilu.19.1694806909871; Fri, 15 Sep 2023 12:41:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694806909; cv=none; d=google.com; s=arc-20160816; b=FkzH6XqxaiVBiZZqC5NQJj5XZUm0o6iwt9zqDZA3GrnzUwc9VH8vA1qJx4fAvXHr3d 6Ho/o3q4qR/k02VlCM9Xxc5MtDV+/xXEnSBz3LPW3SyFPCrAZXstywk1jI7R1Gi7fl4s Yl39487HS9NCvVQnoj0qBC+TXUWjzx5uML14cG6Ro2QgoPcbdb1gPAlWMzTAAhv0TMHj 44ghDJXsU4bowOPeNmOgh0PMd4S9V55XhJAw7B3NQEZ2VadJWeUCq9GfVPrw6sVSUfb9 uajx9nsPnx982aRzYKhgTWxzdwtwMWW6ZVudoMUwAbhW9SgyYdjdCda/9NU/db5xvbaL Blgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=VHMzGcMtBN0O3BtdhEi7kmyfSCn9phB8ftLQ55wHfj4=; fh=en6KpRlndxN300wWkDCZNXQ24Ylc2xRAG8i+OvaGMqY=; b=C6cW6b0irW0S0iuu+zjmkUVkS32CqNGDM32xsMfrJAVt9yYghzm+8dN8uatrChyzB5 Z62FRxABr/nD7raIsBDIbke0/ssVn5x4FzXMNOsIU5miheSdD5zOdpOnpO9MZw30mKAN /7gLIDtS5AapNbt1tkPGCpa5guwaFA9QOPOxeziOr5zMo6M2+vhvGxEy/cc2s4xwkB6O gusWsCZTM31UVvcVvj4f0XXQ/ofmcVBNCwDjv+mugQ4sdJ+tkOFjcHf5cCGOKPcH+Eky aq5H2MakkEufXCrBb+5lfv4GPpaGzW5XxZ8z7NE4z5/QhKpHO4+nsC0RxxsQqwLJsRna AMCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=udBm1XbC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id z2-20020a633302000000b00573fc107575si3555481pgz.699.2023.09.15.12.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=udBm1XbC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id CFD9782A54F4; Fri, 15 Sep 2023 12:20:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236870AbjIOTTc (ORCPT <rfc822;ruipengqi7@gmail.com> + 30 others); Fri, 15 Sep 2023 15:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236873AbjIOTTY (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 15:19:24 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B73EE98; Fri, 15 Sep 2023 12:19:19 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9ABCCC433C8; Fri, 15 Sep 2023 19:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1694805559; bh=O6zKBde/jQeUo4lppmCpOky1iZxcXTpe2NdXo5CtT+k=; h=Date:From:To:Cc:Subject:From; b=udBm1XbCL5/0ifCYnkf2qJ3cbdstwMq/rAxd67WQQcp3+EJWMFabpDIPT3InuAgxl dc4t+yxDE9wFhQVq2rU1ehkXtstoW65Udmk3iflTeYs+8ickHVOnVJNwXZAS6nmKh5 Gf4VvoP75j65FeMbiMji31mczSwpzVw+xUkiQdxs9gbfFj9Eqn5FOZ190lCOcwA7p5 1YoDh5XBc0tmkPPQ5t7GUgJVnkr/+x2lbXVtQJSrtQhZRB9Nos9HsIRtqRJSPRT8zk lkEduTNvCu53RsDrDUzghpv2wL0VrPPJ4k/XHROZuimlWqt9TJ5GWUKQlLDG03xFNX hzac0nz0k+iwg== Date: Fri, 15 Sep 2023 13:20:14 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Duncan Sands <duncan.sands@free.fr>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org> Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] usb: atm: Use size_add() in call to struct_size() Message-ID: <ZQSuboEIhvATAdxN@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 15 Sep 2023 12:20:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777133850011528174 X-GMAIL-MSGID: 1777133850011528174 |
Series |
[next] usb: atm: Use size_add() in call to struct_size()
|
|
Commit Message
Gustavo A. R. Silva
Sept. 15, 2023, 7:20 p.m. UTC
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: b626871a7cda ("usb: atm: Use struct_size() helper")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
drivers/usb/atm/usbatm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Fri, Sep 15, 2023 at 01:20:14PM -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: b626871a7cda ("usb: atm: Use struct_size() helper") > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org>
On Fri, 15 Sep 2023 13:20:14 -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()`. > > Applied to for-next/hardening, thanks! [1/1] usb: atm: Use size_add() in call to struct_size() https://git.kernel.org/kees/c/13f1a60fe04f Take care,
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c index 1cdb8758ae01..2da6615fbb6f 100644 --- a/drivers/usb/atm/usbatm.c +++ b/drivers/usb/atm/usbatm.c @@ -1018,7 +1018,8 @@ int usbatm_usb_probe(struct usb_interface *intf, const struct usb_device_id *id, size_t size; /* instance init */ - size = struct_size(instance, urbs, num_rcv_urbs + num_snd_urbs); + size = struct_size(instance, urbs, + size_add(num_rcv_urbs, num_snd_urbs)); instance = kzalloc(size, GFP_KERNEL); if (!instance) return -ENOMEM;