mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Sun Jian <sun.jian.kdev@gmail.com>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] wifi: nl80211: drop impossible negative band check
Date: Wed, 04 Feb 2026 09:36:29 +0100	[thread overview]
Message-ID: <bc92582d5de175ec325ae53ed3fe18a5e073438b.camel@sipsolutions.net> (raw)
In-Reply-To: <20260204081821.730673-1-sun.jian.kdev@gmail.com> (sfid-20260204_091842_124304_F2AC914A)

On Wed, 2026-02-04 at 16:18 +0800, Sun Jian wrote:
> band is derived from nla_type() of a nested netlink attribute, which is
> a masked u16 value and therefore cannot be negative. Drop the dead
> "band < 0" checks and keep the upper bound validation.

I've seen this before, but I'm not really convinced it is entirely
correct. C says:

   All enumerations have an underlying type. The underlying type can be
   explicitly specified using an enum type specifier and is its fixed
   underlying type. If it is not explicitly specified, the underlying
   type is the enumeration’s compatible type, which is either char or a
   standard or extended signed or unsigned integer type.

It would thus _seem_ to be possible for an enum to generally be a signed
type, and therefore a 'signed short', and therefore an nla_type() that's
a u16 could end up with a negative value...

Am I wrong?

johannes

  reply	other threads:[~2026-02-04  8:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-04  8:18 Sun Jian
2026-02-04  8:36 ` Johannes Berg [this message]
2026-02-04  9:13   ` sun jian
2026-02-04 11:11     ` Johannes Berg
2026-02-04 11:21       ` sun jian
2026-02-04 11:29         ` Johannes Berg
2026-02-04 11:33           ` sun jian
2026-02-04 16:20             ` Jeff Johnson
2026-02-06  2:16               ` sun jian

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=bc92582d5de175ec325ae53ed3fe18a5e073438b.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=sun.jian.kdev@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®