From patchwork Thu Jun 21 22:21:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Esfahani via X-Patchwork-Id: 932975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nongnu.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=digitalocean.com header.i=@digitalocean.com header.b="JQGqa/gg"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41Bbp20NMxz9s3C for ; Fri, 22 Jun 2018 08:23:53 +1000 (AEST) Received: from localhost ([::1]:57813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fW7zb-0005sE-84 for incoming@patchwork.ozlabs.org; Thu, 21 Jun 2018 18:23:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fW7xs-00056H-EH for qemu-devel@nongnu.org; Thu, 21 Jun 2018 18:22:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fW7xo-0008Fo-9Y for qemu-devel@nongnu.org; Thu, 21 Jun 2018 18:22:04 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35638) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fW7xo-0008EF-2W for qemu-devel@nongnu.org; Thu, 21 Jun 2018 18:22:00 -0400 Received: by mail-pf0-x243.google.com with SMTP id c22-v6so2199987pfi.2 for ; Thu, 21 Jun 2018 15:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digitalocean.com; s=google; h=from:to:cc:subject:date:message-id; bh=MwNhCxC1s8i4xs07Ru5MLLOluEpGoShTV8bcgdNfzn4=; b=JQGqa/gg/y5c0oxyv0w6T/rqsXOcMRPMPs0nzGD5j+BDnIkNzHKNdjD2z05EchzPra QsYDfldbu8UROma0/0czwUbG1h1PfD52l/qV3Xi48liYl3cAOndfWAtoIdaY8/Ozp2PA ufJD66yrM5RbQ6gl25RlO9Aiuyg/gNxhClm5Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=MwNhCxC1s8i4xs07Ru5MLLOluEpGoShTV8bcgdNfzn4=; b=hQl3g6wQrBg9i0mQ6hPvDK9fmwdGRhYQRAYaUVdOnLEUBQ7i3CyTTotFGg9fAIDmqq ySrFs2Zelr8rKkOeNckE7/lDFJOQM51UiCpH9hXtY/fjDy/bmozry/u2lti+p16lEjBx 2KgPHbjfSydaHiozN2CXnzE2tiiF0E6bo3Nll7AQZ9lrKQGt/axnHgNKWgfyaJwcEBl2 BG+z1tAhDnC/iYVKQS2rMaZhFiOPLamuUzJOm6KhN8chKbnS9Z6TqL/zBtl8ZrrEZcZq pO5pJ0/vtMgYcy+CX6Da8tyK44lq3pYVPlyMGEC+ZgnRB54JYqUC8uuD3+N0R3MifJJM jZMg== X-Gm-Message-State: APt69E2o7/qW4zu4EnAwgtPkjDlyjGEQ0qOZT7QpD0XxgekMhoUYe+Mn v5S5Ts8Rm0w8KEBD0L5l1GZipA== X-Google-Smtp-Source: ADUXVKLhCetKcTvQpdxcVNWkDYQyggaS1pbTEV5nESsWd40ddnnGXpG1uXyE65XgAH+XD+afgu9rJw== X-Received: by 2002:a63:3641:: with SMTP id d62-v6mr23413338pga.18.1529619719224; Thu, 21 Jun 2018 15:21:59 -0700 (PDT) Received: from breakout.internal.digitalocean.com (97-120-190-204.ptld.qwest.net. [97.120.190.204]) by smtp.gmail.com with ESMTPSA id v26-v6sm8633431pfe.13.2018.06.21.15.21.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 15:21:58 -0700 (PDT) Received: by breakout.internal.digitalocean.com (Postfix, from userid 1000) id EA7C58A2A52; Thu, 21 Jun 2018 15:21:57 -0700 (PDT) To: naravamudan@digitalocean.com Date: Thu, 21 Jun 2018 15:21:41 -0700 Message-Id: <20180621222143.27266-1-naravamudan@digitalocean.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v3 0/2] linux-aio: fix two NULL pointer dereferences failure paths 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: , X-Patchwork-Original-From: Nishanth Aravamudan via Qemu-devel From: Cameron Esfahani via Reply-To: Nishanth Aravamudan Cc: Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" laio_init() can fail for a couple of reasons, which will lead to a NULL pointer dereference in laio_attach_aio_context(), called from aio_get_linux_aio(). Test case 1: Set /proc/sys/fs/max-aio-nr to 0. Start a guest with an aio=native disk. Result: laio_init() returns NULL due to not being able to allocate any AIO contexts. This NULL is assigned to ctx->linux_aio and dereferenced in aio_get_linux_aio. Test case 2: Set /proc/sys/fs/max-aio-nr to 128. Start a guest with an aio=native disk and one in-use I/O thread. Result: laio_init() returns NULL due to not being able to allocate additional AIO contexts for the I/O thread. This NULL is assigned to ctx->linux_aio and dereferenced in aio_get_linux_aio. Thanks to Jon Snow, Eric Blake and Kevin Wolf for review comments on v1 and v2. Nishanth Aravamudan (2): linux-aio: properly bubble up errors from initialization file-posix: reconfigure aio on iothread start block/file-posix.c | 33 ++++++++++++++++++++++++++++----- block/linux-aio.c | 15 ++++++++++----- include/block/aio.h | 3 +++ include/block/raw-aio.h | 2 +- stubs/linux-aio.c | 2 +- util/async.c | 16 +++++++++++++--- 6 files changed, 56 insertions(+), 15 deletions(-)