Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp20102lqe; Tue, 26 Mar 2024 18:36:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVfwUHGGzwwT+IiHdbmigRm6uB1dTcmrQyslBojGDH/Xjw1kzimZqDwiAXUNY4n6ToZ3JOzL4oE6W07giZCHP2+yMM8BDBGRUEQMis1bA== X-Google-Smtp-Source: AGHT+IF15n5wXaUSRb0OkirmyzmWU9y2dTLFGQDzl2LHMC/Sbq8Q5zWnQIcn+vzZJ0GQlyQUPwWq X-Received: by 2002:a17:906:a250:b0:a46:708d:a9d3 with SMTP id bi16-20020a170906a25000b00a46708da9d3mr1874223ejb.71.1711503399899; Tue, 26 Mar 2024 18:36:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711503399; cv=pass; d=google.com; s=arc-20160816; b=H43T/MwPh4/tdU0dHOaQ+tSMvEO/HwAcK5/lREYOX9pZsad10lrjx4Emfko++rvzjo GtzWgjnW5GqeXB+u/DB4QutM1AtZ5v8KbjF3ZWIGN4UZpPUwUhI/ZPRJ6OSiJMOP5gs6 QmdaZrH828vC7rM4NdmYMffsYoEzQ+JGKjM0Rb8a+N7W82lezs+xJW096JDRpdeNx9W1 onDjTfUXWSPthx3mDSp5HTdxo6D2K2+Vm1F47PMysHvogpjTX/lWpIziJyMpl2maTFia QTYop9faFpRVOpDKMqSjFfHt2LIJmNrA0XskIQwkVSQpcrGYDYg/a13RyTSboal3ZOBf cHWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=/aGOYT7TFGrsKfi7KLTdNOkbOmV9AC/pwUSoheK+c+Q=; fh=0PA6iubKuw/xBLQ9zUwV44Mpo5DxXO9B+Kua/qvg+ko=; b=uHN/OnrCR2TnLMxaDQ3kO+fMgfflTPXf1ZLukwDfMFQvK8XrJtXUez8cxXLg+5uVB8 d9nyH4Je60dUDjbbnOSPYs5ukl414CO6i2w5bUu9Bbgcchr7Z7sPB6OCz0euSVCLTce2 ctobqpPc1ESSw3o812mjbVq+uYqgvgbOdRBq03aQ53SLmpCLt0V26LpgC+pbZ+UOYfIY YHmj+UtCW+Kdhuk2Ez7laGgRPrdipkPfAWj+Oap/LmmLNwYtxBu+wWqKlTG/NSOLI0rw Z1x/2dIR8VQDQ5mgkgCsr9mjKJgWAFyI6MoAbMYxq7Cw8+HnKJbw3osekW7gE43jxas7 hxpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PNzvh2g5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120179-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120179-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t6-20020a170906a10600b00a466b2951c7si3988993ejy.981.2024.03.26.18.36.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 18:36:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120179-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PNzvh2g5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-120179-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120179-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 am.mirrors.kernel.org (Postfix) with ESMTPS id A0B851F34B53 for ; Wed, 27 Mar 2024 01:36:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CA691CF9A; Wed, 27 Mar 2024 01:36:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PNzvh2g5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A43020323; Wed, 27 Mar 2024 01:36:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711503392; cv=none; b=C5cp8VO+fCLXMGqkheHTBDWX84BXjOhvdVQW8cTp1G0colh40QMKzxpiHczBf6TUIr+8l2rYYdlEaUMwKNbMMRCQW/7LaqG89jYha2zo470aAi39bdETAhuiRA3PTVV+lpnzAPHLK6LowmmK55rY2wHiXLusRevWZK2h5IhMzww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711503392; c=relaxed/simple; bh=G5CnkT5QVDuAxX6bjBrkXtiKlaXMp79BcaVPmAi2WQQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=n8lDb4FaxxX6AsL7dn89nKOJgWZM678nFfsL0aNdEC7gnvJISZadcVq4RQbyU9VPmlUOrCTYK0QR84p1oTAPEYKQ5sCy2gABEAUyh+wrwLZMf/pmPtNespn3e3y/Pm6kJ3EcctGq/x/HMR0S1vZXqxDxw3dacvB4qe6doRIdnnI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PNzvh2g5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 289CAC433C7; Wed, 27 Mar 2024 01:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711503391; bh=G5CnkT5QVDuAxX6bjBrkXtiKlaXMp79BcaVPmAi2WQQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PNzvh2g5NC3x8OmCPQmNFGAXaVUpQVkEa8BeyO11NScvIdjLTpTGry+Ww3O/SeT7/ 5Ym80jU058K3n7+BoSOm0FCC7j3dtwpF63ff0X4xsojFcVNPa82YpDLNFlXOvEAOTX zpSZLIIyFpGkLleRylvT1mc6AnXj/UmG1b6OiyT2Mz9ACnlAhSwCLUY1aVNuhfbUQp 3t4TgXcgTsdi8AuGf3p+mXGJ3ryHRd/qdIMUrCJDX7bqg40OsYLuQCADxmCVP/Qo3l Uqpc/E26crc48fh4sequ3zRbAZIqvVAcuG8zc9CWwN5kpAsQG3lkYniq9KHHsPTYEl b/1AUvahum7lg== Message-ID: Date: Wed, 27 Mar 2024 10:36:28 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 10/12] sata: sx4: fix pdc20621_get_from_dimm() on 64-bit To: Arnd Bergmann , linux-kbuild@vger.kernel.org, Masahiro Yamada , Niklas Cassel Cc: Nicolas Schier , Nathan Chancellor , Arnd Bergmann , John Garry , "Martin K. Petersen" , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240326144741.3094687-1-arnd@kernel.org> <20240326145348.3318887-1-arnd@kernel.org> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20240326145348.3318887-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/26/24 23:53, Arnd Bergmann wrote: > From: Arnd Bergmann > > gcc warns about a memcpy() with overlapping pointers because of an > incorrect size calculation: > > In file included from include/linux/string.h:369, > from drivers/ata/sata_sx4.c:66: > In function 'memcpy_fromio', > inlined from 'pdc20621_get_from_dimm.constprop' at drivers/ata/sata_sx4.c:962:2: > include/linux/fortify-string.h:97:33: error: '__builtin_memcpy' accessing 4294934464 bytes at offsets 0 and [16, 16400] overlaps 6442385281 bytes at offset -2147450817 [-Werror=restrict] > 97 | #define __underlying_memcpy __builtin_memcpy > | ^ > include/linux/fortify-string.h:620:9: note: in expansion of macro '__underlying_memcpy' > 620 | __underlying_##op(p, q, __fortify_size); \ > | ^~~~~~~~~~~~~ > include/linux/fortify-string.h:665:26: note: in expansion of macro '__fortify_memcpy_chk' > 665 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ > | ^~~~~~~~~~~~~~~~~~~~ > include/asm-generic/io.h:1184:9: note: in expansion of macro 'memcpy' > 1184 | memcpy(buffer, __io_virt(addr), size); > | ^~~~~~ > > The problem here is the overflow of an unsigned 32-bit number to a > negative that gets converted into a signed 'long', keeping a large > positive number. > > Replace the complex calculation with a more readable min() variant > that avoids the warning. > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") That is old :) > Signed-off-by: Arnd Bergmann Looks good to me. I can take the patch through libata tree, unless you prefer taking the whole series ? In case it is the latter: Acked-by: Damien Le Moal -- Damien Le Moal Western Digital Research