From: Simon Horman <horms@kernel.org>
To: Purva Yeshi <purvayeshi550@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
skhan@linuxfoundation.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Kuniyuki Iwashima <kuniyu@amazon.com>,
Dan Carpenter <dan.carpenter@linaro.org>
Subject: Re: [PATCH net-next v2] af_unix: Fix undefined 'other' error
Date: Sat, 15 Feb 2025 17:24:40 +0000 [thread overview]
Message-ID: <20250215172440.GS1615191@kernel.org> (raw)
In-Reply-To: <20250210075006.9126-1-purvayeshi550@gmail.com>
+ Iwashima-san, Dan
On Mon, Feb 10, 2025 at 01:20:06PM +0530, Purva Yeshi wrote:
> Fix issue detected by smatch tool:
> An "undefined 'other'" error occur in __releases() annotation.
>
> Fix an undefined 'other' error in unix_wait_for_peer() caused by
> __releases(&unix_sk(other)->lock) being placed before 'other' is in
> scope. Since AF_UNIX does not use Sparse annotations, remove it to fix
> the issue.
>
> Eliminate the error without affecting functionality.
>
> Signed-off-by: Purva Yeshi <purvayeshi550@gmail.com>
> ---
> V1 - https://lore.kernel.org/lkml/20250209184355.16257-1-purvayeshi550@gmail.com/
> V2 - Remove __releases() annotation as AF_UNIX does not use Sparse annotations.
Hi Iwashima-san, all,
in v1 of this change you commented that:
Tweaking an annotation with a comment for a static analyzer to fix
a warning for yet another static analyzer is too much.
Please remove sparse annotation instead.
Here's the only place where sparse is used in AF_UNIX code, and we
don't use sparse even for /proc/net/unix.
And I do understand entirely that we don't want to overly tweak
things to keep static analysis tools happy. But I don't think the
patch description describes the situation completely. So I'd like
to provide a bit more information.
My understanding is that the two static analysis tools under discussion
are Smatch and Sparse, where AFAIK Smatch is a fork of Sparse.
Without this patch, when checking af_unix.c, both Smatch and Sparse report
(only):
.../af_unix.c:1511:9: error: undefined identifier 'other'
.../af_unix.c:1511:9: error: undefined identifier 'other'
.../af_unix.c:1511:9: error: undefined identifier 'other'
.../af_unix.c:1511:9: error: undefined identifier 'other'
And with either v1 or v2 of this patch applied Smatch reports nothing.
While Sparse reports:
.../af_unix.c:234:13: warning: context imbalance in 'unix_table_double_lock' - wrong count at exit
.../af_unix.c:253:28: warning: context imbalance in 'unix_table_double_unlock' - unexpected unlock
.../af_unix.c:1386:13: warning: context imbalance in 'unix_state_double_lock' - wrong count at exit
.../af_unix.c:1403:17: warning: context imbalance in 'unix_state_double_unlock' - unexpected unlock
.../af_unix.c:2089:25: warning: context imbalance in 'unix_dgram_sendmsg' - unexpected unlock
.../af_unix.c:3335:20: warning: context imbalance in 'unix_get_first' - wrong count at exit
.../af_unix.c:3366:34: warning: context imbalance in 'unix_get_next' - unexpected unlock
.../af_unix.c:3396:42: warning: context imbalance in 'unix_seq_stop' - unexpected unlock
.../af_unix.c:3499:34: warning: context imbalance in 'bpf_iter_unix_hold_batch' - unexpected unlock
TBH, I'm unsure which is worse. Nor how to improve things.
next prev parent reply other threads:[~2025-02-15 17:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 7:50 [PATCH net-next v2] af_unix: Fix undefined 'other' error Purva Yeshi
2025-02-10 17:50 ` Joe Damato
2025-02-11 0:32 ` Kuniyuki Iwashima
2025-02-12 14:24 ` Purva Yeshi
2025-02-12 18:48 ` Jakub Kicinski
2025-02-13 7:44 ` Purva Yeshi
2025-02-15 17:24 ` Simon Horman [this message]
2025-02-16 19:33 ` Dan Carpenter
2025-02-17 11:15 ` Simon Horman
2025-02-17 14:14 ` Dan Carpenter
2025-02-18 13:21 ` Simon Horman
2025-02-18 13:37 ` Purva Yeshi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250215172440.GS1615191@kernel.org \
--to=horms@kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=purvayeshi550@gmail.com \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.