From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFD9142B75F for ; Fri, 29 May 2026 15:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780068294; cv=none; b=Jg2H9/e74b3w8urbiwcge1R1RDWTeRY+tfppShXUZHpWXR7xrkwXZ/gjT5b8BLnd16o2TJ5d9dLUQ3f6jY4SovR/nkRY+Xbe87VWxa8BnhGD5jafhjUP+jAlb5r6aScFBPrDxARAXufxPG4S1rlErG4KZY6RC8c+Sczevv0gzRw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780068294; c=relaxed/simple; bh=CCqjoUNUurzYE4twri0CPtkeKv57rqlJVdiWTN8T65w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OHp7927n5tSReq9HCCQZm2TCwqYbW4bvwF5bTCnXphkLpLsB8l2i/lRjkzvKWLFey4YkdurZ7aveZ+wzoI0BAPcwTjzAS7RoZL1te0qXfRapbMCkxQigz0GReabrzZHij395Rp8Ptgkm+LE54iAFLfAJ20pcp9na+z/htH4O5Xc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=N3Y9CTfP; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=aTu/uLTt; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N3Y9CTfP"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="aTu/uLTt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1780068292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vnDpUYDWGGzhd8LJgVzrd2lW64WfRqjlcwd6dZFOBgQ=; b=N3Y9CTfPsVAOdeGsTPulohIFLqeB+L7KIOJcExm0i0SHSVpNabTYsRoTCY/k68v7Cz0xIb GU+ipG7mZYTbTimulzmPmOckHChw8P725ppswbNHSyTnlnU8YEFPbk3g/B1cmIlFnlqfxS C/SUhdrQaHh+4hXKwzuFOdsfDbFFsiU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-vV5t9NXAPXe4lgjrXRoXjA-1; Fri, 29 May 2026 11:24:50 -0400 X-MC-Unique: vV5t9NXAPXe4lgjrXRoXjA-1 X-Mimecast-MFC-AGG-ID: vV5t9NXAPXe4lgjrXRoXjA_1780068289 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-45ef63d1214so173673f8f.3 for ; Fri, 29 May 2026 08:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1780068289; x=1780673089; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=vnDpUYDWGGzhd8LJgVzrd2lW64WfRqjlcwd6dZFOBgQ=; b=aTu/uLTt3NKJJb1OPZ/VCrfk36tFGQFiABLCGgxla3tEkwnZCxHFKDV6ezVsQMZSlW n7gX23Aky6TTBd+HrWsKRXg1H/eHK7kU/7Bap6K9H97XMVe1yrewxvxK8raMnGDUNJvS SCnKLPoAIRoSK7Zw0leNrEvaCTzOEMCKWAHfyPRwbml1ky10zxPBPuerq/yHvpvO+GwE ddfpMsiK8jiKZtkS5zIK1Osq7bn8XUAlwxMyDiBhNSQ59ONP2VBOhYNy9LMarC+QOP2+ bDjvd+8DhUBRmLyIjYuc/6Y3kLaFze4FFNqWNhSPcKCZ3QvtKF5Cq57n0Qr/Bjy5Np2l ceEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780068289; x=1780673089; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vnDpUYDWGGzhd8LJgVzrd2lW64WfRqjlcwd6dZFOBgQ=; b=N47U/rMmTGWqWJZ7QFppZ4OfPEa+x6jSn4+08KkVNRKio0YrrGTUEXJ8O4EBOazeEc CYdktRTMGnRySASWzKtRNsB3PInp9/FiyAVXDw7Gk92E/qkIgQeOKOkdClG4IZreA+cI pP83e0sVwDmXZM4PKNDXBP+uENrWJ70qc92spzpLOZxRjAlBsKJRaci63SMoBjxE1Yhl +QHD3h0W7YWgNvaqHio7Jf8zRgSh0Q5WYLHSm+cwgK6AW0L6Wsc7fhfBaMJjMlv195VH WzawVpcDIy84XPk65ZqstckfwFTJfUHX1QFWkhua5Iu8nkvYIH7Ip7m1bRZ4BDHLllvc iokw== X-Gm-Message-State: AOJu0Yz81Nm7kAtuIgPKt2aZWkFD/E+HS1NsnEyWpbiJ3Z88syJqVg9V u6FaSi46KeUKBoi8oMZZS4NjOv77FFij4QgTvfRPr+gfwu8LrXhhB0IZT4B47X4bTDNJtYG8y1N X16K1JhTkOWdB3wTwvy1ZlhEwEWVZ6STkuZQofpHS8fpXM2d2Yof8G5GDYtAeuKB982UUU6ZuRk UOZcpPiYU2KKioXQHfj8BcDF0P9wSdQbmewe+2N5N/oLY= X-Gm-Gg: Acq92OHnCEWrOwBbGMEGAETpKwpg6w4N4nlGj84P9LPeFBx/yxgn6ylZTOnj0dxsA08 j8TSnkmrEyyqlAuuYOxD6C4t7KmouH60y+5LyFE7/UKS9FO+KS+uRWCFFdot6mh7IqNFY2ivu9C FXOPYiUq/YXcFHZU8N0jECeeiXiO4RuHFsDZovwBdYH5AVXkBV+8wUDnZFH4etOkbZ88QLAc8rK lLm1CWGtx8ORls2y3BHVQaSHWNscf1DVeMpYqy57vWY7Q+cmndH4lcZ37O/qIif+X0hyxYDm932 m37nu+otT7mpmdilNYW65JwAkjUuflbKnBT5G5nmVcsvp1B8GawPxmKwFoFeVG/MyAMJVYoMNu8 i/TRnFGwqoCasoyo0o/hRgmwSy8v778P4nuWZpsiPHYhSD4Hoke2rDg== X-Received: by 2002:a05:6000:549:b0:43b:4f86:e985 with SMTP id ffacd0b85a97d-45ef6b816bemr370800f8f.33.1780068289212; Fri, 29 May 2026 08:24:49 -0700 (PDT) X-Received: by 2002:a05:6000:549:b0:43b:4f86:e985 with SMTP id ffacd0b85a97d-45ef6b816bemr370703f8f.33.1780068288597; Fri, 29 May 2026 08:24:48 -0700 (PDT) Received: from redhat.com (IGLD-80-230-25-45.inter.net.il. [80.230.25.45]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45ef354bb62sm3964455f8f.19.2026.05.29.08.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2026 08:24:48 -0700 (PDT) Date: Fri, 29 May 2026 11:24:43 -0400 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: "David Hildenbrand (Arm)" , Jason Wang , Xuan Zhuo , Eugenio =?utf-8?B?UMOpcmV6?= , Muchun Song , Oscar Salvador , Andrew Morton , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Brendan Jackman , Johannes Weiner , Zi Yan , Baolin Wang , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Hugh Dickins , Matthew Brost , Joshua Hahn , Rakie Kim , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Christoph Lameter , David Rientjes , Roman Gushchin , Harry Yoo , Axel Rasmussen , Yuanchu Xie , Wei Xu , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , virtualization@lists.linux.dev, linux-mm@kvack.org, Andrea Arcangeli Subject: [PATCH v9 28/37] virtio_balloon: disable indirect descriptors Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent A follow-up patch (DEVICE_INIT_ON_INFLATE) adds an inbuf (bitmap) alongside the outbuf (pfns), making total_sg=2. With INDIRECT_DESC negotiated, virtqueue_use_indirect() triggers for total_sg > 1. Balloon never needs more than 2 entries and virtqueue sizes are 128+, so indirect descriptors are unnecessary. Disabling them avoids a GFP_KERNEL allocation inside virtqueue_add_sgs when VIRTIO_RING_F_INDIRECT_DESC is negotiated. This allocation could trigger OOM reclaim while balloon_lock is held, leading to a deadlock: OOM notifier -> leak_balloon -> balloon_lock. With single-buffer submissions (previous patch) and no indirect descriptors, virtqueue_add never allocates memory. Signed-off-by: Michael S. Tsirkin Assisted-by: Claude:claude-opus-4-6 --- drivers/virtio/virtio_balloon.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 53b4a3984e7d..1fa1c7fa285f 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -7,6 +7,7 @@ */ #include +#include #include #include #include @@ -1175,6 +1176,13 @@ static int virtballoon_validate(struct virtio_device *vdev) else if (!virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_REPORTING); + /* + * Balloon submits 1-2 sg entries max per buffer, virtqueue + * sizes are 128+. Disable indirect descriptors to avoid + * GFP_KERNEL allocation in virtqueue_add under balloon_lock, + * which could deadlock via OOM -> oom_notify -> leak_balloon. + */ + __virtio_clear_bit(vdev, VIRTIO_RING_F_INDIRECT_DESC); __virtio_clear_bit(vdev, VIRTIO_F_ACCESS_PLATFORM); return 0; } -- MST