From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1212C46467 for ; Wed, 4 Jan 2023 15:19:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:From:Cc:To :Subject:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ixi+csMJ4wlCzJIxg73p5IpuBcWdmrxvTLyCXoyjhzM=; b=WnSXYA8rQVBtMZ NO4tAtR3DmEgdkaVPISRtlKFdNzt8vhD0WrdsMxdnu6XgSNaMGmu05CXliUtDmKQmgjX+SjUzxrpF DUlUIWRRqiItNXM704yMd45zsOws0orRxtvikfXSNEvWeWtBWMp85ZDFAKIf8sd6L6AEJbXbUhy11 HKl1HGPhLBBEexoFDTMjQiayxFsmW7iaQS9acv1LQaYf2EOHbCts6yBcogGmrlDmEaOE2qODaTPqs pkj1lVAaUrSMeT5u9BKUSMWNh4qq9shEZZbhjlU7Ya5S3HtqA1H940b4Oi+f6p1b8sdxYhheTZmEV 8GDFd0zEjGfnXr3/zMLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pD5Xj-00A2zS-TE; Wed, 04 Jan 2023 15:19:04 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pD5Au-009san-PL for linux-um@lists.infradead.org; Wed, 04 Jan 2023 14:55:30 +0000 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 ams.source.kernel.org (Postfix) with ESMTPS id 39D22B8169E; Wed, 4 Jan 2023 14:55:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92ED4C433D2; Wed, 4 Jan 2023 14:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672844126; bh=LDSz5riE84Dr9HLlvpPEZbwgcnLNb/ra2djip+FSJBs=; h=Subject:To:Cc:From:Date:From; b=rKJzt1nzAqHJOsOC9okKH3tw6YgWP/yJVWfSi1+dK72jwp63iGCGyfO6mLvnrslOK xB1fnhgyS4Pbjc17ko/eU5KsL0U3+lQBTAUTs5ujMPcjDoDrrxyI2ytnJxC8jt7Gjl AER2vazFook2dffGKm2iAIKFgpiU1sBYypN7oGWM= Subject: Patch "um: virt-pci: Avoid GCC non-NULL warning" has been added to the 6.1-stable tree To: anton.ivanov@cambridgegreys.com,gregkh@linuxfoundation.org,johannes@sipsolutions.net,keescook@chromium.org,linux-um@lists.infradead.org,lkp@intel.com,mst@redhat.com,richard@nod.at,vincent.whitchurch@axis.com,viro@zeniv.linux.org.uk,xiujianfeng@huawei.com Cc: From: Date: Wed, 04 Jan 2023 15:48:00 +0100 Message-ID: <1672843680230167@kroah.com> MIME-Version: 1.0 X-stable: commit X-Patchwork-Hint: ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230104_065529_339775_E32BD216 X-CRM114-Status: GOOD ( 17.34 ) X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-um" Errors-To: linux-um-bounces+linux-um=archiver.kernel.org@lists.infradead.org This is a note to let you know that I've just added the patch titled um: virt-pci: Avoid GCC non-NULL warning to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: um-virt-pci-avoid-gcc-non-null-warning.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From bdc77507fecd00ddad2f502f86a48a9ec38f0f84 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 1 Dec 2022 16:23:25 -0800 Subject: um: virt-pci: Avoid GCC non-NULL warning From: Kees Cook commit bdc77507fecd00ddad2f502f86a48a9ec38f0f84 upstream. GCC gets confused about the return value of get_cpu_var() possibly being NULL, so explicitly test for it before calls to memcpy() and memset(). Avoids warnings like this: arch/um/drivers/virt-pci.c: In function 'um_pci_send_cmd': include/linux/fortify-string.h:48:33: warning: argument 1 null where non-null expected [-Wnonnull] 48 | #define __underlying_memcpy __builtin_memcpy | ^ include/linux/fortify-string.h:438:9: note: in expansion of macro '__underlying_memcpy' 438 | __underlying_##op(p, q, __fortify_size); \ | ^~~~~~~~~~~~~ include/linux/fortify-string.h:483:26: note: in expansion of macro '__fortify_memcpy_chk' 483 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ | ^~~~~~~~~~~~~~~~~~~~ arch/um/drivers/virt-pci.c:100:9: note: in expansion of macro 'memcpy' 100 | memcpy(buf, cmd, cmd_size); | ^~~~~~ While at it, avoid literal "8" and use stored sizeof(buf->data) in memset() and um_pci_send_cmd(). Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202211271212.SUZSC9f9-lkp@intel.com Fixes: ba38961a069b ("um: Enable FORTIFY_SOURCE") Cc: Richard Weinberger Cc: Anton Ivanov Cc: Johannes Berg Cc: "Michael S. Tsirkin" Cc: Al Viro Cc: Xiu Jianfeng Cc: Vincent Whitchurch Cc: linux-um@lists.infradead.org Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- arch/um/drivers/virt-pci.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/arch/um/drivers/virt-pci.c +++ b/arch/um/drivers/virt-pci.c @@ -97,7 +97,8 @@ static int um_pci_send_cmd(struct um_pci } buf = get_cpu_var(um_pci_msg_bufs); - memcpy(buf, cmd, cmd_size); + if (buf) + memcpy(buf, cmd, cmd_size); if (posted) { u8 *ncmd = kmalloc(cmd_size + extra_size, GFP_ATOMIC); @@ -182,6 +183,7 @@ static unsigned long um_pci_cfgspace_rea struct um_pci_message_buffer *buf; u8 *data; unsigned long ret = ULONG_MAX; + size_t bytes = sizeof(buf->data); if (!dev) return ULONG_MAX; @@ -189,7 +191,8 @@ static unsigned long um_pci_cfgspace_rea buf = get_cpu_var(um_pci_msg_bufs); data = buf->data; - memset(buf->data, 0xff, sizeof(buf->data)); + if (buf) + memset(data, 0xff, bytes); switch (size) { case 1: @@ -204,7 +207,7 @@ static unsigned long um_pci_cfgspace_rea goto out; } - if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, 8)) + if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, bytes)) goto out; switch (size) { Patches currently in stable-queue which might be from keescook@chromium.org are queue-6.1/um-virt-pci-avoid-gcc-non-null-warning.patch queue-6.1/random-add-helpers-for-random-numbers-with-given-floor-or-range.patch _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um