Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp300453rwl; Tue, 11 Apr 2023 18:54:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YQlUroGbdw18pwi8FLgaWtfhF6iaaFEL8OaydUrs2jblCiCH1um99FDaLfgyK+p7o5ILDk X-Received: by 2002:a17:907:76eb:b0:94d:56f7:4fc3 with SMTP id kg11-20020a17090776eb00b0094d56f74fc3mr4768703ejc.44.1681264498592; Tue, 11 Apr 2023 18:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681264498; cv=none; d=google.com; s=arc-20160816; b=PSe/7s7dm+kikdf2dH55O2Y7Ar/FsxoKYodaxvTJFTxGqYL99B/OL9kQmRCrojRxGO jqNsVOkLrzAtPzSFhE1fenI5tjbZBZGECij+ObHrwBS6qeGdn9sPwlJxyY+EadvT8xVo mtZXqt2BQwMAsMSvv+WS9Sy9mJ3wh1KT6YqrK3TUeFyRk12hlgqd9ZXw6JtTMA4emte/ 7ZfC06OjaCW3wzl1CXOGZ4dh2o48qJQU6fOrSIFXwwQos2rnRej36ibSP62ggEhma9pM KSPX5Nnb07TKH8rdIx2X9AU3TA4bmVqt7MdnLPBpOu//V38Wbf2omjreg+LOrnF22qGF W9sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=OF4pQW5w28pLJwUluofaHHw/O+1+PT+f4QxhyOtoeEo=; b=IL0b/B4h+Nlq7ywLNQ5dLI7CzOy09X12bXliD84aCE5RnOgHfC/iow0xlAhjFrAa+7 pWwAEfCn/4hjFM79JXZB+sHPflmNEw6KXEO7xdCu8qrNi+3PdrU78c2puiteE2gFWwBG m+IsIiAGyyXjKOculWk+f9FTrkI0+4p5HAgzZts6y5rX0yxNfCSBdysUi9ophVpnYDCa KNb/jNiLdlm6qNISm8pAWDNykdQDsj0O9gEp8Pe2OQEjbEqJQoLiin8BfR0MEDjgvPlp xBExpg+e9UF7FVDs2iXBdoDWT2eLCURQm42Juok9wX3VRTMmkeJTIA/VFrDPcDfD8TUI 5PpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=me1cRiJr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds4-20020a170907724400b00924daa6c305si894080ejc.625.2023.04.11.18.54.11; Tue, 11 Apr 2023 18:54:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=me1cRiJr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229521AbjDLBsU (ORCPT + 99 others); Tue, 11 Apr 2023 21:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbjDLBsT (ORCPT ); Tue, 11 Apr 2023 21:48:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECDA7469D; Tue, 11 Apr 2023 18:48:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6F07162AD9; Wed, 12 Apr 2023 01:48:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CAF3C433D2; Wed, 12 Apr 2023 01:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681264095; bh=Pwva1zUZZWgALz6s4BWXSDqH8zfMPLPj6NoNuxX43uI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=me1cRiJr+yQaMYoqgKw1IbJXbr5RMOAyK3OSd7EW2oBisPzeNiWdts/OChmpzcA48 WB+p5QPLDrhR0cx7vozobJYor//FJ+fIfiIe8NAdDdohyKBqejjijVr18Gzup15V/7 g8We3OmGOkZoD9H5nE5FOyyWLiHvDxbCq3T/rjS2MDcuaq0ArGEc4TSQYyjaXcgECF a/HHY8fTG1XXE4iz3ku4XjNuhkSa1j8r0oB/swE0FdI4WPZ4J1hLLwVGArr69rRBvw /ncE2iEzJANhUucXRyJCXET6P1VaPSL6KCJKO7D2SBvFVDp4nwJYuzIkitFUMevXfC 1+lwpPCozVR3w== Date: Tue, 11 Apr 2023 18:48:14 -0700 From: Jakub Kicinski To: Roman Gushchin Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Rafal Ozieblo , Lars-Peter Clausen Subject: Re: [PATCH net] net: macb: fix a memory corruption in extended buffer descriptor mode Message-ID: <20230411184814.5be340a8@kernel.org> In-Reply-To: <20230407172402.103168-1-roman.gushchin@linux.dev> References: <20230407172402.103168-1-roman.gushchin@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Fri, 7 Apr 2023 10:24:02 -0700 Roman Gushchin wrote: > The problem is resolved by extending the MACB_RX_WADDR_SIZE > in the extended mode. > > Fixes: 7b4296148066 ("net: macb: Add support for PTP timestamps in DMA descriptors") > Signed-off-by: Roman Gushchin > Co-developed-by: Lars-Peter Clausen > Signed-off-by: Lars-Peter Clausen > --- > drivers/net/ethernet/cadence/macb.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h > index c1fc91c97cee..1b330f7cfc09 100644 > --- a/drivers/net/ethernet/cadence/macb.h > +++ b/drivers/net/ethernet/cadence/macb.h > @@ -826,8 +826,13 @@ struct macb_dma_desc_ptp { > #define MACB_RX_USED_SIZE 1 > #define MACB_RX_WRAP_OFFSET 1 > #define MACB_RX_WRAP_SIZE 1 > +#ifdef MACB_EXT_DESC > +#define MACB_RX_WADDR_OFFSET 3 > +#define MACB_RX_WADDR_SIZE 29 > +#else > #define MACB_RX_WADDR_OFFSET 2 > #define MACB_RX_WADDR_SIZE 30 > +#endif Changing register definition based on Kconfig seems a bit old school. Where is the extended descriptor mode enabled? Is it always on if Kconfig is set or can it be off for some platforms based on other capabilities? Judging by macb_dma_desc_get_size() small descriptors can still be used even with EXT_DESC? If I'm grepping correctly thru the painful macro magic this register is only used in macb_get_addr(). It'd seem a bit more robust to me to open code the extraction of the address based on bp->hw_dma_cap in that one function. In addition to maintainers please also CC Harini Katakam on v2.