Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1810418rbb; Tue, 27 Feb 2024 01:40:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFvpGTSnkAtbmFClZyrsEqvOGWnDBzPqQ/jKyrZ+l0XgyXwM1F0Hlhdb8oNTVpHaaMKwA3neDAaeZQG19wfy1jzpoQST/eNiXGMGKBSQ== X-Google-Smtp-Source: AGHT+IHMnOa5e0obW97yZBInSk3J/EXNgWdN5UcBxcgL5Q6HTsL0JQ7+N56DDk0hx9salGi4+RUX X-Received: by 2002:a17:90a:bd0a:b0:299:dd2:47f with SMTP id y10-20020a17090abd0a00b002990dd2047fmr6588907pjr.10.1709026826237; Tue, 27 Feb 2024 01:40:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709026826; cv=pass; d=google.com; s=arc-20160816; b=XIIRo0H/7pwLkwbgjaa5/V6ImKoh5Q4VnBm23x1vhsT+JqBYmRuq2999/sAvwfd6SL B92uGwsjqq0PrjdquJiBC5G4M2Dslah/nTCeRq1IrNTu1VO9ZEb30hZ1RnD/nyChfena kw5XYcruj08r2ng+5znmVCx6pvk1pE6Cfwcja0qtnKBNOKf3itFO03xR7C2mxowAVLFw tlftpRP5enlp1cPYacQsRnH4eZPclYZXGnrEG+v7wUIrw2s9ZizSd0KWmW3PC5e/Xsy0 /dy6uaqLzY/2VDKXvnTJk+ZwAgk3GLcd0EpRcNtmG0anbip993LYnZPCxxwW1BT8Tscg Y3jg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=diggtj8WfVHmGY/2jyxXjIr6GbLKJAvO81RCvtP7dCs=; fh=6zpa7JLXeSaXj5l9UGJUD00IHdBoKjYoj2y3YzihplU=; b=cbr83e4AF+ZiYk4IdtQsKcZYSx9bZsXyuHamyzTU81aIbtyfQDGhPxOFT3HV6NVrPy TyhrGM0Hv3rd6HwZ2CUTN7WQ4y61/SqDb+qzIUAWW7M1g5xbYUuZWVsPALHp1f0M0ix1 FkvUwXvzGqvKDPyRtwxsTrogFrUgmfvBZJDVULa/8IJwqdTS9/sAEBHbjXJ0fJKc7lSt bkLSZngnFZAvs4cz9aLiFEo3LsjhdNVQgAyoXg/qNc/SZ+jaddznXIRZCdB6aGgmTolG +e08rhDqs0vIFkuFzwDbWanCYHLs0HN9WzgJ4aHE2SayLY+/apl119HGRR+PYoRllZ14 Fafg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MJF2+Dbp; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-ext4+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id g7-20020a17090a578700b00299592a7d25si6972615pji.104.2024.02.27.01.40.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 01:40:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MJF2+Dbp; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-ext4+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1404-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id DAF0FB21F77 for ; Tue, 27 Feb 2024 09:17:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6769C135A6A; Tue, 27 Feb 2024 09:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MJF2+Dbp" X-Original-To: linux-ext4@vger.kernel.org Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 2839F537F3 for ; Tue, 27 Feb 2024 09:17:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025438; cv=none; b=kHsmelwG9r/bbAfpHHLANqoE8bz/6EZ4GARbJo/mlmXxFNKEIDEL3OBuRCH5HH9KNhVsmeVcIKIGrZUeYFv86sxP3f6F/oSFd91EwOVoevLZWKx7AueEWqixiD4VAneR2BaHt9m0AP4XmJkwLqZpbW+0dyk9FZVgSPraV0eB5ZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025438; c=relaxed/simple; bh=nj2yHnFQ+uo/AvszXEg+SH6tfnqtd/ozyP2hEU54SL8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=IBB4OpLZxDqmbaJE31pgkJBDg+JWp+IY8s/jngz+cuPkfJpyZ6EXBFhx5DVII+b91HvuGVYN8nO25v3xpBcV7bDsH96NOnIxHsog9n4NoMrtcKs8lxR8qzWSWR4v3uL72N93q0vvZTH02zUC06E/NPy7OEqZgTaxRhiGWXLUUw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=MJF2+Dbp; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-412a3903586so15377185e9.3 for ; Tue, 27 Feb 2024 01:17:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709025435; x=1709630235; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=diggtj8WfVHmGY/2jyxXjIr6GbLKJAvO81RCvtP7dCs=; b=MJF2+Dbpc6EDbN/n8S3r/hhKk2v4SsATFi0HjO75IROv7Sbx+g/FiMdCqkJ9/aWTkI U3mDqeybKeqz3qWMJ8HegbwY0Pyozhe9WgO67SgsLmvQbcBqyY4RfyJN7YyVm1Ifbi6d yzj8ILNlZeFiROn5SaSWN6vwX6mSxu4r9wGkIPBAxl3HQ0xLtX8DEFKCwaXoieCXWqCu JVXsTTuZFJqzwL/hgdr5vLcs/AWYaCBiPz8GWRpQeGvjPZxB5IukPPcYpnRJMyD7cQsg 9T0yTbtypq0xAuWTjVhdAy5cdidfy3pUD/h0QBqbx4/htdZ6ZZW9bx+xE/4xTkDQhODK RiDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709025435; x=1709630235; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=diggtj8WfVHmGY/2jyxXjIr6GbLKJAvO81RCvtP7dCs=; b=L4HJFKL+st9CVQVUlHLMpeAGMtP/b+gt88mMvUKAlMsVWnEqqHDjaXlCtFVOs+9/Eh fdU7vJhmTGeKFAOD10es7KjUaUvoAuG+zdqYirNYq5JfYqnJ3EUlPoeYbGdEwsJzg+T8 Uxa5hwv/cczsfClhWzlgPK2Grwn3DJsAJECpS3QgWwYYQQJ6Quwg9mIFqhED9lkPVQtO JXCOJxf0TMoRdMB/tAiYI8KfoBwuY/BlstQJsqcovTZEeOSl/xn3uWZ4Q4tMILsLH3mn cX5AHVuA0DdOal1tvy/w0/zuUgXUA88kcZb81IaLFM4Fpf7wxuYDymEZ+aIRg7/E7Lt6 Uchw== X-Gm-Message-State: AOJu0YwgUeG+kyeLs3z9FqFj2yWbXopOKmACCh1juXUNSUdAeoAT8jDT Dxw9M/gmNJ61+MqF2Ukbi2HN4JvCrGWZYSac7b3xyvEfUe/xQ9TcqKUQcj1wLTs= X-Received: by 2002:adf:ecc5:0:b0:33d:282c:af48 with SMTP id s5-20020adfecc5000000b0033d282caf48mr6055317wro.69.1709025435509; Tue, 27 Feb 2024 01:17:15 -0800 (PST) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id ay25-20020a5d6f19000000b0033da430f286sm11011148wrb.69.2024.02.27.01.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 01:17:15 -0800 (PST) Date: Tue, 27 Feb 2024 12:17:11 +0300 From: Dan Carpenter To: jack@suse.cz Cc: linux-ext4@vger.kernel.org Subject: [bug report] ext4: do not create EA inode under buffer lock Message-ID: <6e5f8a70-1cba-41fa-98f3-2ef3bcc29017@moroto.mountain> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello Jan Kara, The patch ea554578483b: "ext4: do not create EA inode under buffer lock" from Feb 9, 2024 (linux-next), leads to the following Smatch static checker warning: fs/ext4/xattr.c:2265 ext4_xattr_ibody_set() warn: duplicate check 'error' (previous on line 2255) fs/ext4/xattr.c 2232 int ext4_xattr_ibody_set(handle_t *handle, struct inode *inode, 2233 struct ext4_xattr_info *i, 2234 struct ext4_xattr_ibody_find *is) 2235 { 2236 struct ext4_xattr_ibody_header *header; 2237 struct ext4_xattr_search *s = &is->s; 2238 struct inode *ea_inode = NULL; 2239 int error; 2240 2241 if (!EXT4_INODE_HAS_XATTR_SPACE(inode)) 2242 return -ENOSPC; 2243 2244 /* If we need EA inode, prepare it before locking the buffer */ 2245 if (i->value && i->in_inode) { 2246 WARN_ON_ONCE(!i->value_len); 2247 2248 ea_inode = ext4_xattr_inode_lookup_create(handle, inode, 2249 i->value, i->value_len); 2250 if (IS_ERR(ea_inode)) 2251 return PTR_ERR(ea_inode); 2252 } 2253 error = ext4_xattr_set_entry(i, s, handle, inode, ea_inode, 2254 false /* is_block */); 2255 if (error) { ^^^^^ 2256 if (ea_inode) { 2257 int error2; 2258 2259 error2 = ext4_xattr_inode_dec_ref(handle, ea_inode); 2260 if (error2) 2261 ext4_warning_inode(ea_inode, "dec ref error=%d", 2262 error2); 2263 2264 /* If there was an error, revert the quota charge. */ --> 2265 if (error) ^^^^^ We know "error" is non-zero. I'm not sure whether to delete this check or change "error" to "error2". 2266 ext4_xattr_inode_free_quota(inode, ea_inode, 2267 i_size_read(ea_inode)); 2268 iput(ea_inode); 2269 } 2270 return error; 2271 } 2272 header = IHDR(inode, ext4_raw_inode(&is->iloc)); 2273 if (!IS_LAST_ENTRY(s->first)) { 2274 header->h_magic = cpu_to_le32(EXT4_XATTR_MAGIC); 2275 ext4_set_inode_state(inode, EXT4_STATE_XATTR); 2276 } else { 2277 header->h_magic = cpu_to_le32(0); 2278 ext4_clear_inode_state(inode, EXT4_STATE_XATTR); 2279 } 2280 iput(ea_inode); 2281 return 0; 2282 } regards, dan carpenter