SELinux Security Module development
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: "Johannes Segitz" <jsegitz@suse.de>,
	"Christian Göttsche" <cgzones@googlemail.com>,
	"SElinux list" <selinux@vger.kernel.org>
Subject: Re: [PATCH] libselinux: Cached security context not accurate
Date: Tue, 25 Jan 2022 16:06:43 +0100	[thread overview]
Message-ID: <877danua64.fsf@redhat.com> (raw)
In-Reply-To: <20220124085113.GC5813@suse.com>

Johannes Segitz <jsegitz@suse.de> writes:

> On Fri, Jan 21, 2022 at 01:06:16PM +0100, Christian Göttsche wrote:
>> Wouldn't it make logically more sense to first check if pid is zero
>> and then check if the cache is set, cause we never want to access the
>> cache if not operating on out own process?
>
> Yes, I changed that
>
>> Also isn't setprocattrcon_raw() affected too?
>
> Of course. I managed to attach the wrong file that only had the change for
> getprocattrcon_raw. Attached is the full patch

Hello,

thanks for the patch. I have only comments on the format.

The best way how to send a patch to the mailing list is to use `git send-email`, e.g.

   $ git send-email --from='Johannes Segitz <jsegitz@suse.de>' --to=selinux@vger.kernel.org --smtp-server=your.smtp.server --confirm=auto -1

Also as stated in CONTRIBUTING.md, the patch description must have signed-off.
See
https://github.com/SELinuxProject/selinux/pull/336/checks?check_run_id=4559976491
for the guidance.


Petr

> Johannes
> -- 
> GPG Key                EE16 6BCE AD56 E034 BFB3  3ADD 7BF7 29D5 E7C8 1FA0
> Subkey fingerprint:    250F 43F5 F7CE 6F1E 9C59  4F95 BC27 DD9D 2CC4 FD66
> SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nuernberg
> Geschäftsführer: Ivo Totev (HRB 36809, AG Nürnberg)
> Index: libselinux-3.3/src/procattr.c
> ===================================================================
> --- libselinux-3.3.orig/src/procattr.c
> +++ libselinux-3.3/src/procattr.c
> @@ -148,7 +148,7 @@ static int getprocattrcon_raw(char ** co
>  			return -1;
>  	}
>  
> -	if (prev_context && prev_context != UNSET) {
> +	if (pid == 0 && prev_context && prev_context != UNSET) {
>  		*context = strdup(prev_context);
>  		if (!(*context)) {
>  			return -1;
> @@ -242,9 +242,9 @@ static int setprocattrcon_raw(const char
>  			return -1;
>  	}
>  
> -	if (!context && !*prev_context)
> +	if (pid == 0 && !context && !*prev_context)
>  		return 0;
> -	if (context && *prev_context && *prev_context != UNSET
> +	if (pid == 0 && context && *prev_context && *prev_context != UNSET
>  	    && !strcmp(context, *prev_context))
>  		return 0;
>  
> @@ -272,9 +272,11 @@ out:
>  		free(context2);
>  		return -1;
>  	} else {
> -		if (*prev_context != UNSET)
> -			free(*prev_context);
> -		*prev_context = context2;
> +		if (pid == 0) {
> +			if (*prev_context != UNSET)
> +				free(*prev_context);
> +			*prev_context = context2;
> +		}
>  		return 0;
>  	}
>  }


      reply	other threads:[~2022-01-25 15:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-21  8:40 [PATCH] libselinux: Cached security context not accurate Johannes Segitz
2022-01-21 12:06 ` Christian Göttsche
2022-01-24  8:51   ` Johannes Segitz
2022-01-25 15:06     ` Petr Lautrbach [this message]

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=877danua64.fsf@redhat.com \
    --to=plautrba@redhat.com \
    --cc=cgzones@googlemail.com \
    --cc=jsegitz@suse.de \
    --cc=selinux@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