From patchwork Fri Sep 27 16:51:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Remington Brasga X-Patchwork-Id: 1990349 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=uci.edu header.i=@uci.edu header.a=rsa-sha256 header.s=google header.b=YKC+aHS8; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=lvlc=qz=vger.kernel.org=linux-ext4+bounces-4364-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XFc2164tJz1xt8 for ; Sat, 28 Sep 2024 02:51:53 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XFc206hZ8z4x8b for ; Sat, 28 Sep 2024 02:51:52 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4XFc206dRCz4xTS; Sat, 28 Sep 2024 02:51:52 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45e3:2400::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1727455912; cv=pass; b=DtxGpKVKpbHN6z0DALO35pSoduIijwIYE1zp1D5kL4mLhdD3bhlcqOpW8vjXa/ZPaO6SN1+Ef0Uu3/mSQcXBO12fUK9B9EpXQM/81mjZO0JHFEcbVDJm72kdD+SnJxYQzNDvuokV60RNG3OniUSCTCkMaplUIQRokt/CWx0ZlIYNYNWdGqFfRI0DGJT88m2doyMP45W7xY8RBKvy/33/mpsLdeUox2yWACaSq9sJ8EYBb1Bfab7Gdmq1A2Ge5PwLQl3xbnCWPacFruIL3qfDQM4vdUux/MW23j9+whW+l1EgNQlh0lr+pTV0+ZRToOsDiQCkapdKwyPWBxj7TKCzuQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1727455912; c=relaxed/relaxed; bh=rEYw1gYmwA8Qrj5YShUHffTTF3dzo6EdcZl8qQYjRd4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=oyv60Y1Gx4UOfmPLEgxXRQDFxNvwttozYyRusUhx7BVuFYlhC0Jm925Fc5gUl8HAAbQL9ha4iBudVgtLz7cOPIvyFUDkRqLz/o57bffZwxdcgjAUbH97R1InF3ae6q+f7YV9tbIu0haHvYE19IS98v+XwU7OIXwjbeJmlB+GMDh2AhRJjC0iVhJqJ/eDGgC7bI58f49XXtCZnYrUGVBjCOaXNmhP9gnPIDcxOoQuuk2aXxpqxq2ZyJzNZHEA+pVQs/yI7L2zZfpgh1zyxkKlDvXKkcR+9jDqYAYGt13G9SCUBUBBPTNolbFdipNI9Z8XMfrjNxHapS9xFzhwikh+dg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=uci.edu; dkim=pass (2048-bit key; unprotected) header.d=uci.edu header.i=@uci.edu header.a=rsa-sha256 header.s=google header.b=YKC+aHS8; dkim-atps=neutral; spf=pass (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4364-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=none dis=none) header.from=uci.edu Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=uci.edu header.i=@uci.edu header.a=rsa-sha256 header.s=google header.b=YKC+aHS8; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45e3:2400::1; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4364-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4XFc1z2Dk4z4x8b for ; Sat, 28 Sep 2024 02:51:51 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 30A9F284020 for ; Fri, 27 Sep 2024 16:51:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E84E01C173F; Fri, 27 Sep 2024 16:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=uci.edu header.i=@uci.edu header.b="YKC+aHS8" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B255139587 for ; Fri, 27 Sep 2024 16:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727455904; cv=none; b=kpX3+tMWeA540sU2y2eXhcz5X+9hBoIUx2CjRakFdo24uM6DVVfv509HP7totw+nRP+qymslg2Kju81G+Ld8F9niLPGUX4nctz0oDPM1Dxo6cLt35LL7cEhKXV3/yEr184y627Sw8v8wOtycIfteYkV1HNzoXgWFuLRqTyXoSzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727455904; c=relaxed/simple; bh=w1hDeaaqePkObd4w74ICxIIrNF2olAqnyLHEkqzZJjY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=lnnASOjlP3u67a715oJfV7E+TGNOMPqNdfgf4Wog1FgpnxqgvYuwGkdIByVDjqI+6aUdyaql1PW0Vxes/LVbZlGhOMLNUMEoM7aqgTj8W4cNo/8Yo+4khPGvfeLW0Y9T6Hx1PWEvrm0YK1kZa8zlGknWXSIjmFKaXLEYWbJlTnI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uci.edu; spf=pass smtp.mailfrom=uci.edu; dkim=pass (2048-bit key) header.d=uci.edu header.i=@uci.edu header.b=YKC+aHS8; arc=none smtp.client-ip=209.85.210.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uci.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uci.edu Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-718da0821cbso1883077b3a.0 for ; Fri, 27 Sep 2024 09:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uci.edu; s=google; t=1727455902; x=1728060702; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=rEYw1gYmwA8Qrj5YShUHffTTF3dzo6EdcZl8qQYjRd4=; b=YKC+aHS8iqgPtd9KfGe7jBZdhN9K01rPv4gFMwMYdX+dnFUWctPZOO4kXAmbSTei3T erqG3zFX3oiHlTZoW9Tmd/5lDV4khto3iKSVluo8xWhKOmVhR9liLtiG8X/D36vs+qlu SkvK0zJ++1w1cwNwqif2/Zo/fDHlNt3Td/qUe40Sy0dBN2nIPlcDx2zu6RyDDQWBVY+9 hiZOIh8EobziIoovz0x/WoOOjTh6r0GhmtvYKVuT8uPMcm56eosL6uOXvnlLbFnfzXhs YCQQlo75JXGI7YzsDUjO+tKCfDucBVwdWmQn0H/9FahSXixFKK60CfSLR/ZSkLies8Ad bnTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727455902; x=1728060702; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rEYw1gYmwA8Qrj5YShUHffTTF3dzo6EdcZl8qQYjRd4=; b=JOosz1Ef80mCVd/uYeLrxPalBdfGdJQC0wX/twISAzwm1aS9k1SLbr3hWJ+ZMPj/7W 7NLOTx/QRONcIk9S7U7cTj8kANPLHrzlGL2O7JCZbRWGrmOCFHj/uru2TWrAGyKlek4g jCV0gNYRzOgv0sAQGsVBA+0a7rnFswWxXNQI3RA2NdvggYRVjVtMqxPQj+3QP2mcmfWR g6eRDB1F7I3QtCZpnA6nfggpq4Fgwu2hRsu25aHsXSdO79/CWd/1Y/T6Ik5dNikmA5Ss SOlG7VYhOO0VZcCYalAb5KbWWZFHRTSZa3JUq0GitjntkkofJruaSkxw+rtSOY+07AjG OVGQ== X-Gm-Message-State: AOJu0YzCeIFFsAj4Mg1OIyTCAVxvr1n+G5/+W5d3cQiTKIcmiC/tYUDX MYj7UUTiSj/hcxfQ+S/hjOaTmyd3KeXf25J9Os/Gcp0WD48kcFRZmFvxI7Uad4c= X-Google-Smtp-Source: AGHT+IFhIGmE5LlhA55s0kcrgULqLsbgUkU+TsikBbl64f/xmQdYg/RN8UoCzM3MFKkvAI7Dpi4j8A== X-Received: by 2002:a05:6a00:3d14:b0:717:8ece:2f8b with SMTP id d2e1a72fcca58-71b26057f9emr6125090b3a.17.1727455902352; Fri, 27 Sep 2024 09:51:42 -0700 (PDT) Received: from alpha.mshome.net (ip68-4-168-191.oc.oc.cox.net. [68.4.168.191]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71b26515da6sm1800938b3a.122.2024.09.27.09.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2024 09:51:42 -0700 (PDT) From: Remington Brasga To: Theodore Ts'o , Andreas Dilger , Shuah Khan Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, syzbot+a3c8e9ac9f9d77240afd@syzkaller.appspotmail.com, Remington Brasga Subject: [PATCH] ext4: WARNING: locking bug in ext4_ioctl Date: Fri, 27 Sep 2024 16:51:32 +0000 Message-Id: <20240927165132.17289-1-rbrasga@uci.edu> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Fixed the locking bug with the bisection found by syzbot. Link to the syzbot bug report: https://syzkaller.appspot.com/bug?extid=a3c8e9ac9f9d77240afd Reported-by: syzbot+a3c8e9ac9f9d77240afd@syzkaller.appspotmail.com Signed-off-by: Remington Brasga --- First attempt at patching this issue. Verified the bug exists, and that this patch fixes it, and EXT4 KUnit tests pass. Though I am not sure if the patch should be higher up the stack. Open to questions or any suggestions for improvements. #syz test fs/ext4/xattr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index e0e1956dcdd3..2b30b9571fd8 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -124,8 +124,12 @@ void ext4_xattr_inode_set_class(struct inode *ea_inode) struct ext4_inode_info *ei = EXT4_I(ea_inode); lockdep_set_subclass(&ea_inode->i_rwsem, 1); - (void) ei; /* shut up clang warning if !CONFIG_LOCKDEP */ - lockdep_set_subclass(&ei->i_data_sem, I_DATA_SEM_EA); + + if (ei->i_flags & EXT4_EA_INODE_FL) { + lockdep_set_subclass(&ei->i_data_sem, I_DATA_SEM_EA); + } else { + lockdep_set_subclass(&ei->i_data_sem, I_DATA_SEM_NORMAL); + } } #endif