netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Casey Schaufler <casey@schaufler-ca.com>
Cc: Florian Westphal <fw@strlen.de>,
	Chenyuan Yang <chenyuan0y@gmail.com>,
	netfilter-devel@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: Initialize ctx to avoid memory allocation error
Date: Fri, 14 Mar 2025 17:47:08 +0100	[thread overview]
Message-ID: <20250314164708.GA1542@breakpoint.cc> (raw)
In-Reply-To: <42e5bb33-1826-43df-940d-ec80774fc65b@schaufler-ca.com>

Casey Schaufler <casey@schaufler-ca.com> wrote:
> If seclen is 0 it implies that there is no security context and that
> the secctx is NULL. How that is handled in the release function is up
> to the LSM. SELinux allocates secctx data, while Smack points to an
> entry in a persistent table.
> 
> > seclen needs to be > 0 or no secinfo is passed to userland,
> > yet the secctx release function is called anyway.
> 
> That is correct. The security module is responsible for handling
> the release of secctx correctly.
> 
> > Should seclen be initialised to -1?  Or we need the change below too?
> 
> No. The security modules handle secctx their own way.

Well, as-is security_release_secctx() can be called with garbage ctx;
seclen is inited to 0, but ctx is not initialized unconditionally.

  reply	other threads:[~2025-03-14 16:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13 19:54 [PATCH] net: Initialize ctx to avoid memory allocation error Chenyuan Yang
2025-03-13 20:10 ` Florian Westphal
2025-03-14 16:41   ` Casey Schaufler
2025-03-14 16:47     ` Florian Westphal [this message]
2025-03-14 17:26       ` Casey Schaufler
2025-03-14 20:30         ` Florian Westphal
2025-03-15 18:34           ` Casey Schaufler

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=20250314164708.GA1542@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=casey@schaufler-ca.com \
    --cc=chenyuan0y@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).