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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 174AFEE14D9 for ; Thu, 7 Sep 2023 09:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:Cc:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p7YKEOmOG1+MZ2Mawl0q5LqCvfFF3wsDn3Q5rlMa8j0=; b=He9rZv6XQJPgDe QEj9ujrB3uXEF/3pi5o5FRBhIhF3q5DIjSdF4Z5FouYpuDVDoE5tJQKXqq3AOibyiKuI/Q5B1Xu7h L5M5qjUSCPoqxC7icPU4q/QGBNCOb+J5hFzCYG6lOXYrhfThJnSn7qfKPeaVT7SzOnm/zQDtyIDcM gqDTEANU+lJj+irDZlfXA2S3EaKw51WnC+8WIkRsW1DALq/9Z4HAgztmIyMeA6bdKa8Jd2JJLhr9j Bvlk5S5r7knZYwDVGZQ0OSOg0GhgPcIZGtBV5uYbBHsT+odk+806SZHzstpaxqhXC+chel09XQS8r ZwuwKS3yA2GXsD/0qYfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qeBZG-00Bhvh-2o; Thu, 07 Sep 2023 09:44:54 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qeBZE-00Bhun-2b for linux-arm-kernel@lists.infradead.org; Thu, 07 Sep 2023 09:44:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694079891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SDnMgm2pO9DiKf5tQ2V3g1yxw6hd2QGFbQ7HyFd9eI8=; b=THiZJ6i9vvJWWaRfM3MzD+J0PbuczwvVonIivXg2Vl/ijSqiETWLotsPUHxrjUlTD9mSWK AcoQ4dFUCI6slkmnjXKwxNqcG7/VS1YPj//xTSVbhvaljSWzR2KMWmmGLhabSh1nFgiYNF XVxeVOopnK0skCp0byZjeqjsPdHdPVE= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-319---bp8cZwN_mFG1pzvth5uA-1; Thu, 07 Sep 2023 05:44:50 -0400 X-MC-Unique: --bp8cZwN_mFG1pzvth5uA-1 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9a5c5f0364dso16945766b.0 for ; Thu, 07 Sep 2023 02:44:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694079889; x=1694684689; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=7iV8N0Zs9ekoCmuMeKBQuzMuRWS57eO3gP7qT4sD/5o=; b=MvYG5ABhPxqoL00KCw2scek9wFQUo/8tUDfmGEXqG7jqlIyETmpo4sB5/qefxCbfEu dTSmLd62NCN8zZgXfZYVfAfH+BLCA1GlJhOafJaNqfZyVhvqFa2vhPDfT+0vm6S0IIdu tFpzMx7zqZE8MlRnwl0GZCGh2ktzQB7HiQe08PwZvPFdwMFIxXUapX7OjEeGsVwZM/Og Z6HrFdVcNfI38KeJapHO+0GcLeoPLyxdgaupGzzjRuuKMplMiTkt9asrYi2PLJd/AMmJ 3QBTSft38hM+5puFdpFfq8I+4nPINXrvD02yVcAziwbQTnZbUu1m38reIh3npMQ3kvJo 3Fww== X-Gm-Message-State: AOJu0YwA3oFlXhd007yYGMMUDuH5P1+lFcKWJAeJ5dADLgUwuuW/ZUg8 OlOYE7RxqOE12l4XvlkAsPOwqETq1eGlYd9hI5lMvbGvWvtu13tByTk2tA+5aE8IiJt8FK3s2rF C255rr662mx5YxX25WZ3vFJxsv7Dxc0JKFTQ= X-Received: by 2002:a17:907:cca1:b0:9a6:ae76:d6ae with SMTP id up33-20020a170907cca100b009a6ae76d6aemr3715619ejc.3.1694079889073; Thu, 07 Sep 2023 02:44:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFnPN4syHJKZykCDJc7KbCt9GyZHbum1qYTeTY8d2HUtrQ1128rOz00zDgwcLVUTwKZzjDO1g== X-Received: by 2002:a17:907:cca1:b0:9a6:ae76:d6ae with SMTP id up33-20020a170907cca100b009a6ae76d6aemr3715589ejc.3.1694079888723; Thu, 07 Sep 2023 02:44:48 -0700 (PDT) Received: from gerbillo.redhat.com (146-241-251-112.dyn.eolo.it. [146.241.251.112]) by smtp.gmail.com with ESMTPSA id ja8-20020a170907988800b0099290e2c163sm10063541ejc.204.2023.09.07.02.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 02:44:48 -0700 (PDT) Message-ID: <7b42e1ca549f8d7d18a4df9d74a93cf527071a4d.camel@redhat.com> Subject: Re: [PATCH 1/3] net: ethernet: bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active() From: Paolo Abeni To: Hangyu Hua , justin.chen@broadcom.com, florian.fainelli@broadcom.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, mw@semihalf.com, linux@armlinux.org.uk, nbd@nbd.name, john@phrozen.org, sean.wang@mediatek.com, Mark-MC.Lee@mediatek.com, lorenzo@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, maxime.chevallier@bootlin.com, nelson.chang@mediatek.com Cc: bcm-kernel-feedback-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Date: Thu, 07 Sep 2023 11:44:46 +0200 In-Reply-To: <20230906092107.19063-2-hbh25y@gmail.com> References: <20230906092107.19063-1-hbh25y@gmail.com> <20230906092107.19063-2-hbh25y@gmail.com> User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230907_024452_932166_B26E73B7 X-CRM114-Status: GOOD ( 17.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 2023-09-06 at 17:21 +0800, Hangyu Hua wrote: > rule_locs is allocated in ethtool_get_rxnfc and the size is determined by > rule_cnt from user space. So rule_cnt needs to be check before using > rule_locs to avoid OOB writing or NULL pointer dereference. > > Fixes: c5d511c49587 ("net: bcmasp: Add support for wake on net filters") > Signed-off-by: Hangyu Hua > --- > drivers/net/ethernet/broadcom/asp2/bcmasp.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c > index d63d321f3e7b..4df2ca871af8 100644 > --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c > +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c > @@ -535,6 +535,9 @@ void bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, > int j = 0, i; > > for (i = 0; i < NUM_NET_FILTERS; i++) { > + if (j == *rule_cnt) > + break; Side note: it's a bit unfortunate/confusing that the drivers can arbitrary return -EMSGSIZE or silently truncate the list. I think it would be clearer if we could stick to single behavior - and I'll vote for -EMSGSIZE. Cheers, Paolo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel