From patchwork Thu Aug 30 15:47:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582195 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B8D1B920 for ; Thu, 30 Aug 2018 15:59:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A86282C0F3 for ; Thu, 30 Aug 2018 15:59:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BA3A2C0F6; Thu, 30 Aug 2018 15:59:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 907472C0F3 for ; Thu, 30 Aug 2018 15:59:38 +0000 (UTC) Received: from localhost ([::1]:49634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPM9-0001xB-J2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:59:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCN-0006Y2-UB for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8Y-0005Qr-2G for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44508) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8X-0005Q7-QX for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:33 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdF8O030685 for ; Thu, 30 Aug 2018 15:45:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=eDhTNATvwz0R/eran1+RhIzM6VNSevCzSAtvdr4AQ90=; b=sZUWM0/Q+du1OUQC3RK3cecO7+2ovOves/zdgf9ISjK4DRizCuZYQy809cuCgJPNfb/x h/VdFLqKld4B7EiBUalpt/i/x9KNX9vHKBqIojdRc49QOrSWEhZV55i6ef/TzAKagOyy ueRyN03R/lzqKXKGn/oyZ/o+B1YMt7Nln/K+Bg5EZv89AyM0M4VfSGsfKV0utIIfUIIH /7ZM92YcnFhajcL2vTbBKz74qkZWZu4QkF0y54mjleauvFYkdqNkmf507ARt5u03/t0A avk1EmKVS/buqzIG27P1Tw22NtiTplA2vQRJSs24MfFzfmpu1IcI8XS5NNHk+Vxe/Ttf /Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2m2y2pwhhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:30 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjTha024023 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:29 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7UFjTDk014933 for ; Thu, 30 Aug 2018 15:45:29 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:29 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:04 +0100 Message-Id: <1535644031-848-2-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=735 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH 1/8] configure: Provide option to explicitly disable AVX2 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The configure script detects if the compiler has AVX2 support and automatically sets avx2_opt="yes" which in turn defines CONFIG_AVX2_OPT. There is no way of explicitly overriding this setting so this commit adds two command-line options: --enable-avx2 and --disable-avx2. The default behaviour, when no option is specified, is to maintain the current behaviour and enable AVX2 if the compiler supports it. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- configure | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 58862d2ae88a..8904a91715b3 100755 --- a/configure +++ b/configure @@ -427,7 +427,7 @@ usb_redir="" opengl="" opengl_dmabuf="no" cpuid_h="no" -avx2_opt="no" +avx2_opt="" zlib="yes" capstone="" lzo="" @@ -1332,6 +1332,10 @@ for opt do ;; --disable-glusterfs) glusterfs="no" ;; + --disable-avx2) avx2_opt="no" + ;; + --enable-avx2) avx2_opt="yes" + ;; --enable-glusterfs) glusterfs="yes" ;; --disable-virtio-blk-data-plane|--enable-virtio-blk-data-plane) @@ -1709,6 +1713,7 @@ disabled with --disable-FEATURE, default is enabled if available: libxml2 for Parallels image format tcmalloc tcmalloc support jemalloc jemalloc support + avx2 AVX2 optimization support replication replication support vhost-vsock virtio sockets device support opengl opengl support @@ -5127,7 +5132,7 @@ fi # There is no point enabling this if cpuid.h is not usable, # since we won't be able to select the new routines. -if test $cpuid_h = yes; then +if test "$cpuid_h" = "yes" -a "$avx2_opt" != "no"; then cat > $TMPC << EOF #pragma GCC push_options #pragma GCC target("avx2") @@ -5141,6 +5146,8 @@ int main(int argc, char *argv[]) { return bar(argv[0]); } EOF if compile_object "" ; then avx2_opt="yes" + else + avx2_opt="no" fi fi From patchwork Thu Aug 30 15:47:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3F01114BD for ; Thu, 30 Aug 2018 15:54:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EE122C0E7 for ; Thu, 30 Aug 2018 15:54:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 229BC2C0EA; Thu, 30 Aug 2018 15:54:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B3BE02C0E7 for ; Thu, 30 Aug 2018 15:54:25 +0000 (UTC) Received: from localhost ([::1]:49594 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPH7-0004Rk-0u for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:54:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCL-0006qH-QX for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8b-0005gE-QF for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:39 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44784) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8b-0005bn-E2 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:37 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdIom030793 for ; Thu, 30 Aug 2018 15:45:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=0gtyd5LNZ1vHOXKWwtp4sbGFPdjUjV5BAYk5VfTXmwQ=; b=WmpfLm1+sOyrpNgzZARWTAKM4TADqlSZWbvLBJ9sunKT0JSu/N+xlzYYKLNaet/ONgs4 9/U45+H8e5eLRTGMfGjHt3EsG3HJZzJVU7TlXFC5OrOame7gOl/M/OArD+JQc6kE8I6+ npBkmMfpTD0FVsGmdteVGynAduVfx8Na5o4FKX3PQWT6wmoweVrZr3+7ixchm919LQfr 2nxWTgxjM43L1Sbiq5+cg1R2yp4lggguPhrrD5MlJ0d9wTzp1NF4SjVCa4ZLCnFvEpnW 7aH9RNLYLknlPaFZhGoKBMYhfc5qLnNM6xXmETswbJnM/Oh5qeDZtnNR0sa2XL8oVSBK /g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2m2y2pwhja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:36 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjU8C013995 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:30 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjUjK007730 for ; Thu, 30 Aug 2018 15:45:30 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:30 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:05 +0100 Message-Id: <1535644031-848-3-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=924 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH 2/8] job: Fix off-by-one accesses to JobSTT and JobVerbTable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In the array dereference of JobVerbTable[verb] in job_apply_verb() the check of the index, verb, allows an overrun because an index equal to the array size is permitted. Similarly, in the array dereference of JobSTT[s0][s1] with index s1 in job_state_transition(), an off-by-one overrun is possible. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda Reviewed-by: Eric Blake --- job.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/job.c b/job.c index e36ebaafd81c..40320566f43b 100644 --- a/job.c +++ b/job.c @@ -166,7 +166,7 @@ bool job_is_internal(Job *job) static void job_state_transition(Job *job, JobStatus s1) { JobStatus s0 = job->status; - assert(s1 >= 0 && s1 <= JOB_STATUS__MAX); + assert(s1 >= 0 && s1 < JOB_STATUS__MAX); trace_job_state_transition(job, job->ret, JobSTT[s0][s1] ? "allowed" : "disallowed", JobStatus_str(s0), JobStatus_str(s1)); @@ -181,7 +181,7 @@ static void job_state_transition(Job *job, JobStatus s1) int job_apply_verb(Job *job, JobVerb verb, Error **errp) { JobStatus s0 = job->status; - assert(verb >= 0 && verb <= JOB_VERB__MAX); + assert(verb >= 0 && verb < JOB_VERB__MAX); trace_job_apply_verb(job, JobStatus_str(s0), JobVerb_str(verb), JobVerbTable[verb][s0] ? "allowed" : "prohibited"); if (JobVerbTable[verb][s0]) { From patchwork Thu Aug 30 15:47:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1C61920 for ; Thu, 30 Aug 2018 15:54:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C35A22C0E2 for ; Thu, 30 Aug 2018 15:54:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B75342C0EC; Thu, 30 Aug 2018 15:54:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5D2A52C0E9 for ; Thu, 30 Aug 2018 15:54:02 +0000 (UTC) Received: from localhost ([::1]:49593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPGj-00044o-JD for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:54:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCO-0006mW-08 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8Y-0005Rg-89 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44520) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8X-0005QI-QY for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:34 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdF8P030685 for ; Thu, 30 Aug 2018 15:45:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=p/3GpT6mCmpta1WDgi6uy9ouAWsAbVPq/7JoVAsXPOs=; b=wfUbOVKlhfIhzLnDrzR8D3XCIS+j3uKkmAGQZ0cjONj1gV0kTEPywLa6BNK7frp/GEEV OHE/hC2cbaOI9B7neU/MU0dHFRjn1gt1JlfFIWy/VqrafY1v5yJBL+/2vdpoSBeIS6ov RaEiDnj69hMTu/AaCQaICi9QLq1pEH4FgfwopHGpKYPYS8Qe2S4/tFLS0C3K768h7Otp FJ3Wh3gjiD26yxznx7nuFYk83VNCfpV/cHT48+GFk/VHcQzC4IMpOPNr31bjc7FLWPlz 4tGcjgaXLEVWOUfJD7BYMTv2JSv3IcYcYY+gTnZ0TWyxlsJotORAzhc0sl4OMD0VDwjL 5A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2m2y2pwhhq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:31 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjVLG014014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:31 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjVH6020741 for ; Thu, 30 Aug 2018 15:45:31 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:30 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:06 +0100 Message-Id: <1535644031-848-4-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=936 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH 3/8] block: Null pointer dereference in blk_root_get_parent_desc() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The dev_id returned by the call to blk_get_attached_dev_id() in blk_root_get_parent_desc() can be NULL (an internal call to object_get_canonical_path may have returned NULL) so it should be checked before dereferencing. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index fa120630be83..210eee75006a 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -136,7 +136,7 @@ static char *blk_root_get_parent_desc(BdrvChild *child) } dev_id = blk_get_attached_dev_id(blk); - if (*dev_id) { + if (dev_id && *dev_id) { return dev_id; } else { /* TODO Callback into the BB owner for something more detailed */ From patchwork Thu Aug 30 15:47:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F95414BD for ; Thu, 30 Aug 2018 15:57:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FBD52C0EA for ; Thu, 30 Aug 2018 15:57:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52A222C0EC; Thu, 30 Aug 2018 15:57:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 003DD2C0EA for ; Thu, 30 Aug 2018 15:57:15 +0000 (UTC) Received: from localhost ([::1]:49618 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPJr-00074C-7n for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:57:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCK-0006Y2-L6 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8a-0005a5-8T for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:39 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:53802) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8Z-0005Ql-Th for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:36 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdGS1000796 for ; Thu, 30 Aug 2018 15:45:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=d57m5px3UpkBjMYNbdfrJ5lORtZvHO6efeRyL6punSc=; b=ZOR9xe0TSX+hxuR4gTu4219eVYcAktGhte64RIWzgDPcQ/a/wQH9j0DrGIZC8qEnNb/d kS5rM26dcR0M0iFGM112IsoOlzh1Kj9TfQnspNM5HVII07Tb4Rqxk2ZoGe51GSGSN5wB su8Lm+efT5zvQ2RNs2ykC5d+GMX6FvZwpXHIg1xSmfpjtacp5f4z6Flo8RV2pVhuq8Ce +VtLDhpf9JiMAQp1vRcIZxQznuo5/wLJwVrRF1hNuC3K/+gSo7t33Ijic8PbhVa4vhDf jxENLQIGiTLW+off8aJ3knTlK63aMEGwNeVo8Cm0Sxh9kXoU8WOxiK2WlVub8UTmfq+2 XQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2m2xhu5j54-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:33 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjWhi014055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:32 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjV9e007750 for ; Thu, 30 Aug 2018 15:45:32 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:31 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:07 +0100 Message-Id: <1535644031-848-5-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=792 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH 4/8] qemu-img: potential Null pointer deref in img_commit() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The function block_job_get() may return NULL so before dereferencing the 'job' pointer in img_commit() it should be checked. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- qemu-img.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index b12f4cd19b0a..51fe09bd08ed 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1029,6 +1029,9 @@ static int img_commit(int argc, char **argv) } job = block_job_get("commit"); + if (job == NULL) { + goto unref_backing; + } run_block_job(job, &local_err); if (local_err) { goto unref_backing; From patchwork Thu Aug 30 15:47:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1BCB14BD for ; Thu, 30 Aug 2018 15:56:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19A42C0EA for ; Thu, 30 Aug 2018 15:56:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D63282C0EC; Thu, 30 Aug 2018 15:56:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33A002C0EA for ; Thu, 30 Aug 2018 15:56:49 +0000 (UTC) Received: from localhost ([::1]:49615 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPJQ-0006Qq-7W for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:56:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54805) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCN-0006qH-VL for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8Y-0005R0-3Q for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:37 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44584) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8X-0005QX-RT for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:33 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdGU6030721 for ; Thu, 30 Aug 2018 15:45:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=y/iXqS2mgXQufQSoaTle9V2E2l5V2Czhnww5kswlI9A=; b=eI9DCzfj6vT65DDY8jNDxn0z0M0frBRSoAbgw4z0pEp1PvylWsmIaEh7EnmyFCCx8awi fsE5HMJKo5jKckGrs7coctxpKLBbGR2kkfoNnLPGkhudNHXvvfMyvANWL8It+uHyDNVX kSQ69VDyDgr3qz4jZCaHuPKh15+B9KoANu3LVLCk4OjZINDRQdIiGUJF7+KQSE4ub6d1 EVOdSv6fFqcQHgw0yOfj/6agTKHaBENeX+vHcgcoCCusIH+xx2PPG951hIvvlaLIiSxg c7v0WBUMHYCe0UJ4Jws8VJCcZznOqqwjGJ+hQdfYp2UUFBcE4pnF2BCTOZPlwMJuit/D qg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2m2y2pwhhv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:32 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjWLW014069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:32 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjWL2020756 for ; Thu, 30 Aug 2018 15:45:32 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:32 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:08 +0100 Message-Id: <1535644031-848-6-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=4 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=750 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH 5/8] block: Fix potential Null pointer dereferences in vvfat.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The calls to bdrv_new_open_driver(), find_mapping_for_cluster(), and array_get_next() may return NULL but it isn't always checked for before dereferencing the value returned. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- block/vvfat.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/block/vvfat.c b/block/vvfat.c index fc41841a5c3c..0f1f10a2f94b 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -448,6 +448,9 @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename) for(i=0;idirectory)); + if (entry == NULL) { + continue; + } entry->attributes=0xf; entry->reserved[0]=0; entry->begin=0; @@ -665,6 +668,9 @@ static inline void fat_set(BDRVVVFATState* s,unsigned int cluster,uint32_t value } else { int offset = (cluster*3/2); unsigned char* p = array_get(&(s->fat), offset); + if (p == NULL) { + return; + } switch (cluster&1) { case 0: p[0] = value&0xff; @@ -730,6 +736,9 @@ static inline direntry_t* create_short_and_long_name(BDRVVVFATState* s, if(is_dot) { entry=array_get_next(&(s->directory)); + if (entry == NULL) { + return NULL; + } memset(entry->name, 0x20, sizeof(entry->name)); memcpy(entry->name,filename,strlen(filename)); return entry; @@ -844,6 +853,12 @@ static int read_directory(BDRVVVFATState* s, int mapping_index) /* create mapping for this file */ if(!is_dot && !is_dotdot && (S_ISDIR(st.st_mode) || st.st_size)) { s->current_mapping = array_get_next(&(s->mapping)); + if (s->current_mapping == NULL) { + fprintf(stderr, "Failed to create mapping for file\n"); + g_free(buffer); + closedir(dir); + return -2; + } s->current_mapping->begin=0; s->current_mapping->end=st.st_size; /* @@ -941,6 +956,9 @@ static int init_directories(BDRVVVFATState* s, /* add volume label */ { direntry_t* entry=array_get_next(&(s->directory)); + if (entry == NULL) { + return -1; + } entry->attributes=0x28; /* archive | volume label */ memcpy(entry->name, s->volume_label, sizeof(entry->name)); } @@ -953,6 +971,9 @@ static int init_directories(BDRVVVFATState* s, s->cluster_count=sector2cluster(s, s->sector_count); mapping = array_get_next(&(s->mapping)); + if (mapping == NULL) { + return -1; + } mapping->begin = 0; mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; @@ -1630,6 +1651,9 @@ static void schedule_rename(BDRVVVFATState* s, uint32_t cluster, char* new_path) { commit_t* commit = array_get_next(&(s->commits)); + if (commit == NULL) { + return; + } commit->path = new_path; commit->param.rename.cluster = cluster; commit->action = ACTION_RENAME; @@ -1639,6 +1663,9 @@ static void schedule_writeout(BDRVVVFATState* s, int dir_index, uint32_t modified_offset) { commit_t* commit = array_get_next(&(s->commits)); + if (commit == NULL) { + return; + } commit->path = NULL; commit->param.writeout.dir_index = dir_index; commit->param.writeout.modified_offset = modified_offset; @@ -1649,6 +1676,9 @@ static void schedule_new_file(BDRVVVFATState* s, char* path, uint32_t first_cluster) { commit_t* commit = array_get_next(&(s->commits)); + if (commit == NULL) { + return; + } commit->path = path; commit->param.new_file.first_cluster = first_cluster; commit->action = ACTION_NEW_FILE; @@ -1657,6 +1687,9 @@ static void schedule_new_file(BDRVVVFATState* s, static void schedule_mkdir(BDRVVVFATState* s, uint32_t cluster, char* path) { commit_t* commit = array_get_next(&(s->commits)); + if (commit == NULL) { + return; + } commit->path = path; commit->param.mkdir.cluster = cluster; commit->action = ACTION_MKDIR; @@ -2261,6 +2294,9 @@ static mapping_t* insert_mapping(BDRVVVFATState* s, } if (index >= s->mapping.next || mapping->begin > begin) { mapping = array_insert(&(s->mapping), index, 1); + if (mapping == NULL) { + return NULL; + } mapping->path = NULL; adjust_mapping_indices(s, index, +1); } @@ -2428,6 +2464,9 @@ static int commit_direntries(BDRVVVFATState* s, direntry_t* direntry = array_get(&(s->directory), dir_index); uint32_t first_cluster = dir_index == 0 ? 0 : begin_of_direntry(direntry); mapping_t* mapping = find_mapping_for_cluster(s, first_cluster); + if (mapping == NULL) { + return -1; + } int factor = 0x10 * s->sectors_per_cluster; int old_cluster_count, new_cluster_count; @@ -2494,6 +2533,9 @@ DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapp direntry = array_get(&(s->directory), first_dir_index + i); if (is_directory(direntry) && !is_dot(direntry)) { mapping = find_mapping_for_cluster(s, first_cluster); + if (mapping == NULL) { + return -1; + } assert(mapping->mode & MODE_DIRECTORY); ret = commit_direntries(s, first_dir_index + i, array_index(&(s->mapping), mapping)); @@ -2522,6 +2564,10 @@ static int commit_one_file(BDRVVVFATState* s, assert(offset < size); assert((offset % s->cluster_size) == 0); + if (mapping == NULL) { + return -1; + } + for (i = s->cluster_size; i < offset; i += s->cluster_size) c = modified_fat_get(s, c); @@ -2668,6 +2714,9 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s) if (commit->action == ACTION_RENAME) { mapping_t* mapping = find_mapping_for_cluster(s, commit->param.rename.cluster); + if (mapping == NULL) { + return -1; + } char* old_path = mapping->path; assert(commit->path); @@ -2692,6 +2741,9 @@ static int handle_renames_and_mkdirs(BDRVVVFATState* s) if (is_file(d) || (is_directory(d) && !is_dot(d))) { mapping_t* m = find_mapping_for_cluster(s, begin_of_direntry(d)); + if (m == NULL) { + return -3; + } int l = strlen(m->path); char* new_path = g_malloc(l + diff + 1); @@ -3193,6 +3245,10 @@ static int enable_write_target(BlockDriverState *bs, Error **errp) backing = bdrv_new_open_driver(&vvfat_write_target, NULL, BDRV_O_ALLOW_RDWR, &error_abort); + if (!backing) { + ret = -EINVAL; + goto err; + } *(void**) backing->opaque = s; bdrv_set_backing_hd(s->bs, backing, &error_abort); From patchwork Thu Aug 30 15:47:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DFAD14BD for ; Thu, 30 Aug 2018 15:51:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F3972C0B4 for ; Thu, 30 Aug 2018 15:51:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8310A2C0BC; Thu, 30 Aug 2018 15:51:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3345B2C0B4 for ; Thu, 30 Aug 2018 15:51:37 +0000 (UTC) Received: from localhost ([::1]:49580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPEO-0000KU-Dy for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:51:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCA-0006Y2-Tt for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8j-0005u3-87 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:48 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:53914) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8g-0005lH-2y for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:43 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdGs5000803 for ; Thu, 30 Aug 2018 15:45:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=0905u8WgI+JpxzHiVD9d7NZj9e+qCkCdXVrEqr/vpeQ=; b=Ok2UZrAU1fjYp5scdxZfc6WdaXVw4SIDzWudcutU6g01eW4gmsAdfNNGsJxn47VdyHkf mX1mb2M03FLVDgVHsvG53maF1I1lE4hk86rA8QmCp1HPfQWmbCTb44hR4z4zHMvhw4Dk fYX8QXwyDCPry5Yn2q2vJYctoQRDZXImAkLMVHIpibM/X0EFhF2l+6JCRUBGZDXGbMSB 8jOcs5XTEfnzzeRL9GVdNmlixYhpVTHP37yekTUQYMu3yb6VHUlxpytGM3TetdPfadMx UlDtoLE3JdE9C8XySl32p8xmIC+KPThE4D2wExv47z4eeXPZrkeTeO2K5cVVwbe7dULQ Zw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2m2xhu5j5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:39 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjX9i014489 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:34 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjXkq007757 for ; Thu, 30 Aug 2018 15:45:33 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:33 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:09 +0100 Message-Id: <1535644031-848-7-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=741 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH 6/8] block: dump_qlist() may dereference a Null pointer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A NULL 'list' passed into function dump_qlist() isn't correctly validated and can be passed to qlist_first() where it is dereferenced. This could be resolved by checking if the list is NULL in dump_qlist() and returning immediately. However, the general case can be handled by adding a NULL arg check to to qlist_first() and qlist_next() and all the callers to those functions handle that cleanly. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- include/qapi/qmp/qlist.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index 8d2c32ca2863..1ec716e2eb9e 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -58,11 +58,17 @@ void qlist_destroy_obj(QObject *obj); static inline const QListEntry *qlist_first(const QList *qlist) { + if (!qlist) { + return NULL; + } return QTAILQ_FIRST(&qlist->head); } static inline const QListEntry *qlist_next(const QListEntry *entry) { + if (!entry) { + return NULL; + } return QTAILQ_NEXT(entry, next); } From patchwork Thu Aug 30 15:47:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D17C920 for ; Thu, 30 Aug 2018 15:51:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F16792C137 for ; Thu, 30 Aug 2018 15:51:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE9392C141; Thu, 30 Aug 2018 15:51:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A362E2C129 for ; Thu, 30 Aug 2018 15:51:09 +0000 (UTC) Received: from localhost ([::1]:49579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPDw-0008DI-U5 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:51:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCN-0006mW-40 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8a-0005Zb-5O for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:39 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8Z-0005Wl-T1 for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:36 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdGcV030752 for ; Thu, 30 Aug 2018 15:45:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=SJlakGcyh1isXxPK32Wq6iy3spKyo/ITMcBBwJY1kEw=; b=Tk8L2nSZ2O3MwudVcI03F2Zn3e8yQ9EWwMkQ4522nhmtIldu7R3LK8HKlx2wZ4Mz6a8a CutM10Lv7HnTQjrlGpzNS8l3QeutuBa6YvmdYFYtpBmLvwHgi9vL35U9nG0+DYCJ2IDu vb8FBDsvbsD4o1/PsPxixjl8+L8oovMHtvZF4QuPJ5Vora8HuR9Hn0rVzuo5liDb6vfp IdCOShc2tuv71pLSRJfyzdioSs58CkjQ0gP1FvKK0e5AGM0Hnf3CiNv+HusoEVyV3qLR i6G3yy4/o3mdtEECFuJ8v72r2x1yMJkWnYdjl9pYJKY73iPCd+3j4P+ZiWaQDQsfpzT0 yg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2m2y2pwhj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:35 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjY3s014142 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:34 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjYmU007767 for ; Thu, 30 Aug 2018 15:45:34 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:33 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:10 +0100 Message-Id: <1535644031-848-8-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=759 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH 7/8] io: file descriptor not initialized in qio_channel_command_new_spawn() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Incorrect checking of flags could result in uninitialized file descriptor being used. Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- io/channel-command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io/channel-command.c b/io/channel-command.c index 3e7eb17eff54..38deb687da21 100644 --- a/io/channel-command.c +++ b/io/channel-command.c @@ -59,10 +59,10 @@ qio_channel_command_new_spawn(const char *const argv[], flags = flags & O_ACCMODE; - if (flags == O_RDONLY) { + if ((flags & O_RDONLY) == O_RDONLY) { stdinnull = true; } - if (flags == O_WRONLY) { + if ((flags & O_WRONLY) == O_WRONLY) { stdoutnull = true; } From patchwork Thu Aug 30 15:47:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10582157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2627920 for ; Thu, 30 Aug 2018 15:51:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C27862C122 for ; Thu, 30 Aug 2018 15:51:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C074E2C131; Thu, 30 Aug 2018 15:51:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 17F682C12A for ; Thu, 30 Aug 2018 15:51:03 +0000 (UTC) Received: from localhost ([::1]:49577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPDq-000864-RR for patchwork-qemu-devel@patchwork.kernel.org; Thu, 30 Aug 2018 11:51:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53877) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvPCH-0006Y2-Cm for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:49:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvP8b-0005g2-NX for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:41 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:44776) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvP8b-0005bU-Av for qemu-devel@nongnu.org; Thu, 30 Aug 2018 11:45:37 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7UFdFJb030693 for ; Thu, 30 Aug 2018 15:45:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=37tlN+uNEbXiAuG12LZsugPUOLPaqdHi0hOXiFXHC9o=; b=Aqg/iDWpKGRwT3IWgbtmN+gTEE/L+1YlzFL9XVqKEG3HdJpvi7dTUldUvwtOh/An2qKV tBCXnU4N2+kh8g03NyrBIzS/hKV5A+/dgGPD/jRdkGaYrqqVuPz4uLR3Jbd7ibm5K/O3 7Kpete7+KDalpyLeiAf/0GYN2GPRx+toUfhBnd5Hh6lzMKWVaPHDU/WUvXbaVunWXuR3 VngYUeV7odMRvHLvT9lrY0okRSS9VqGAf0KEDDgE1nkwmHsvN5NAIfeC7vqv1va2cwUx XX3f9z47q5LVjbkJnnC3TmwTP0MHlH7ZZ42kNjghEHg8cMftoMOJe4ORlPhJrg5yNovy jQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2m2y2pwhj6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:36 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7UFjYZd011026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Aug 2018 15:45:35 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7UFjYIM017482 for ; Thu, 30 Aug 2018 15:45:34 GMT Received: from ol7.uk.oracle.com (/10.175.215.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 30 Aug 2018 08:45:34 -0700 From: Liam Merwick To: qemu-devel@nongnu.org Date: Thu, 30 Aug 2018 16:47:11 +0100 Message-Id: <1535644031-848-9-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> References: <1535644031-848-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=863 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808300162 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH 8/8] qcow2: Read outside array bounds in qcow2_pre_write_overlap_check() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The commit for 0e4e4318eaa5 increments QCOW2_OL_MAX_BITNR but does not add an array entry for QCOW2_OL_BITMAP_DIRECTORY_BITNR to metadata_ol_names[]. As a result, an array dereference of metadata_ol_names[8] in qcow2_pre_write_overlap_check() could result in a read outside of the array bounds. Fixes: 0e4e4318eaa5 ('qcow2: add overlap check for bitmap directory') Cc: Vladimir Sementsov-Ogievskiy Signed-off-by: Liam Merwick Reviewed-by: Darren Kenny Reviewed-by: Mark Kanda --- block/qcow2-refcount.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 3c539f02e5ec..6504e7421324 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -2719,14 +2719,15 @@ int qcow2_check_metadata_overlap(BlockDriverState *bs, int ign, int64_t offset, } static const char *metadata_ol_names[] = { - [QCOW2_OL_MAIN_HEADER_BITNR] = "qcow2_header", - [QCOW2_OL_ACTIVE_L1_BITNR] = "active L1 table", - [QCOW2_OL_ACTIVE_L2_BITNR] = "active L2 table", - [QCOW2_OL_REFCOUNT_TABLE_BITNR] = "refcount table", - [QCOW2_OL_REFCOUNT_BLOCK_BITNR] = "refcount block", - [QCOW2_OL_SNAPSHOT_TABLE_BITNR] = "snapshot table", - [QCOW2_OL_INACTIVE_L1_BITNR] = "inactive L1 table", - [QCOW2_OL_INACTIVE_L2_BITNR] = "inactive L2 table", + [QCOW2_OL_MAIN_HEADER_BITNR] = "qcow2_header", + [QCOW2_OL_ACTIVE_L1_BITNR] = "active L1 table", + [QCOW2_OL_ACTIVE_L2_BITNR] = "active L2 table", + [QCOW2_OL_REFCOUNT_TABLE_BITNR] = "refcount table", + [QCOW2_OL_REFCOUNT_BLOCK_BITNR] = "refcount block", + [QCOW2_OL_SNAPSHOT_TABLE_BITNR] = "snapshot table", + [QCOW2_OL_INACTIVE_L1_BITNR] = "inactive L1 table", + [QCOW2_OL_INACTIVE_L2_BITNR] = "inactive L2 table", + [QCOW2_OL_BITMAP_DIRECTORY_BITNR] = "bitmap directory", }; /*