mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Roberto Sassu <roberto.sassu@huaweicloud.com>
Cc: linux-kernel@vger.kernel.org,
	"Roberto Sassu" <roberto.sassu@huawei.com>,
	stable@vger.kernel.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Mike Kravetz" <mike.kravetz@oracle.com>
Subject: Re: [PATCH] memfd: Check for non-NULL file_seals in memfd_create() syscall
Date: Wed, 7 Jun 2023 10:21:31 -0700	[thread overview]
Message-ID: <20230607102131.11964c87b1078374c9d4b341@linux-foundation.org> (raw)
In-Reply-To: <20230607132427.2867435-1-roberto.sassu@huaweicloud.com>

On Wed,  7 Jun 2023 15:24:27 +0200 Roberto Sassu <roberto.sassu@huaweicloud.com> wrote:

> From: Roberto Sassu <roberto.sassu@huawei.com>
> 
> Ensure that file_seals is non-NULL before using it in the memfd_create()
> syscall. One situation in which memfd_file_seals_ptr() could return a NULL
> pointer is when CONFIG_SHMEM=n.

Thanks.  Has thie crash actually been demonstrated?

> --- a/mm/memfd.c
> +++ b/mm/memfd.c
> @@ -371,12 +371,15 @@ SYSCALL_DEFINE2(memfd_create,
>  
>  		inode->i_mode &= ~0111;
>  		file_seals = memfd_file_seals_ptr(file);
> -		*file_seals &= ~F_SEAL_SEAL;
> -		*file_seals |= F_SEAL_EXEC;
> +		if (file_seals) {
> +			*file_seals &= ~F_SEAL_SEAL;
> +			*file_seals |= F_SEAL_EXEC;
> +		}
>  	} else if (flags & MFD_ALLOW_SEALING) {
>  		/* MFD_EXEC and MFD_ALLOW_SEALING are set */
>  		file_seals = memfd_file_seals_ptr(file);
> -		*file_seals &= ~F_SEAL_SEAL;
> +		if (file_seals)
> +			*file_seals &= ~F_SEAL_SEAL;
>  	}
>  
>  	fd_install(fd, file);


  reply	other threads:[~2023-06-07 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-07 13:24 Roberto Sassu
2023-06-07 17:21 ` Andrew Morton [this message]
2023-06-08 21:05   ` Roberto Sassu
2023-06-08 21:29     ` Roberto Sassu

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=20230607102131.11964c87b1078374c9d4b341@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=mike.kravetz@oracle.com \
    --cc=roberto.sassu@huawei.com \
    --cc=roberto.sassu@huaweicloud.com \
    --cc=stable@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

all inboxes | Powered by JetHome®