From patchwork Mon Mar 22 16:02:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406157 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1346637ejm; Mon, 22 Mar 2021 09:03:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUvqA4IO9kxgOnFGm3MPfk0CtPk/QOdgaz7tWYiWg0YG+cxwgZdTYY2gmq0T8sv4FPWKv5 X-Received: by 2002:a62:4e57:0:b029:203:93bc:3cb with SMTP id c84-20020a624e570000b029020393bc03cbmr525693pfb.56.1616429003867; Mon, 22 Mar 2021 09:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429003; cv=none; d=google.com; s=arc-20160816; b=BckKY9dTY1r0kOeley6ujc2X8Km7KjScIJN/nh7DhfcBzW7E0ejDT9O+2BSEkf9qZV r3wqIYmtbmAeFD/fVM0zE1J6I4t/T9Lh/vijy0ezPX1d3DPxA7WShVZzANvPHNUS9iGL mWOTLvj3aHWIYyVOBrkpgq8HvgxZ3oqj2MAI7oAtK2GUemCCfxBi9fG6bwNjcx2Tez4T Ba01WX4r1mGxj8s+kaCMZXkCAJ6vq7wwCmEEcNkecLqigM4LNCQxhmuWLOiBw0VELPs9 O8grenXq405OuvpuXCwYeYYcsNc4DgBW1XtiOuZCnQaDhEvK8VIfG54jEHveu2e0000r iIfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=SdH9lcvW+ZlIYhYJciSzUA7rE2XrQdMmVS4dx57vfYg=; b=PojsbW46b33/e0LlTppminz25LR1kA1kv+h01D+9n0Buh+02T+Y/CbqIC7kjHX2Kri 1lpLnwFGUZJ7JnkXiGlAtH8x6BUEea3XOYhc8nNxvIN3Ra5rU0k8mdCZTsVKjw0eRb1X rIAD1TokzAKek3u+AH3T3GGT9YQ9vHhD1CX+GH4s/jadC4i0NN+orxt2yuSlR0/Fnqsk 4nggrXVtyqkGitHrybO5WgxrdRCvFdCJEfw0Xden6APqEedZKRa7aps04hLW6X+xEmlh 6g0V7zRCzIViQHKPOecpnD9EuaesDxOxhutGHXhexj1AdnPbPWpFvnvicvtls5EX2C8A Fzyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=VRbsfgY+; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id w8si15192149pgs.103.2021.03.22.09.03.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:03:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=VRbsfgY+; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1584289EBB; Mon, 22 Mar 2021 16:03:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB2476E500; Mon, 22 Mar 2021 16:03:20 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id C5EBC61992; Mon, 22 Mar 2021 16:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429000; bh=3vH1tW/3dz/29rKeu66QIybhctPu7u2aaTt+yHw+ixQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRbsfgY+z8kWvWs+txugnu/XzSTF1os4UBObTbMaVvuShG2tPdw5ChRNTsdoitI1c Os5gXEmTV19Hh0dH4sglqm/fSEpSE1o+cdD5mtmVZ292EJ017mpHo8q2zl1C63RDvy 9IP52tHZwWSskub+gnvqqJxnuA90avLg12n2yst/hTpywQNyH7pGS5SlpLOCg1l1zv SC2S1tGwIlfSqI7YXPTsk7il0mAFtLumFo7AO2H+payHYwT3xe1jEFpNJbjQ5KEMrV fL6MEJv6J7008Lwon/8167XZUtB/IGdDaiFW7a3KldjWew3Xisi5j0MtsrpiR6liOq jy3MXhpKCZK+w== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Subject: [PATCH 01/11] x86: compressed: avoid gcc-11 -Wstringop-overread warning Date: Mon, 22 Mar 2021 17:02:39 +0100 Message-Id: <20210322160253.4032422-2-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, "H. Peter Anvin" , linux-scsi@vger.kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Kalle Valo , ath11k@lists.infradead.org, Serge Hallyn , Kees Cook , Arnd Bergmann , "James E.J. Bottomley" , Ning Sun , Anders Larsen , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc gets confused by the comparison of a pointer to an integer listeral, with the assumption that this is an offset from a NULL pointer and that dereferencing it is invalid: In file included from arch/x86/boot/compressed/misc.c:18: In function ‘parse_elf’, inlined from ‘extract_kernel’ at arch/x86/boot/compressed/misc.c:442:2: arch/x86/boot/compressed/../string.h:15:23: error: ‘__builtin_memcpy’ reading 64 bytes from a region of size 0 [-Werror=stringop-overread] 15 | #define memcpy(d,s,l) __builtin_memcpy(d,s,l) | ^~~~~~~~~~~~~~~~~~~~~~~ arch/x86/boot/compressed/misc.c:283:9: note: in expansion of macro ‘memcpy’ 283 | memcpy(&ehdr, output, sizeof(ehdr)); | ^~~~~~ I could not find any good workaround for this, but as this is only a warning for a failure during early boot, removing the line entirely works around the warning. This should probably get addressed in gcc instead, before 11.1 gets released. Signed-off-by: Arnd Bergmann --- arch/x86/boot/compressed/misc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 3a214cc3239f..9ada64e66cb7 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -430,8 +430,6 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, error("Destination address too large"); #endif #ifndef CONFIG_RELOCATABLE - if ((unsigned long)output != LOAD_PHYSICAL_ADDR) - error("Destination address does not match LOAD_PHYSICAL_ADDR"); if (virt_addr != LOAD_PHYSICAL_ADDR) error("Destination virtual address changed when not relocatable"); #endif From patchwork Mon Mar 22 16:02:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406158 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1346869ejm; Mon, 22 Mar 2021 09:03:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnWwPqkNXZ0QHmo9q9ngTRaZ3ecxju4SMYEP82cZjdqQf50/ujE45tqwnGaODZakxyMm4T X-Received: by 2002:a17:902:c94f:b029:e4:59a3:2915 with SMTP id i15-20020a170902c94fb02900e459a32915mr469248pla.9.1616429021412; Mon, 22 Mar 2021 09:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429021; cv=none; d=google.com; s=arc-20160816; b=q3FO89Yjud9C8R3C/H57HqbpQgiIYlASwaL7Qh5p0DPG3uuKUGoxqZyNCD825wit63 dqZ4nsNZlk/eXald/ZYD9/93tk/XNQkfDaDdtlgyGpw+lxSc4nSoyupsxFiw3qdIofWJ MY5Z+o34u4qoBOmfOKao8Ox8UoOoOezyXAUDJ+7BKxjeJIj2SVMv2CUISgYwr10gJ9zV B1pKc7K1RtuOli5WEREMxl5DhICUEh1t0PIKP/cREhIqMq9vyxJC4M6NfdR6HLC8vvGD 6q4Cl+GWm0xUOlfNX8wF6YvsIo0HoHCoJ10AfybY0RalMW8bnbiwgZoaSn15sta7vtL6 DK5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=ELTwI7rSUTycaGp+nHaBcuPL9D9EKyste3PNzBBRJHE=; b=VZ84SvxXVN9iF6/ejBHKukY/KnjXhwqv86gB9vnpVskGbmZMD2VxaV70iuSKbjKLUj afBSr8M434DB8PqyZqdmlPzZUTc2iNb5c1p7uWzpgQGW4aKF9EtoIKHSw0JMhZyh0P4u E8aEA8o/B2vVR+qJ5Z/KOLE0UlbP0p9r2VJ7o0EM9QWWn211V7mqxaDBZcRooz6Ujv9I V7txCiIKr6ykvALVCJx8lxTP+5U4aZMnaz2oGEMSCEMjWNpnOTSDtgcHs/rjItGyW6bl ID1OrdkylS1aJ3S6NobXL3eUSpk9zTvqG6LOOcMQung7VHUKIiG9EqRw/8uW3fqxiI+1 uVbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=O6Jy+HmU; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id w13si14810572pgi.548.2021.03.22.09.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:03:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=O6Jy+HmU; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 548DC89D3E; Mon, 22 Mar 2021 16:03:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2A43A89D3E; Mon, 22 Mar 2021 16:03:39 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id BA0F66199E; Mon, 22 Mar 2021 16:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429019; bh=by6x6Rsrr+/5kT7BQ0fn/CIy488q3HO6uAtxXzMMlIk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6Jy+HmUTikJ1x1bJ304Vrp1sBfWbLm1PtId9ZJsKafzCLMEYQU//L/uQ5NyHGzrh RhBcv0KcZohevaQjWtq/m2PyDxHXZ6oO/xPHdEAeZN27qebnzt5Wg4fhtjqGJK48VY UL94XPmfJWp5a2JWF1yBFnnQqkdteTxWc08FTIpJX/wa6/CiiShyqAZe7XpjIeOmzt cO/lp91PJ7K5iDRKpXJ1LzXMgwxLeTNc1hWrW+Oj2cHQ8M1FuYfEUnJHvIMPGvZ3nY pOppyp2fEDOWTHfMFCcVXI+sMo5gidr9nyHaAyqJ/Nlnh1nTbp/etdZKIJcUsxQAJ9 FpT/4xvv9xvFg== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Ning Sun , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org Subject: [PATCH 02/11] x86: tboot: avoid Wstringop-overread-warning Date: Mon, 22 Mar 2021 17:02:40 +0100 Message-Id: <20210322160253.4032422-3-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, "H. Peter Anvin" , Will Deacon , linux-scsi@vger.kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Kalle Valo , ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , "James E.J. Bottomley" , Anders Larsen , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley , Andrew Morton , intel-gfx@lists.freedesktop.org, Lu Baolu Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 warns about using string operations on pointers that are defined at compile time as offsets from a NULL pointer. Unfortunately that also happens on the result of fix_to_virt(), which is a compile-time constant for a constantn input: arch/x86/kernel/tboot.c: In function 'tboot_probe': arch/x86/kernel/tboot.c:70:13: error: '__builtin_memcmp_eq' specified bound 16 exceeds source size 0 [-Werror=stringop-overread] 70 | if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I hope this can get addressed in gcc-11 before the release. As a workaround, split up the tboot_probe() function in two halves to separate the pointer generation from the usage. This is a bit ugly, and hopefully gcc understands that the code is actually correct before it learns to peek into the noinline function. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 Signed-off-by: Arnd Bergmann --- arch/x86/kernel/tboot.c | 44 ++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 18 deletions(-) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c index 4c09ba110204..f9af561c3cd4 100644 --- a/arch/x86/kernel/tboot.c +++ b/arch/x86/kernel/tboot.c @@ -49,6 +49,30 @@ bool tboot_enabled(void) return tboot != NULL; } +/* noinline to prevent gcc from warning about dereferencing constant fixaddr */ +static noinline __init bool check_tboot_version(void) +{ + if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) { + pr_warn("tboot at 0x%llx is invalid\n", boot_params.tboot_addr); + return false; + } + + if (tboot->version < 5) { + pr_warn("tboot version is invalid: %u\n", tboot->version); + return false; + } + + pr_info("found shared page at phys addr 0x%llx:\n", + boot_params.tboot_addr); + pr_debug("version: %d\n", tboot->version); + pr_debug("log_addr: 0x%08x\n", tboot->log_addr); + pr_debug("shutdown_entry: 0x%x\n", tboot->shutdown_entry); + pr_debug("tboot_base: 0x%08x\n", tboot->tboot_base); + pr_debug("tboot_size: 0x%x\n", tboot->tboot_size); + + return true; +} + void __init tboot_probe(void) { /* Look for valid page-aligned address for shared page. */ @@ -66,25 +90,9 @@ void __init tboot_probe(void) /* Map and check for tboot UUID. */ set_fixmap(FIX_TBOOT_BASE, boot_params.tboot_addr); - tboot = (struct tboot *)fix_to_virt(FIX_TBOOT_BASE); - if (memcmp(&tboot_uuid, &tboot->uuid, sizeof(tboot->uuid))) { - pr_warn("tboot at 0x%llx is invalid\n", boot_params.tboot_addr); + tboot = (void *)fix_to_virt(FIX_TBOOT_BASE); + if (!check_tboot_version()) tboot = NULL; - return; - } - if (tboot->version < 5) { - pr_warn("tboot version is invalid: %u\n", tboot->version); - tboot = NULL; - return; - } - - pr_info("found shared page at phys addr 0x%llx:\n", - boot_params.tboot_addr); - pr_debug("version: %d\n", tboot->version); - pr_debug("log_addr: 0x%08x\n", tboot->log_addr); - pr_debug("shutdown_entry: 0x%x\n", tboot->shutdown_entry); - pr_debug("tboot_base: 0x%08x\n", tboot->tboot_base); - pr_debug("tboot_size: 0x%x\n", tboot->tboot_size); } static pgd_t *tboot_pg_dir; From patchwork Mon Mar 22 16:02:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406159 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1347084ejm; Mon, 22 Mar 2021 09:03:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHZis5RH06GCYolF8Lf5oB8mfRVCSwXczXlERxnSuoJK4GUNFYeSJDMJ58EqWNFuLDlBnV X-Received: by 2002:a17:902:b781:b029:e4:545d:77 with SMTP id e1-20020a170902b781b02900e4545d0077mr443164pls.59.1616429039698; Mon, 22 Mar 2021 09:03:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429039; cv=none; d=google.com; s=arc-20160816; b=RZkuR4QDbwRtFjqnxHtWdCtTWoDKZCPGnhYXI9WjweIi6q4q3USdwt7QJm+SPkh3sx 02fHo27O9P8fUIfO4SgvTPLoMW4J+1DWQNoUZHRVlMbBBpFZTKMKIQRVANHYKqO9gguS tJ1tgrst0a3PPrWmOQyQ7Xe2c0O2WGSjLR1WqxGvhyAfl5L2yKQx/OEwLeOVDx5Jxuak Y7pql1CZCm7ds2PEF+KRjRYMQ8Hfria4ANF/uVkQRg8sMeMwlAt31EYk6knKtdfInspJ jHhkaR1e7AIxuKAJvsDe2XfBxCWEbhA4YPt7SOLcWZMi9CIY8DOmCe3zDh3xLj+uLGUQ Jz0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=E73QMOZ8viGNiDYJyLFjn6iMy3804zOGrz/MDNrrLkU=; b=HSXvZdxIk2SoUK7vs9H+wv2XiJEx7qVr4OVjcO2qVrw7Doah9q9SQ5W3Pf5hG7mAiX SYgQ8qRBqtQ2BCvB+m6maBEpAFkkJ5a4KT/WgQmVbc+VwLXY6Wkqum7DFBpvlQrsD8I1 krOCU+cRIqkcsOIktGOlQK68QJ5P/W/goOU2RJjHlXHc9w4/YEuK9ckF9shGE7ZED+u5 pcyDdfVfq/Isl8EV6KGY8AUsTJQmOu47DpZs9noI52cGfbeHwCdUOGfZ6n/CLrqMNXFy 8AKNyUkZdqvJ+uNv9A5HQITfa0qIcBzLwAhNBXDglQlkDgdy4olW/lbl4yRRFk+092bn HuYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=DnY2VvcI; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id a15si17372559pgw.241.2021.03.22.09.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:03:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=DnY2VvcI; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7808189CA2; Mon, 22 Mar 2021 16:03:58 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8861789CA2; Mon, 22 Mar 2021 16:03:56 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 4428761998; Mon, 22 Mar 2021 16:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429036; bh=yFqEt0Vza9xx1ZEH6vpmadF/s9WD+9cr+PvfYFx1jTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DnY2VvcIHWNR00CmYsS8o9sdpXW8IfqlUTn3pfDogyHxX/SIITlr8SG6GxkT3eSRZ a7K8jLXsPna4Mm190+MpWcuBICb/n+i193Sgx5UJVnr/NQaks4zNGBOOkdJN7kk+Zx IrtL2gHR1/fBjD9NvgLiYwkQqQ/EKWhfodExGrNMHcxDZouSH1dybJZC/EbBnOcXm9 XQLG8dt1bjMaDOofLpAx013Fhy9k111G7DuVnc/32l3avRksgUDzsBf0x12znYeUYk RAdBhG+/y/EhxEsBwjpyhm77vbHfFV6Wbj7ETM5qbIRB/4/X2e34tKnfe8hgDnqlGY gToo1OwJ8lpqg== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Serge Hallyn , James Morris Subject: [PATCH 03/11] security: commoncap: fix -Wstringop-overread warning Date: Mon, 22 Mar 2021 17:02:41 +0100 Message-Id: <20210322160253.4032422-4-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Christian Brauner , linux-scsi@vger.kernel.org, x86@kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Kalle Valo , ath11k@lists.infradead.org, Miklos Szeredi , Kees Cook , Arnd Bergmann , "James E.J. Bottomley" , Ning Sun , Anders Larsen , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, "Eric W. Biederman" , Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org, Tycho Andersen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 introdces a harmless warning for cap_inode_getsecurity: security/commoncap.c: In function ‘cap_inode_getsecurity’: security/commoncap.c:440:33: error: ‘memcpy’ reading 16 bytes from a region of size 0 [-Werror=stringop-overread] 440 | memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The problem here is that tmpbuf is initialized to NULL, so gcc assumes it is not accessible unless it gets set by vfs_getxattr_alloc(). This is a legitimate warning as far as I can tell, but the code is correct since it correctly handles the error when that function fails. Add a separate NULL check to tell gcc about it as well. Signed-off-by: Arnd Bergmann --- security/commoncap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/commoncap.c b/security/commoncap.c index 28f4d25480df..9a36ed6dd737 100644 --- a/security/commoncap.c +++ b/security/commoncap.c @@ -400,7 +400,7 @@ int cap_inode_getsecurity(struct user_namespace *mnt_userns, &tmpbuf, size, GFP_NOFS); dput(dentry); - if (ret < 0) + if (ret < 0 || !tmpbuf) return ret; fs_ns = inode->i_sb->s_user_ns; From patchwork Mon Mar 22 16:02:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406160 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1347366ejm; Mon, 22 Mar 2021 09:04:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA+rRoxBWVpdiSW6lfTauOWoM8+42x7wJ8RrRJgL+pZNIgVs93OyLeIkJD9co73qsnzXRU X-Received: by 2002:a63:ee4e:: with SMTP id n14mr269137pgk.422.1616429059584; Mon, 22 Mar 2021 09:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429059; cv=none; d=google.com; s=arc-20160816; b=WGx4eTYajH6GMnvHYFLP31JzJ5QuDp8KiZTVtobXNDoNN20PS7xK3/UKC0Gc0FWdDY aT5mz54XPJK67SSZgytr6TWhXYpIyiAFjSHN6J0RSQmkBjs69+IozLFoY80YvWxtSOVF RhFRqFvSU7hRAEWHRBpXnQ/+OBI5/kZcIXKYOXy4OX+iEAZ9FdulmqFpqdCwtuC9I9V7 oOPJ7NOmK0HZB5OMB0nxYM/FgwRe5EdzNviL3r8XdAzKGJzZJDxB2CxvE5cGPfFfmUZ0 7Gn4ZuBbdbLSnC57x/IVBeP/800voHA6ydQSv+qRJCsXgPtj443knQviF2HOMt+LHQqw eYpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=cxWtR5wxbjLsGywuj2lEC2+Dqh4ifYoIbnnuy1o4YPU=; b=bYI6TecxgNutkibuLNBDOHgTKRc1GFC8iy1A134GNz5fGU2fFRvD9V3T15al3IsgUv o9wa0EgFlTjhLAMBaEmXK+MyqZDpkyUBDlK91W8GBWPfBY2pJWLGDLjTxWZFUYf3IqMx oD3agExIbCKvITmhafB01TL3UTuMZiLcCF8tE3HGMlvEtTExndU/ajSNJBT4rZEgWJGk umbTnWh0VsyQtB7XVLBjJsVnXSPA8nt9R7LX+yZJBlzqs/8/bsipd/QRNI51m+bJvq/9 GXfZGaXW5TPXc0EgHp4V5WomEpGjUst7rndXavhJuYIhLckeuVAYYSsDapo5jgmOaLt9 wmPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=PJL0qpPD; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id y6si5573943pgl.402.2021.03.22.09.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:04:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=PJL0qpPD; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 683876E4AA; Mon, 22 Mar 2021 16:04:18 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 10B686E4AA; Mon, 22 Mar 2021 16:04:17 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 60C55619A7; Mon, 22 Mar 2021 16:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429056; bh=n4YjjyF/BQX1oLI53brWrn/ZFErJefAlbdz/B6a/LhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PJL0qpPDqSs2z7UPLYK5QVJo9sc76O7NWlWo5JPHSsPqGyDVDF4pF7hWXIkB1JA75 QpQt35+7BgO8L8Mn3URqgy3oEgZ8mXFVdUTizaV6t4aX9h9ExQGoEX/rwcyz2jamB2 scTuPUkDJISJZufdWGtFTIeZztxCxD3lXQOLujQyrS4sySOSS+Y/vZY+qg8LWnqJQL I/Aimz84KOYue+E+Dz/GzEJ2kjYrLgh/PeozYrKn1GELVG7ePD4iEbNB0WU3el9Rvz crDXO284w80Ehtcr/BjQheDrwVIVIOc3LE73CNZdbBcsVLFqijc8sIiXIjFKbmSQwm LtmW3NkvnLTfA== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Kalle Valo , "David S. Miller" , Jakub Kicinski Subject: [PATCH 04/11] ath11: Wstringop-overread warning Date: Mon, 22 Mar 2021 17:02:42 +0100 Message-Id: <20210322160253.4032422-5-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maharaja Kennadyrajan , Carl Huang , dri-devel@lists.freedesktop.org, Johannes Berg , linux-scsi@vger.kernel.org, x86@kernel.org, Aloka Dixit , James Smart , tboot-devel@lists.sourceforge.net, ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , Ritesh Singh , "James E.J. Bottomley" , Ning Sun , Anders Larsen , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Rajkumar Manoharan , Pradeep Kumar Chitrapu , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org, Felix Fietkau Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 with the kernel address sanitizer prints a warning for this driver: In function 'ath11k_peer_assoc_h_vht', inlined from 'ath11k_peer_assoc_prepare' at drivers/net/wireless/ath/ath11k/mac.c:1632:2: drivers/net/wireless/ath/ath11k/mac.c:1164:13: error: 'ath11k_peer_assoc_h_vht_masked' reading 16 bytes from a region of size 4 [-Werror=stringop-overread] 1164 | if (ath11k_peer_assoc_h_vht_masked(vht_mcs_mask)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/net/wireless/ath/ath11k/mac.c: In function 'ath11k_peer_assoc_prepare': drivers/net/wireless/ath/ath11k/mac.c:1164:13: note: referencing argument 1 of type 'const u16 *' {aka 'const short unsigned int *'} drivers/net/wireless/ath/ath11k/mac.c:969:1: note: in a call to function 'ath11k_peer_assoc_h_vht_masked' 969 | ath11k_peer_assoc_h_vht_masked(const u16 vht_mcs_mask[NL80211_VHT_NSS_MAX]) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ According to analysis from gcc developers, this is a glitch in the way gcc tracks the size of struct members. This should really get fixed in gcc, but it's also easy to work around this instance by changing the function prototype to no include the length of the array. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99673 Signed-off-by: Arnd Bergmann --- drivers/net/wireless/ath/ath11k/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index b391169576e2..5cb7ed53f3c4 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -966,7 +966,7 @@ ath11k_peer_assoc_h_ht_masked(const u8 ht_mcs_mask[IEEE80211_HT_MCS_MASK_LEN]) } static bool -ath11k_peer_assoc_h_vht_masked(const u16 vht_mcs_mask[NL80211_VHT_NSS_MAX]) +ath11k_peer_assoc_h_vht_masked(const u16 vht_mcs_mask[]) { int nss; From patchwork Mon Mar 22 16:02:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406161 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1347516ejm; Mon, 22 Mar 2021 09:04:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2qLO+0fqABYy6u1yqRtBh2mcJbOoQpNENlLWcoDTA4P5o/z8KP1YycJaIdfJAQkKrdvi3 X-Received: by 2002:a62:800c:0:b029:203:6990:78e2 with SMTP id j12-20020a62800c0000b0290203699078e2mr528438pfd.3.1616429068106; Mon, 22 Mar 2021 09:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429068; cv=none; d=google.com; s=arc-20160816; b=C8vzvtGPMum7D7EW0wf4QeEq2P1R15ThsKggQ8h/tFicqY+UA4rAg33aGgZrXLIAzU HOViKPY/5Um418Vbl1uFRnauoQUOfn5MkOG/FR7s9zWl3NvzKVrsB8GLORKhUrSfbFVu sDIVFOCapnv5X5x+tdWH5BkEcwI/fQN6id29wyg+HMRAKlJFF1fZ2NeozUHeKwyKqNth Kt8SYD/QqJ9621D7nONTUBVSmG7L8gbDjatgTzNtG5hamzxaw/s9qiCByDariBgCFof8 jmsJ6Zo5lTJu4SaKTz3yP4W5rqyCgoaXxnM7DgCL4PM0xYzFE6BLBY7uY12PGsyxXo9X sQpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=xKsCPQYCwaCSczjEvOM5OqW9KxGmGPabdyMU3aSnopE=; b=ZUfrIn2Hl4CAfrrhGB7+RChEwMRmxcGp5bPDXkjaPhlXhe/m5VMhXojfPLceixpbvW Ht+Z4bdXD8eYw/byiHd/dRGDDBp0LGdmIRYlzQFx1cGKReEUpyFttZvx4uE525zHgZeF fhYvYVwLF29ygAy2UaX5UySQoFBjOXPbelzDo79nHEJS/wnsoBaCDqnPMwXu+DdHbIIR Zmt/0sbqkNMoTiTj+u72oJnzsrV+OXU6wDihyP8NrEI1mw7v21EotV0yQXFiWVKVsW5I NRU1O3a9TI3NM3G3ZKmZkmb9NFBJu/bvmoKiHZ9EEgWxVaElxsmHTXotJx1XTLlJLTtL mZkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=MU4IL9JN; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id y21si13924111pgj.546.2021.03.22.09.04.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:04:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=MU4IL9JN; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1BC336E4FE; Mon, 22 Mar 2021 16:04:27 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 201256E4FE; Mon, 22 Mar 2021 16:04:26 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id D63E5619A4; Mon, 22 Mar 2021 16:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429066; bh=nkpO3F9iV2LP9C5b1X1yN1ZVysmYmotRTLuBUWIaptM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MU4IL9JNNK+J8U+vvpLpwovR+/suU+W9R4RhhhMaub4p/qt1HSm7/5H/LxJjfRA1v f+dccndcC0t+6DndIOBCJbVJvgtAFbUO/Xj+Ad4PAK3HRVGVN0VmdJVzwNG2nWP60W yoMi7GzhcMMul2Me0RQEOrAkh9+ikItIp0T7LrmMn4UxhxHfYhCqAAaad++VD478Ly WRurbxWp7EoqaQbB5aDSFB4iZyCpOkFivtOdus8BKdINgwMELaIsTcoM1dTXGsBCvO NUlZI47cRIaTlBnQpp36y5LIoHJRasVTH3KqfKgtuhF/A3Vph299qnut15q3EDnfE2 ATElHLu2Uchbw== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Anders Larsen Subject: [PATCH 05/11] qnx: avoid -Wstringop-overread warning Date: Mon, 22 Mar 2021 17:02:43 +0100 Message-Id: <20210322160253.4032422-6-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-security-module@vger.kernel.org, dri-devel@lists.freedesktop.org, Arnd Bergmann , netdev@vger.kernel.org, "James E.J. Bottomley" , x86@kernel.org, linux-wireless@vger.kernel.org, James Smart , ath11k@lists.infradead.org, Ning Sun , tboot-devel@lists.sourceforge.net, linux-arm-kernel@lists.infradead.org, cgroups@vger.kernel.org, linux-scsi@vger.kernel.org, Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org, Kalle Valo , Serge Hallyn Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 warns that the size of the link name is longer than the di_fname field: fs/qnx4/dir.c: In function ‘qnx4_readdir’: fs/qnx4/dir.c:51:32: error: ‘strnlen’ specified bound 48 exceeds source size 16 [-Werror=stringop-overread] 51 | size = strnlen(de->di_fname, size); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from fs/qnx4/qnx4.h:3, from fs/qnx4/dir.c:16: include/uapi/linux/qnx4_fs.h:45:25: note: source object declared here 45 | char di_fname[QNX4_SHORT_NAME_MAX]; The problem here is that we access the same pointer using two different structure layouts, but gcc determines the object size based on whatever it encounters first. Change the strnlen to use the correct field size in each case, and change the first access to be on the longer field. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 Signed-off-by: Arnd Bergmann --- fs/qnx4/dir.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c index a6ee23aadd28..68046450e543 100644 --- a/fs/qnx4/dir.c +++ b/fs/qnx4/dir.c @@ -39,21 +39,20 @@ static int qnx4_readdir(struct file *file, struct dir_context *ctx) ix = (ctx->pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK; for (; ix < QNX4_INODES_PER_BLOCK; ix++, ctx->pos += QNX4_DIR_ENTRY_SIZE) { offset = ix * QNX4_DIR_ENTRY_SIZE; - de = (struct qnx4_inode_entry *) (bh->b_data + offset); - if (!de->di_fname[0]) + le = (struct qnx4_link_info *)(bh->b_data + offset); + de = (struct qnx4_inode_entry *)(bh->b_data + offset); + if (!le->dl_fname[0]) continue; if (!(de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK))) continue; if (!(de->di_status & QNX4_FILE_LINK)) - size = QNX4_SHORT_NAME_MAX; + size = strnlen(de->di_fname, sizeof(de->di_fname)); else - size = QNX4_NAME_MAX; - size = strnlen(de->di_fname, size); + size = strnlen(le->dl_fname, sizeof(le->dl_fname)); QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, de->di_fname)); if (!(de->di_status & QNX4_FILE_LINK)) ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1; else { - le = (struct qnx4_link_info*)de; ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) * QNX4_INODES_PER_BLOCK + le->dl_inode_ndx; From patchwork Mon Mar 22 16:02:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406162 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1347723ejm; Mon, 22 Mar 2021 09:04:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxomW27j00I84Dm4y7Ig6Oph85WmXUhkgCOxLlL1nvJqQH7O+25UAk9ya/iGsaOhbXdbyar X-Received: by 2002:a17:902:59c9:b029:e6:5cdd:f709 with SMTP id d9-20020a17090259c9b02900e65cddf709mr360358plj.20.1616429079984; Mon, 22 Mar 2021 09:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429079; cv=none; d=google.com; s=arc-20160816; b=WCox7uSh94O3xWTR+ImdbTf2Ak/sVIu6v7kioWRUaDwx6Ybf58QrBBUZNiF5ZS9NCm LBrFfvrlK4R2+QtZzhngdU4BEC+J4d5iI1R40ep4zoOVihWYbyrpBO6p0/7JVPNzKQbt n+pzUW04QA1527vAdnaZpu99ABl/Js/+P7J+1kZZJdS6tKceSqmwzrG9CpwMwoT582HU 8G64Kkiqo++8QI8+aao0mksZDCHKdLxSmJMlqEC3C3Q5PzZfePoIGMSafT3uGmzEfQtF 6ite/RPXcGNlYThtXJ69XrnjflWZRvQYBSF2+hRyuXJxACexgWY3MRMwy1DeTkNYfgdL mjhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=9wlApGGlxLKV8Z1QtRWqh8SahBtlv/0k3KyVAtCmAB4=; b=p+JNgBAb9sN9/JmBtYb7T+sBYPYFDZ3ZoWGfiYOBw562I6IFSUvaz9Om/iLD+boXGh N3Lm7GkmN4mup7/s11fVukmkmQZjU54+7oYRGSAYxKMppvcC2GFQd2PbvWMC6lxm2TAh +nyx19pjF0c06mOsiZmA+y9+PjnCDLN5boaMnUiR4q+Vh9oD2S2AZJzmoUrQ0nVq1yQ9 Cv+TR8y/DvudusihHqfYMxY57CREpKviDdmltefvb1WQ/pvBo4Ij6RlPnfGPZPBTMgnF w/DCH+bMrsh6ShR7TAphg41piih96empBzb2Yp0dE5VbjYi/0Ygs5B1PAKbB4LZXbPeT oOtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=UB5shkw7; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id k2si14887560plk.371.2021.03.22.09.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:04:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=UB5shkw7; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ED4DC6E500; Mon, 22 Mar 2021 16:04:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE0406E500; Mon, 22 Mar 2021 16:04:37 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id DD9F06199F; Mon, 22 Mar 2021 16:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429077; bh=yAy/I3E6cDxsmlVnV0YJAH5ZEQIRtNmu4zak4TbdMtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UB5shkw7Yd4R5EAaTaJbKCgGMQHdzM6i80uoGxhNLAKr58/Z+hb/X02iDZFbFM5q7 ohBr0mnuKE2zD2dZIPp5mGV/8upXxQjJIfPGJp9PdMs6uae5VNAC7zYBRMfKWnHX2T dVcWKQocYTTmbDcT2P/QpYMSgUNzpEBC5mOFpZCLPDNYvMuLPWfLzgAFpKC9vWx2UV WcW6Gm/cjDbzo+bVOJsKrlf8DWJ6XKsV5KO6yCyvx8yAazXnd03HJIpEKsAL1WBIyL rctKK7FEjfv0XP7F/8O3bxyOq6H75TM+jdZPPW1bjsoXOWVbf0YQRUVNLoyOj2UQzP uTGmECN+tjDoA== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Tejun Heo , Zefan Li , Johannes Weiner Subject: [PATCH 06/11] cgroup: fix -Wzero-length-bounds warnings Date: Mon, 22 Mar 2021 17:02:44 +0100 Message-Id: <20210322160253.4032422-7-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexei Starovoitov , dri-devel@lists.freedesktop.org, Cong Wang , Christian Brauner , Odin Ugedal , linux-scsi@vger.kernel.org, x86@kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Kalle Valo , Andrii Nakryiko , ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , "James E.J. Bottomley" , Ning Sun , Anders Larsen , Bhaskar Chowdhury , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, =?utf-8?q?Michal_Koutn=C3=BD?= , Simon Kelley , intel-gfx@lists.freedesktop.org, Roman Gushchin Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann When cgroups are enabled, but every single subsystem is turned off, CGROUP_SUBSYS_COUNT is zero, and the cgrp->subsys[] array has no members. gcc-11 points out that this leads to an invalid access in any function that might access this array: kernel/cgroup/cgroup.c: In function 'cgroup_addrm_files': kernel/cgroup/cgroup.c:460:58: warning: array subscript '' is outside the bounds of an interior zero-length array 'struct cgroup_subsys_state *[0]' [-Wzero-length-bounds] kernel/cgroup/cgroup.c:460:24: note: in expansion of macro 'rcu_dereference_check' 460 | return rcu_dereference_check(cgrp->subsys[ss->id], | ^~~~~~~~~~~~~~~~~~~~~ In file included from include/linux/cgroup.h:28, from kernel/cgroup/cgroup-internal.h:5, from kernel/cgroup/cgroup.c:31: include/linux/cgroup-defs.h:422:43: note: while referencing 'subsys' 422 | struct cgroup_subsys_state __rcu *subsys[CGROUP_SUBSYS_COUNT]; I'm not sure what is expected to happen for such a configuration, presumably these functions are never calls in that case. Adding a sanity check in each function we get the warning for manages to shut up the warnings and do nothing instead. Signed-off-by: Arnd Bergmann --- I'm grouping this together with the -Wstringop-overread warnings, since the underlying logic in gcc seems to be the same. --- kernel/cgroup/cgroup.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 9153b20e5cc6..3477f1dc7872 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -456,7 +456,7 @@ static u16 cgroup_ss_mask(struct cgroup *cgrp) static struct cgroup_subsys_state *cgroup_css(struct cgroup *cgrp, struct cgroup_subsys *ss) { - if (ss) + if (ss && (CGROUP_SUBSYS_COUNT > 0)) return rcu_dereference_check(cgrp->subsys[ss->id], lockdep_is_held(&cgroup_mutex)); else @@ -534,6 +534,9 @@ struct cgroup_subsys_state *cgroup_e_css(struct cgroup *cgrp, { struct cgroup_subsys_state *css; + if (CGROUP_SUBSYS_COUNT == 0) + return NULL; + do { css = cgroup_css(cgrp, ss); @@ -561,6 +564,9 @@ struct cgroup_subsys_state *cgroup_get_e_css(struct cgroup *cgrp, { struct cgroup_subsys_state *css; + if (CGROUP_SUBSYS_COUNT == 0) + return NULL; + rcu_read_lock(); do { @@ -630,7 +636,7 @@ struct cgroup_subsys_state *of_css(struct kernfs_open_file *of) * the matching css from the cgroup's subsys table is guaranteed to * be and stay valid until the enclosing operation is complete. */ - if (cft->ss) + if (cft->ss && CGROUP_SUBSYS_COUNT > 0) return rcu_dereference_raw(cgrp->subsys[cft->ss->id]); else return &cgrp->self; @@ -2343,6 +2349,9 @@ struct task_struct *cgroup_taskset_next(struct cgroup_taskset *tset, struct css_set *cset = tset->cur_cset; struct task_struct *task = tset->cur_task; + if (CGROUP_SUBSYS_COUNT == 0) + return NULL; + while (&cset->mg_node != tset->csets) { if (!task) task = list_first_entry(&cset->mg_tasks, @@ -4523,7 +4532,7 @@ void css_task_iter_start(struct cgroup_subsys_state *css, unsigned int flags, it->ss = css->ss; it->flags = flags; - if (it->ss) + if (it->ss && CGROUP_SUBSYS_COUNT > 0) it->cset_pos = &css->cgroup->e_csets[css->ss->id]; else it->cset_pos = &css->cgroup->cset_links; From patchwork Mon Mar 22 16:02:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406163 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1347955ejm; Mon, 22 Mar 2021 09:04:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPqur8egj9mxvwhpSrZnFj388jHW4lt+voPs0PeyYDAmgP7hJGJBD1BsEl29K8pML2pKwt X-Received: by 2002:a63:1e47:: with SMTP id p7mr267626pgm.133.1616429096377; Mon, 22 Mar 2021 09:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429096; cv=none; d=google.com; s=arc-20160816; b=csfhtADiOfVXiWuCIQGzJE3l26qWCIMV7xnaezHrkMKHYuK/G5R25Ls6byldSL7PSB O9HgLFUMTRH+Z7i50S58Jtlr+t9G9JQYL2EBsQYVPci0RISvnzFUbQWwpRdEDwcfKDV/ J+vhsgLxa7PxABshNLRnNYUezzadZFuKxrNqXE3Fad9qX9v0ozqIvC5yeZze+bRiFYPI R1+0na3VQ7DCIkOfK/TcI7GMsBKO7DaYrSG3QAIRwfqtuOe/5fnI9BRuX7sf9f7ZXqZP o+0MEgP60ljVSsUH/taoe4jeTSZHw2X7i6Y92SbAsZzeNdb/pBjMlecseUn45W+0BDYd BYuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=p0P4w23YmEONacFIdJWllZwW/ihN4F5hrAl7MpkesMc=; b=ppGn7U0ZQo/J0h+yFCRM5ulmJeQJZFq1j3PM3UYc2WAoEmfEWJ4wKzac3apMSMIiv/ VQykaNKNGWuoHo/tfxcFVz4uhVTsljpi+Y7sWnGpMxkWXy6ECMsnAgyNXq78Co0GrhAf 3+VSN+9AdNOkxOQ6h47Hryc9mk1+eQZ4yvOW3xVJ6ENKPwBS5uq8G08JWs/3pFHBl/0h nr6d3GJ+N8Sr9T9GA3yhemHMEGXrwt2m5LT6BO8FnWO7Uh+DlhtXQymN1ynXCEYF8/K8 yP9H7FBZxDS9Z0ADLOMxl3G+k9oPKNyt0RpHLjvUNzERP/j/7CW2c/4/FiPMD9/gd+g2 r+Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="qF3TQ/qA"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id z192si16245145pfc.213.2021.03.22.09.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:04:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="qF3TQ/qA"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A0746E503; Mon, 22 Mar 2021 16:04:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3414B6E503; Mon, 22 Mar 2021 16:04:54 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id C1F12619AA; Mon, 22 Mar 2021 16:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429094; bh=xAtyylaIqASvvaS85ZKuu0hXHauLkQxCojv0RLX/Mb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qF3TQ/qAB99dHQJQ17LkEWSGHzxXaa6ah0V394Zl3kvv8RzfyZLGR5LrTvWyC7H1A Y/FGboTYdhxs+1JdIoA84vXMKDdcAhTrEkBBb0UQUQKweCwvIzhlEQaLj3V5+EtINN TkIcf5XVjUiGPrExh51GxNaO8HstdwbBZt6yPypCRTLZ7dgkDLCsQKmQNcTUMokkXV S8QQatAQDJMuuHsGK0sG76w09rCi8u76J/NCDygW1XdPiFPESnsqpJ4LRffqASyFiK CjWew/HiP9HZ5pWACV/kafDp0YkSlO5krvl5NtQtLs6m/hkRHKNSKqc2U8LuhcidQu 4FzJ0OAQMgZGg== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor Subject: [PATCH 07/11] ARM: sharpsl_param: work around -Wstringop-overread warning Date: Mon, 22 Mar 2021 17:02:45 +0100 Message-Id: <20210322160253.4032422-8-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Russell King , linux-scsi@vger.kernel.org, x86@kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Kalle Valo , ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , "James E.J. Bottomley" , Ning Sun , Anders Larsen , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc warns that accessing a pointer based on a numeric constant may be an offset into a NULL pointer, and would therefore has zero accessible bytes: arch/arm/common/sharpsl_param.c: In function ‘sharpsl_save_param’: arch/arm/common/sharpsl_param.c:43:9: error: ‘memcpy’ reading 64 bytes from a region of size 0 [-Werror=stringop-overread] 43 | memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In this particular case, the warning is bogus since this is the actual pointer, not an offset on a NULL pointer. Add a local variable to shut up the warning and hope it doesn't come back. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578 Signed-off-by: Arnd Bergmann --- arch/arm/common/sharpsl_param.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/arm/common/sharpsl_param.c b/arch/arm/common/sharpsl_param.c index efeb5724d9e9..6237ede2f0c7 100644 --- a/arch/arm/common/sharpsl_param.c +++ b/arch/arm/common/sharpsl_param.c @@ -40,7 +40,9 @@ EXPORT_SYMBOL(sharpsl_param); void sharpsl_save_param(void) { - memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info)); + struct sharpsl_param_info *params = param_start(PARAM_BASE); + + memcpy(&sharpsl_param, params, sizeof(*params)); if (sharpsl_param.comadj_keyword != COMADJ_MAGIC) sharpsl_param.comadj=-1; From patchwork Mon Mar 22 16:02:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406164 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1348143ejm; Mon, 22 Mar 2021 09:05:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdy0iSud6OsLXQUGnORvkGpjBy8LNx7zftPaROyaxr2/8xMOeeb1uKn+/Sr4HRWAhfOS9Q X-Received: by 2002:a17:90a:c096:: with SMTP id o22mr68828pjs.119.1616429109921; Mon, 22 Mar 2021 09:05:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429109; cv=none; d=google.com; s=arc-20160816; b=gFXyh6LA0StJCVKG3ex1ZeMmEq1zSW1hQWGRBXMoShfd+BWAuQWV0Ee5QJut2b5//s 8W24ivZ9xP1vII3XUrzu59gX/jj6Fq0+NYLfdOGLZVSgleQigMm8YV7MmK1ToF5g+2Zh 7Zwq9uhQivKYL0fQqbqOWv1+0c871v2colitNfIgkSLUJSVc2dbKqnzOPGe3JHEz132R nJ6pIvyWsPa6RlfHN35fwTdvX6uY7whj5uxVtRIJ1d94n1eTJYFVu1jbxr1CUnDs0cis LvkS3UucnJLtkjA3zsSG5jMKfSiNqz3+/wsw15lwJdnmP90UzExsJ+EPg85n8jyjKLWp O4yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=gQ82R8+cW81M4L5RfnsgOZAPK0f64dOtSUmzxRYe6KE=; b=Fvxg3HX8+60zW9pXIoTbmIoxKuUmUX+q/GCxSYi65cfwgA8ga3WDzzWppXGDd7g2yP 6U8EVsMYaPBs5QXW+fD/cdSuHCGvh2R2ROOsebim3o+Ly7LaobJUhIc6WfZ1pmzyWcL6 o9szEjsB/laPmexkrJfUX8GLpG8F5y8N5LxAZBln/Uew8J4my94Wx0ryqeZIBxj1Bu2l DpSQ9qKFSMvdgG/B+dm9xDLg/qKgf9YN2SSRCykzZYRikT5rbdeUAK1rINNR+iTtxYmm 6EL7XTXZbcwHCmkEDh/2Rcb9+htmYbPMfSLfOb6Vv/CUZvq/2Kp+u/EsFYap8bkp7jn5 +ZAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=dwkY1GeS; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id fv8si15617014pjb.92.2021.03.22.09.05.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:05:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=dwkY1GeS; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C888D6E509; Mon, 22 Mar 2021 16:05:08 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 353626E505; Mon, 22 Mar 2021 16:05:07 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 2816A619AD; Mon, 22 Mar 2021 16:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429107; bh=hZ+CAtng3yIYZIb+ah3e8qtw8iX8HVHsX0ExOcLMkVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dwkY1GeSKE6uqnx1AxEi3VFdRhYPg81cUVXGmS7VFECNmiWnHG9H8Xs03DE5r5UkI 2VYRrKWZEbiYE/8Go+UBgggdeU5IHX8PCQyERsMz4uhXvD8S/WDGEhcAqel5lYAhxx GH5OrCzsuWJ7MemQavOxq36ZBrGw8QsN0rHVPucenBu12gisEUNifGSz6+0j2xJ9ZZ bEVaUqft+/YBHP8/oDZqfcdvztMrcHT8BJQ3udH192n6G7X4gUnHIGCuLP1ptF/QU4 TnlXa1Qe8PUzWprVm8njgDc/yGpNfz20AWAFmYDGGOfZtOuyJUs4ZC7Fgr12Ezshk/ OxLRDx1pnNY1A== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Simon Kelley , Kalle Valo , "David S. Miller" , Jakub Kicinski Subject: [PATCH 08/11] atmel: avoid gcc -Wstringop-overflow warning Date: Mon, 22 Mar 2021 17:02:46 +0100 Message-Id: <20210322160253.4032422-9-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Lee Jones , linux-scsi@vger.kernel.org, x86@kernel.org, James Smart , tboot-devel@lists.sourceforge.net, ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , "James E.J. Bottomley" , Ning Sun , Anders Larsen , cgroups@vger.kernel.org, Pascal Terjan , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, "Gustavo A. R. Silva" , linux-security-module@vger.kernel.org, Tejun Heo , intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 notices that the fields as defined in the ass_req_format structure do not match the actual use of that structure: cc1: error: writing 4 bytes into a region of size between 18446744073709551613 and 2 [-Werror=stringop-overflow=] drivers/net/wireless/atmel/atmel.c:2884:20: note: at offset [4, 6] into destination object ‘ap’ of size 6 2884 | u8 ap[ETH_ALEN]; /* nothing after here directly accessible */ | ^~ drivers/net/wireless/atmel/atmel.c:2885:20: note: at offset [4, 6] into destination object ‘ssid_el_id’ of size 1 2885 | u8 ssid_el_id; | ^~~~~~~~~~ This is expected here because the actual structure layout is variable. As the code does not actually access the individual fields, replace them with a comment and fixed-length array so prevent gcc from complaining about it. Signed-off-by: Arnd Bergmann --- drivers/net/wireless/atmel/atmel.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/atmel/atmel.c b/drivers/net/wireless/atmel/atmel.c index 707fe66727f8..ff9152d600e1 100644 --- a/drivers/net/wireless/atmel/atmel.c +++ b/drivers/net/wireless/atmel/atmel.c @@ -2881,13 +2881,18 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc) struct ass_req_format { __le16 capability; __le16 listen_interval; - u8 ap[ETH_ALEN]; /* nothing after here directly accessible */ - u8 ssid_el_id; - u8 ssid_len; - u8 ssid[MAX_SSID_LENGTH]; - u8 sup_rates_el_id; - u8 sup_rates_len; - u8 rates[4]; + u8 ssid_el[ETH_ALEN + 2 + MAX_SSID_LENGTH + 2 + 4]; + /* + * nothing after here directly accessible: + * + * u8 ap[ETH_ALEN]; + * u8 ssid_el_id; + * u8 ssid_len; + * u8 ssid[MAX_SSID_LENGTH]; + * u8 sup_rates_el_id; + * u8 sup_rates_len; + * u8 rates[4]; + */ } body; header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | @@ -2907,13 +2912,13 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc) body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period); + ssid_el_p = body.ssid_el; /* current AP address - only in reassoc frame */ if (is_reassoc) { - memcpy(body.ap, priv->CurrentBSSID, ETH_ALEN); - ssid_el_p = &body.ssid_el_id; + memcpy(ssid_el_p, priv->CurrentBSSID, ETH_ALEN); + ssid_el_p += ETH_ALEN; bodysize = 18 + priv->SSID_size; } else { - ssid_el_p = &body.ap[0]; bodysize = 12 + priv->SSID_size; } From patchwork Mon Mar 22 16:02:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406165 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1348297ejm; Mon, 22 Mar 2021 09:05:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+wuRkXgk6iOVDYcHacZ7u5cAo7tzTUxMmL+iEBGeGeLyWZkB3VJftw3yEr8ilJimVFOA8 X-Received: by 2002:a17:90a:498d:: with SMTP id d13mr86381pjh.47.1616429120485; Mon, 22 Mar 2021 09:05:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429120; cv=none; d=google.com; s=arc-20160816; b=oEldlYoS8eNjgsd7RQdD9JfcwqMMDYrlx66MI4nNe9SPfKqOH7GO7bOydD45Ye0lga GBJU1T22ZRnc7Bo4y0xQNeg3p3x+mDzvZ+jKjaKEEYgJ0rxaXysOAnMOiSj7kaCrptw5 rbg1vplcFM/wl5o2ETEyzU2Xe5bQgUUXsycwuev90BF+aOpv5HVFY10+Gkr5IFCieQ00 8otCmyaGqWUuQLGnyqA55ukS29UUfAhMmrKn4LCT6tVi02IHdTuu03cfVsk97QIlYcdL Mk+nx8zkyNTjHQ4+5CH3tL7aEUaP87l/yIlSGHKuKjwh+6juUSKCodY/uXdcwERsTgG8 jIUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=lVaBl3rZkdopO3vct4+hDOQmILxH7e6aV4WCoEQ8K7M=; b=XEgtkae7a8I41GRewxAeoCIYYbDN0dAU1T3cvxc5CmA3vuAwqRywLQXorlQHqNw6Ip Hs4qR0YwM01lq+yFwm8lkO1ojf9/OrLl71iot5aiC7cM6Y7p2ay0SLaVb8dUHYaINgaB kzQOOTd/IXMqGt09SUmDlFvjWV0B0U/5moq6y5JXwMr6ivioS/kifiR8dpFq4/pQzi+M feOO92YO+Yp1GV7JNWI+E/ZD1UpIHhmwEIevVx73b8zWdwWifZ99pszFwyUZGmZsggPU t5TkcgXb7EqJKipptM0UieI7i6koYbexZ3SjNKKhE8kAxJ42qHNuf4mH+6e/cHNx4zoc z29A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=odvbczUM; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id y15si15709747pll.388.2021.03.22.09.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:05:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=odvbczUM; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68DFF6E505; Mon, 22 Mar 2021 16:05:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id ABA246E505; Mon, 22 Mar 2021 16:05:18 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 72908619A9; Mon, 22 Mar 2021 16:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429118; bh=EPe3bIidXGt1QSXUt8K/T9qB09rG8+BNJJvNG8YjWag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=odvbczUMlcMOL6OYbdCtO6qt6RZm272nfTphlFLY6klU5CkTn017tx34pnASZGNCF IpTcV7nYkdiHmdTO4YSIbtaihkUG1yjP/yyOdl4AEWNcNqBp3RlBD18ZnYm597BmUn wbL0s1j6ZDhyXNOvtPSEo+IomEmxiiG2PhvFgAApDhn6IwYxk6QphMYP+c26QRueLZ RufWjyGVlIhAtQ1wf9LhLwHYQjNNIjPOnznUa3dYOSsg79XhSsMNd+utp3nEch/2kA G7BxSH7No+IViGt23UWj5mYSj83XwgoEag8qXDcmE/UvDP4IP5Eh1a52oCa4LWy515 1pAfWyFQAG1Kg== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , James Smart , Dick Kennedy , "James E.J. Bottomley" , "Martin K. Petersen" Subject: [PATCH 09/11] scsi: lpfc: fix gcc -Wstringop-overread warning Date: Mon, 22 Mar 2021 17:02:47 +0100 Message-Id: <20210322160253.4032422-10-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anders Larsen , dri-devel@lists.freedesktop.org, Lee Jones , linux-scsi@vger.kernel.org, x86@kernel.org, tboot-devel@lists.sourceforge.net, Kalle Valo , ath11k@lists.infradead.org, Ye Bin , Serge Hallyn , Arnd Bergmann , intel-gfx@lists.freedesktop.org, Ning Sun , Hannes Reinecke , Colin Ian King , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 warns about an strnlen with a length larger than the size of the passed buffer: drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_nvme_info_show': drivers/scsi/lpfc/lpfc_attr.c:518:25: error: 'strnlen' specified bound 4095 exceeds source size 24 [-Werror=stringop-overread] 518 | strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In this case, the code is entirely valid, as the string is properly terminated, and the size argument is only there out of extra caution in case it exceeds a page. This cannot really happen here, so just simplify it to a sizeof(). Fixes: afff0d2321ea ("scsi: lpfc: Add Buffer overflow check, when nvme_info larger than PAGE_SIZE") Signed-off-by: Arnd Bergmann --- drivers/scsi/lpfc/lpfc_attr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c index bdd9a29f4201..f6d886f9dfb3 100644 --- a/drivers/scsi/lpfc/lpfc_attr.c +++ b/drivers/scsi/lpfc/lpfc_attr.c @@ -512,11 +512,9 @@ lpfc_nvme_info_show(struct device *dev, struct device_attribute *attr, "6314 Catching potential buffer " "overflow > PAGE_SIZE = %lu bytes\n", PAGE_SIZE); - strlcpy(buf + PAGE_SIZE - 1 - - strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1), + strlcpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_NVME_INFO_MORE_STR), LPFC_NVME_INFO_MORE_STR, - strnlen(LPFC_NVME_INFO_MORE_STR, PAGE_SIZE - 1) - + 1); + sizeof(LPFC_NVME_INFO_MORE_STR) + 1); } return len; From patchwork Mon Mar 22 16:02:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406166 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1348550ejm; Mon, 22 Mar 2021 09:05:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8zUjMiCM+nAIQ1PuvzcsZogeLTL4xtyRYQqfLxOfzrnF0hI3OwGSqJ21QXhIEuoam6s0z X-Received: by 2002:a62:4c1:0:b029:1ee:70e1:75c1 with SMTP id 184-20020a6204c10000b02901ee70e175c1mr602017pfe.23.1616429134971; Mon, 22 Mar 2021 09:05:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429134; cv=none; d=google.com; s=arc-20160816; b=TxFtzK55qiUQ1AKwy0a0rB1rqcJBRO3SzZwp2TMZ90prTUPmKlexHK9EMsNvZPHCf5 4iIUFit1atz3H1R/pCjfU0qqNx/FIGKQVoRjsYbvPO27J2Tgllyby/iz9EJXOejBc07t gIYcSeu1pJF71G2If4JZ19bn3xBailpxA9YvOuZHPt0SFScPEQx3EoeUYoSSUsXb00fO E6nezVNY6YwO+97hdIOIhjan9oqD96zNx7fQ51nYCJlqWEPyf7Fr9BnOzMvygW7ntBvA L6iEVy0w8iXAErfrC1VGM9uzUy2Ax9HNqvrWXAQiPOgjBxTUauvv2n2Yn/2+2INMD8i0 hGTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=tHTEUdB1pUN2gsdd0T3EHGf2YiuQXrzy8nalwlY+pOU=; b=fhrw4iMQW6jEa5Q1zNyRcdhhFxuXVqVU0ZhdAcracNEZeCNC1xZi27JitTxxCp6kZ1 zDWu/rRFuHqWtPrtsJ9+OIW3O3b49SjIPV6JBTtoFGMA7mfa6aJGAT29zBlbyqqQ9EPp TkXkPk6ME9xCdthpddd+kVXvyLAzdjaAp1O1HtlavrIP3zcOWPSz5SjqlTTPhUGoOwAn 7Jdja2Ymn1Km8BssGXJv/MWMUpNEtuzGTCp+iFYhW/8htfYLVrNYVF3rMUkJKYULORcy tWwXlaudaYx2kHF3mbb8nKDXTJMWiM48Tq8MOdZot4sJGngWKbKJVbJcMfZPXOqW7XwI J1pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=YmX1KQkI; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id t14si14901202pgv.180.2021.03.22.09.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:05:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=YmX1KQkI; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D10076E508; Mon, 22 Mar 2021 16:05:33 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id B37206E508; Mon, 22 Mar 2021 16:05:32 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E526619B3; Mon, 22 Mar 2021 16:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429130; bh=Cz6Ib/Jy2MCBRG3RkrW7YxIgzj/6kEv+v4DuuyruVdM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmX1KQkIWDTM9oL9SIaizhQuXBgId2TgjaOHRvpRa8ujB1Hj1aOwCgrCrMNJVi2gq P8VgokfOwAmfnYZLX1rsRk4pLvkeDX2bspNuX1VYi25/JXoxXtnn7F2MgFWC0FsAFu N+uQuJ3Me21QeU0KrCs4aFbaBIGeJwlctHwPj1pA51MBMY2ra+UvbFh+zl+P+BsSj9 1ElKemq6Wxa1TUdo/FGf/LywTMYZxZt3573Q+qI3GKdCXVd48krzSZHquQETNI++01 tCB8r6B7NO2iohCFFlGopnfYJGFYOD5rOpt+nJhCejnPW+cx72ztkTHm7tbHkrEoPf S1/KeKBMSo8Ag== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter Subject: [PATCH 10/11] drm/i915: avoid stringop-overread warning on pri_latency Date: Mon, 22 Mar 2021 17:02:48 +0100 Message-Id: <20210322160253.4032422-11-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Chris Wilson , linux-scsi@vger.kernel.org, x86@kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Kalle Valo , ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , "James E.J. Bottomley" , Ning Sun , Anders Larsen , =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Aditya Swarup , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 warns about what appears to be an out-of-range array access: In function ‘snb_wm_latency_quirk’, inlined from ‘ilk_setup_wm_latency’ at drivers/gpu/drm/i915/intel_pm.c:3108:3: drivers/gpu/drm/i915/intel_pm.c:3057:9: error: ‘intel_print_wm_latency’ reading 16 bytes from a region of size 10 [-Werror=stringop-overread] 3057 | intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/intel_pm.c: In function ‘ilk_setup_wm_latency’: drivers/gpu/drm/i915/intel_pm.c:3057:9: note: referencing argument 3 of type ‘const u16 *’ {aka ‘const short unsigned int *’} drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function ‘intel_print_wm_latency’ 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv, | ^~~~~~~~~~~~~~~~~~~~~~ My guess is that this code is actually safe because the size of the array depends on the hardware generation, and the function checks for that, but at the same time I would not expect the compiler to work it out correctly, and the code seems a little fragile with regards to future changes. Simply increasing the size of the array should help. Signed-off-by: Arnd Bergmann Reviewed-by: Jani Nikula --- drivers/gpu/drm/i915/i915_drv.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 26d69d06aa6d..3567602e0a35 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1095,11 +1095,11 @@ struct drm_i915_private { * in 0.5us units for WM1+. */ /* primary */ - u16 pri_latency[5]; + u16 pri_latency[8]; /* sprite */ - u16 spr_latency[5]; + u16 spr_latency[8]; /* cursor */ - u16 cur_latency[5]; + u16 cur_latency[8]; /* * Raw watermark memory latency values * for SKL for all 8 levels From patchwork Mon Mar 22 16:02:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 406167 Delivered-To: patch@linaro.org Received: by 2002:a17:906:5290:0:0:0:0 with SMTP id c16csp1348747ejm; Mon, 22 Mar 2021 09:05:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySQsZpjqM9fbNTP6KSFPWp7sDyICgY/nxf66pMlf3LbkRPjH/O9Md03SAcg8lROz+R9f4F X-Received: by 2002:a63:fa02:: with SMTP id y2mr271875pgh.412.1616429145931; Mon, 22 Mar 2021 09:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616429145; cv=none; d=google.com; s=arc-20160816; b=E0q6yRlKNT48phzUtEcYFLGMrkpHIZROEay18evhFGu0EDrookKoLLZCxLTDumqHvp K791tTUwfZpoBUYRPtUzo0z8fYSG6bWEZryQRsd2xm9/O6aEmGwNLUcN1O/McjiyhHSu jmfhKERtZYrAnvtGabrEY1OV4lTQHrtaQsSrZ2A4LatxXKIjtXJ4UbT+GHEJkAJWKYgG V8I0yhq1jDj84VTpHpHuqACqS6v/sbLRj8sHDD10XrmmE/C/8j4lQxgSf6tAH/pfH3hD cvOmPahv6IGtaPkRI/2r0b2xKGQbYnUPmwb4QVrCTW/Vsab8zBPhw8JCnIyw9dgajU/G eNcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to; bh=KkMTz7bKFDa85flXoQs85USEpQyzT0SwJ/+yGYZgsSc=; b=Lbcg8JdS4qjDX+9KJueumDiUkpjDWW0Bs2pcqHT1AOCkBLeSrI/P+QVv3+wPms/UAF l46zhNTl3KB37H5Wgz616k68mL2go5w0ZOhob2NVfk/PXrV8GYT0TDPXv/ZCXednMlPR KfBLReZOPNvj6sfGS4vd5yzO5zHOVEXoE5xAq5IGpPafhKhaxuMz3F1Tke3wNcSqOuUW wdLXCRoPWQO0O5qP2W+zQp82o+09VSgkLfQgZRaFX+QOk7UuoH6HFHTDVUUB0PPsHbpB oTcw3aKH5vkuFuRhIUlIcO7atAVIuLnUdKk594SrPnO0RFU1MjfSdolp1g/3oKMdmtAQ ateg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=KfNQhB8I; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 15si15793803pfw.144.2021.03.22.09.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Mar 2021 09:05:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=KfNQhB8I; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E716F6E507; Mon, 22 Mar 2021 16:05:44 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4984E6E507; Mon, 22 Mar 2021 16:05:43 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 49D21619CF; Mon, 22 Mar 2021 16:05:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616429143; bh=ppc9fZupOrjA6hpvzPGCige1HMZi82rKq0OzuPiwp30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KfNQhB8I6TCilI9rWZIUvrD60VxxXK7zzzf2CzYQVcPCX4dTFC+5vrq57/HXue9eN 7bPBi+K09Uuo8FgLHJN5cLADDDnPtd+D6sEhJhO/VLvKBoLaRa1BESfKHtMpZuvnwh D3Vc4uZU9Dcg74j9eeiZa4qkcbeOz2ZvcezhMcicUmJ4FzCGExiFKR4ER32CvaOaWV akMTcdJNfGrFGH5JvGZ7qns0oNxpRTzGH0qZ76EqyoQfhjLJvxqyHurET1PBvf6svb dBMESSwDo3iJsmPDGBQ1mVtfw03/ahNqDciEznfWOfvZZJNzU8YYxi4I1doMFPdTRo oo8eGNoKcMUqQ== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Martin Sebor , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter Subject: [PATCH 11/11] [RFC] drm/i915/dp: fix array overflow warning Date: Mon, 22 Mar 2021 17:02:49 +0100 Message-Id: <20210322160253.4032422-12-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210322160253.4032422-1-arnd@kernel.org> References: <20210322160253.4032422-1-arnd@kernel.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, linux-scsi@vger.kernel.org, Animesh Manna , x86@kernel.org, James Smart , tboot-devel@lists.sourceforge.net, Uma Shankar , Kalle Valo , Ankit Nautiyal , ath11k@lists.infradead.org, Serge Hallyn , Arnd Bergmann , "James E.J. Bottomley" , Gwan-gyeong Mun , Ning Sun , Anders Larsen , Sean Paul , cgroups@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, Manasi Navare , linux-security-module@vger.kernel.org, Tejun Heo , Simon Kelley , intel-gfx@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann gcc-11 warns that intel_dp_check_mst_status() has a local array of fourteen bytes and passes the last four bytes into a function that expects a six-byte array: drivers/gpu/drm/i915/display/intel_dp.c: In function ‘intel_dp_check_mst_status’: drivers/gpu/drm/i915/display/intel_dp.c:4556:22: error: ‘drm_dp_channel_eq_ok’ reading 6 bytes from a region of size 4 [-Werror=stringop-overread] 4556 | !drm_dp_channel_eq_ok(&esi[10], intel_dp->lane_count)) { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/i915/display/intel_dp.c:4556:22: note: referencing argument 1 of type ‘const u8 *’ {aka ‘const unsigned char *’} In file included from drivers/gpu/drm/i915/display/intel_dp.c:38: include/drm/drm_dp_helper.h:1459:6: note: in a call to function ‘drm_dp_channel_eq_ok’ 1459 | bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE], | ^~~~~~~~~~~~~~~~~~~~ Clearly something is wrong here, but I can't quite figure out what. Changing the array size to 16 bytes avoids the warning, but is probably the wrong solution here. Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index 8c12d5375607..830e2515f119 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -65,7 +65,7 @@ #include "intel_vdsc.h" #include "intel_vrr.h" -#define DP_DPRX_ESI_LEN 14 +#define DP_DPRX_ESI_LEN 16 /* DP DSC throughput values used for slice count calculations KPixels/s */ #define DP_DSC_PEAK_PIXEL_RATE 2720000