Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1828316lqo; Sun, 12 May 2024 22:07:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV7EujMHfD2T1XknKsu4z6fvPmiLRSKtfXCzY5wVs29vex0RMHN/tAHLqpdPgDjj6aYb50fN3SDhdIHacZABs2G2c31vxJxT3K60hHMNQ== X-Google-Smtp-Source: AGHT+IE3VTI3dSuLBIaT0OmFEVqyRu9buDpth8YyztYCsSotUmJl0NuPIM1qjEEiulS7r+M6TtZj X-Received: by 2002:a05:6a21:983:b0:1a7:a6f3:1827 with SMTP id adf61e73a8af0-1afde1b719fmr9575017637.46.1715576872429; Sun, 12 May 2024 22:07:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715576872; cv=pass; d=google.com; s=arc-20160816; b=pWOBEWlTK+3RmWqXSGf6IgToki9aqA4fcpXI5UhxFtheFfSwJLQShqXjde0/rnTB4B /tN0uUhXM/AYtke9zSQYQThBzzDkiuB/VWCqSqdUtK/2+2b3tnWhi0pMpBehsq1d4uqI m2lJiRPtMz+zB2Aisfms2WXA1KWLnOUJeh4FnNz+9R9YzFLlLPn2e/QJKo8pxxyWfEOd 4f7PyUBlHZjUNJ5FQIWpKxSRcvzjAjmoUy65SeiWcI3OT0t8kAHaVZl0LOb5Aqj5wmbD BzkWHSGSfGqmHtzOI7nZ9yEQKst8CLF9nyDp4xV8WNyef9+WHqW6X/K7q7xy/oP9+2IO jW7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id; bh=Uw/16UOIp0Zk76kJXiDb5d3RcEbZkRCtaVDI7Jh3cdw=; fh=NLq3jn22deQ2m2vNHKbaKecuBN/uZyjYxllHbDU0f5Y=; b=h1a/vdDWLQnyUToC+p6y7YT9ix9vNYFXvDnDSdYF7wq4DLwinlNWzJrkia+rT/vr9v HOJ11ZG8GG+lvGdsmFWb+L+gzzmZf93a8PKNzV+uMJJapgPkjxeh2XrbiCBz4qByweTV y1JZwBdivoPUlhbqIbL/vzWm6l116M7K0dtZ3mSSOTDWuU56ql441aZDmC4FrHrDQIXy pFmicR0mJ5e/tn0klYhzonMEmMwKKL8g5cV/XcRdYhFYg+O6z8ly/lu4EGTo7LrcYnte ZCRfCF26JW9evXlp/AasnZO+MrfkphfRdo8BkytttMSRc4jD6QR6g5n04DJi9NHA38Fx zD5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4550-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c269dcdsi87995835ad.592.2024.05.12.22.07.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 May 2024 22:07:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4550-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4550-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4550-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 550D3B20C36 for ; Mon, 13 May 2024 05:07:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BCC8146016; Mon, 13 May 2024 05:07:37 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 654D51E493; Mon, 13 May 2024 05:07:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715576857; cv=none; b=cr1Uyq0dDVEhcXcGmVQa66Dv1WJZmxClMfk/LK27xusW4diV6o9+lLp70qe0pSBoDAHwquzK7l+X1dF24fdyMV0burBT7V6QnlqAPOhydnsF7wgApAUEinZOX/eNxf/JjT0kNOvysQM1QTf92+yw/tIjy4clFARg7Ci9JoOBhow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715576857; c=relaxed/simple; bh=6r5mD4vVz5Goxgvkp3evVY3tElzQ0VE3+3nkBb71T3A=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EtnnwBH5A22mvWggCuozT5R4MfAnghq0zUWVh2s8w9IBP4CvD84ZFhNSZJ/1bua48rOq073fL87YU/gHxO/GfvAt1UvPqYcQCIEWHDSFfKYVDM5SjetzzOWhKY/CSt04VMRGClUQ1y29jrNiiazgOixIktrj1pg0NkR3mLb2wMM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a5a157a1cd1so955212866b.0; Sun, 12 May 2024 22:07:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715576854; x=1716181654; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Uw/16UOIp0Zk76kJXiDb5d3RcEbZkRCtaVDI7Jh3cdw=; b=h1lbHWXP/9OQVqHzDTOHJI6uSmQQHW+Id6CoLv5zqWqB14PYRLHzeC7wFaTNqYDEtU uMd3Ms+iyEUDjL2Q7E4eI3cod9TU4ipBGWJOlfWOyKo/2uUe8eoTnu6m1bi4BT38LZmQ 0YjjvN4I0HdbPPm5x2pR8JxnVnXma5A9w+7nhcPomRmU74B9LFketDerbV42reLsiyeV 0T1EdKkzVEKMP2as7bss+Tz24VlKDciv5MUZvpA7nYkbDMh1trOqumHXd5VAcyhGx3Vv 1WZUpULqIIZ2p4BPdt3A0Fk0lQ8lKQbGFB72EyevDPtLqXAT3JzEFQWokfKkOl/skfH3 J58A== X-Forwarded-Encrypted: i=1; AJvYcCVdWTSH9XMw31ba2r2RA05ji1V17XqsQ9bW9jjjDEeC56TAqD+Cy7AXMqaOfZd2ibjm7Nl2eIkkzyUJ/JhcI5A93IISGS2lJM4k+fYjMQGoAvkIGa4BLUoXOaGN6Kj4ZE6FqFRZ7uqEhvEmM2tnGyjJI8iARFjaikXAUvTjAKG+wFuwuqQu X-Gm-Message-State: AOJu0Yy23I7eMdCZjPraT02DGhfeJf9rlJ1KZW1/vD28z7lhnb/hV3/4 J1l6sVxRkRHltoGC5XqtAa/n6SDbgc1mZFnI53UiGeROevR7Mu6R X-Received: by 2002:a17:906:7f8a:b0:a59:b6a8:4d7a with SMTP id a640c23a62f3a-a5a2d5d3d22mr566370166b.43.1715576853469; Sun, 12 May 2024 22:07:33 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:69? ([2a0b:e7c0:0:107::aaaa:69]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d787sm550149966b.11.2024.05.12.22.07.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 May 2024 22:07:32 -0700 (PDT) Message-ID: Date: Mon, 13 May 2024 07:07:31 +0200 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] tty: rfcomm: prefer struct_size over open coded arithmetic To: Erick Archer , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kees Cook , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Greg Kroah-Hartman , Geert Uytterhoeven Cc: linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev References: Content-Language: en-US From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qI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VneqM2TUQQbK+Kh7JwmGVrRGNqQrDk+gRNvKnGwFNeTkTKtJ0P8jYd7P1gZb9Fwj9YLx jhn/sVIhNmEBLBoI7PL+9fbILqJPHgAwW35rpnq4f/EYTykbk1sa13Tav6btJ+4QOgbcezWI wZ5w/JVfEJW9JXp3BFAVzRQ5nVrrLDAJZ8Y5ioWcm99JtSIIxXxt9FJaGc1Bgsi5K/+dyTKL wLMJgiBzbVx8G+fCJJ9YtlNOPWhbKPlrQ8+AY52Aagi9WNhe6XfJdh5g6ptiOILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12. 05. 24, 13:17, Erick Archer wrote: > This is an effort to get rid of all multiplications from allocation > functions in order to prevent integer overflows [1][2]. > > As the "dl" variable is a pointer to "struct rfcomm_dev_list_req" and > this structure ends in a flexible array: ... > --- a/include/net/bluetooth/rfcomm.h > +++ b/include/net/bluetooth/rfcomm.h ... > @@ -528,12 +527,12 @@ static int rfcomm_get_dev_list(void __user *arg) > list_for_each_entry(dev, &rfcomm_dev_list, list) { > if (!tty_port_get(&dev->port)) > continue; > - (di + n)->id = dev->id; > - (di + n)->flags = dev->flags; > - (di + n)->state = dev->dlc->state; > - (di + n)->channel = dev->channel; > - bacpy(&(di + n)->src, &dev->src); > - bacpy(&(di + n)->dst, &dev->dst); > + di[n].id = dev->id; > + di[n].flags = dev->flags; > + di[n].state = dev->dlc->state; > + di[n].channel = dev->channel; > + bacpy(&di[n].src, &dev->src); > + bacpy(&di[n].dst, &dev->dst); This does not relate much to "prefer struct_size over open coded arithmetic". It should have been in a separate patch. Other than that, LGTM. thanks, -- js suse labs