From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796308270; b=gWcOnSdjPBa3p1X5upAGS95+6ftOK6PP2tjGH6eIjhQUTzhtb9JZ1Itxtq7Tunuqmq08 nIgcrk2sP5ConVwbtFlEDogLQwNNbBIemCpWAdjYBYMOgNYmV3hlyRWLFF8vv9PLweGEw QQGKKzBpdsPm0Y5js1gfh5BgnVyWyNCh0TpMhZbsugvrJkbxLfgSQyXQPdFVp3aRNZVPo mfvFCR39ugpVcwsNde1ysUoVEPIiihWdUAUBWB8fyO0QFlWVtHymgq9yl/XsUf0CxBh+s XUkif4mekA9QtyQAKUG7Q9kXDdRyC9ipDOnPoFYU/kmBuedQ3vQc6jattSvCFcduqFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796308270; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Date:From:To:Cc: Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:Content-Transfer-Encoding:In-Reply-To; bh=2UeQIFHcdjxMXoXNMc2HcOZFnlgzGrRhPIIvzZAGZWQ=; b=rvCUiWW4OIFJgM064PySq4kJH24vA9MRLdpwMU6VKn19MPTrq+ZO+s0XCCLkUTdZuJv+ FEmRwjfMZ/9CUIlMPPzVLJzFbztjiWwoJbxowIxxR+IR27RRuOf4/ZjIfWOMv2e9eRhLB G/Yc3+fXluljccFhFWUBlkJMD9Hsi1QoFoGzPTf45vAtZ306qA2FBVbRVgI2aXVWwOl4J LCMy1V64/f441nlG66tOt51Ricb/f4NcJu6aJCo5tljcjk06EDFbwVvncjCZZo3ZR8F96 XXjKICJwKBw2d7uXC3uzCbTPu/vPXesA6og+ELRRoiEOe6RpV3spV57eOfOgZ6JXlpw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=PKAH291h; arc=none smtp.remote-ip=209.85.128.53 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1572606A32C for ; Thu, 3 Dec 2026 14:31:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D1572606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=PKAH291h Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4bb70074ab2so150321815e9.0 for ; Thu, 03 Dec 2026 06:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796308268; x=1796913068; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=2UeQIFHcdjxMXoXNMc2HcOZFnlgzGrRhPIIvzZAGZWQ=; b=PKAH291hRq6tfxlFqvVcAdXT1aBmAVl9YX16rkQoxhB02s4CHvhIlwk1L4nPpuLNVE hQx6FzZ1ziMlTHMXGJbleDfd7bjM7Nl/cKD+mDKUu3r+G4217PqAxLs/N86K5x23xx1m T6tM024rOVY86c/UYOrXwoDSb3zNEweJ9M5S+0tyi6rrRJiQ1ZAoTPUnVVUCtO2Tuf3t dsB6cRt3xaoiNWvpRbM0GQRdwXs2iz6UBjoJraMGk0hR1uHQY6FcSzfYlCqhXQZsmpwl s3/3w1KF8YRHUJwx9TX0+CMHPwKc3duCAoaumYNEXNz8JISutgbom3klBdQyCdWaykly xz9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796308268; x=1796913068; h=in-reply-to:content-transfer-encoding:content-disposition :content-type: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:content-type; bh=2UeQIFHcdjxMXoXNMc2HcOZFnlgzGrRhPIIvzZAGZWQ=; b=I54wKHoVK6Vv1C7o9GBezRhdqPL6anErNs7gVeHih1rkyTy5hFkJokpq8qX08SYgC1 rOEuf/ajTITCNlsLADatFtmS/5XtYNNaCuNe4uQya/MyfRqPj2cVvMWq7bdql5qiUMo/ b4vJsh+iIzfDBAkkQF09wEDaPwD8kbD4C1IlyrKOipVdM20g8mFYrjyc7TZcVDymMXAk zFeTwglGsIVRD8eqneBq0lWeCNyB6Wp/iLQm4safMDRs8CEyqQ+37DVUbTVFPw4Q9gs0 LhbZOu994jCI9bUMEDu0flA6TT/nj0TStr13zJM04kxW4KpwmDG409Lsb9qAOjhFFOWb hOtQ== X-Gm-Message-State: APuU4Z/GtQ4hmHy8VEVlks/EubNIZfmwy1cnEyz73OhAZwovHNIMidbE YdnMyZ7qO73p5YB81SbICb6r8C8M+55dETE5wAmrOkWT1iNTtWAv/ZA57WD2jEm6 X-Gm-Gg: AZFdTZdAP89L+xPQFIPvnwUONQKW/1BFHsejZBHakUhLLmx7u/x2ye/2UwyoGj3nl1v mEJqqCF6smI7a8HYZl2kCuh+xtztffXMEE3P+6dsu9sFezK1FtvcCYkIHwvYMkowsqgoiwKJFkL AGIoiUBQFs8NPRq9UmkhO2Ylz8BxKLBst/fXdridDCI7qgOOOncsUBpgk/0vB3AcPO4R/gcC0qI YQ+Spx2tyW/RivxeZQpCJ3zb7og2UB+WHlRt79AgxR0D7+6tw9/p2G6NT4ukow+vw2NTdE5ibvY IVQjQV9N066+p/6+y2O+10/R25BrPljNCvcIhF4KCIkjASlBo/BlwBsjArAZDihrg4gGGXDyOsd kvd1KKVjGV+ho1hofHBzsTbxip6SS1txC5nGhWTaLWfk04VUKPwQlnAV88W9cTeoVzae+ui9HTl 8DS5rWDa3d0WEc5vz/0RRqAlem+F8nlPXO7Zi2AvvsdAlRHYRfQQiTeoEJs2HLX5SHlnGdAfc8q BOFZj4NmEedNGAUXFl+uAhROClyMJ/EbNTVJ5KXYHj8N8a35/1dtwQe5G7PfPZMP7f6p/8zHZQl MJeloaAvUtynS6yOG1f794X8EBAWvaS//lM9 X-Received: by 2002:a05:600c:6290:b0:4a3:59c9:a743 with SMTP id 5b1f17b1804b1-4bb8882a21amr803316745e9.27.1796308268040; Thu, 03 Dec 2026 06:31:08 -0800 (PST) Received: from mail.gmail.com ([2a04:ee41:4:b2de:1ac0:4dff:fe0f:3782]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbe005543esm87646885e9.5.2026.12.03.06.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 06:31:07 -0800 (PST) Date: Thu, 3 Dec 2026 14:42:49 +0000 From: Anton Protopopov To: sashiko-reviews@lists.linux.dev Cc: bpf@vger.kernel.org Subject: Re: [PATCH v1 bpf-next 2/3] bpf: Add a bpf_get_inode_xattr kfunc Message-ID: References: <20261203134411.1092433-1-a.s.protopopov@gmail.com> <20261203134411.1092433-3-a.s.protopopov@gmail.com> X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On 26/12/03 02:01PM, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 1 potential > issue to consider: > - [Medium] bpf: bpf_get_inode_xattr() ignores hashed aliases via > d_find_any_alias() > -- > > commit 411b1cdf4c29cccf8363d8423d9bb02ec61b59b9 > Author: Anton Protopopov > > bpf: Add a bpf_get_inode_xattr kfunc > > This commit adds the sleepable bpf_get_inode_xattr() kfunc to read an > extended attribute from an inode by looking up one of its dentries with > d_find_any_alias(). > > > diff --git a/fs/bpf_fs_kfuncs.c b/fs/bpf_fs_kfuncs.c > > index 1b973bd4e5355..654340a0bc70e 100644 > > --- a/fs/bpf_fs_kfuncs.c > > +++ b/fs/bpf_fs_kfuncs.c > > @@ -169,6 +169,35 @@ __bpf_kfunc int bpf_get_file_xattr(struct file *file, const char *name__str, > [ ... ] > > +__bpf_kfunc int bpf_get_inode_xattr(struct inode *inode, const char *name__str, > > + struct bpf_dynptr *value_p) > > +{ > > + struct dentry *dentry; > > + int ret; > > + > > + dentry = d_find_any_alias(inode); Yes, thanks, will change this to + dentry = d_find_alias(inode); + if (!dentry) + dentry = d_find_any_alias(inode); > > + if (!dentry) > > + return -ENOENT; > > + ret = bpf_get_dentry_xattr(dentry, name__str, value_p); > > + dput(dentry); > > + return ret; > > +} > > [Severity: Medium] > Should this try d_find_alias() before falling back to d_find_any_alias()? > > d_find_any_alias() returns the first alias on inode->i_dentry without > skipping unhashed or disconnected dentries. Path-based filesystems rely on > the dentry in their xattr callbacks; for example, cifs_xattr_get() builds > the server path from it via build_path_from_dentry(). > > When an inode has an open unlinked hard link ahead of a live hard link on > inode->i_dentry, bpf_get_inode_xattr() passes the unhashed alias to > __vfs_getxattr() and spuriously fails even though a hashed alias exists. > > Trying d_find_alias(inode) first and falling back to d_find_any_alias(inode) > on NULL, as inode_doinit_with_dentry() in security/selinux/hooks.c does, > avoids this while still handling unlinked open files. > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261203134411.1092433-1-a.s.protopopov@gmail.com?part=2