linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Mike Frysinger <vapier@gentoo.org>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/2 v2] binfmt_misc: add comments & debug logs
Date: Mon, 20 Oct 2014 15:59:56 -0700	[thread overview]
Message-ID: <1413845996.5407.2.camel@perches.com> (raw)
In-Reply-To: <1413845160-22497-1-git-send-email-vapier@gentoo.org>

On Mon, 2014-10-20 at 18:45 -0400, Mike Frysinger wrote:

> let's deploy extensive pr_debug markers at
> logical parse points, and add comments to the dense parsing logic.  It
> let's you see exactly where the parsing aborts, the string the kernel
> received (useful when dealing with shell code), how it translated the
> buffers to binary data, and how it will apply the mask at runtime.

Mostly trivia:

> diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
[]
> @@ -323,46 +343,113 @@ static Node *create_entry(const char __user *buffer, size_t count)
[]
> +			if (e->mask) {
> +				int i;
> +				char *masked = kmalloc(e->size, GFP_USER);

Why GFP_USER?  Does it need it?

> +				print_hex_dump_bytes(
> +					KBUILD_MODNAME ": register:  mask[decoded]: ",
> +					DUMP_PREFIX_NONE, e->mask, e->size);
> +
> +				if (masked) {
> +					for (i = 0; i < e->size; ++i)
> +						masked[i] = e->magic[i] & e->mask[i];
> +					print_hex_dump_bytes(
> +						KBUILD_MODNAME ": register:  magic[masked]: ",
> +						DUMP_PREFIX_NONE, masked, e->size);
> +
> +					kfree(masked);

[]

> @@ -553,11 +645,17 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
>  	int res = parse_command(buffer, count);
>  
>  	switch (res) {
> -		case 1: clear_bit(Enabled, &e->flags);
> +		case 1:
> +			/* Disable this handler. */
> +			clear_bit(Enabled, &e->flags);
>  			break;
> -		case 2: set_bit(Enabled, &e->flags);
> +		case 2:
> +			/* Enable this handler. */
> +			set_bit(Enabled, &e->flags);
>  			break;
> -		case 3: root = dget(file->f_path.dentry->d_sb->s_root);
> +		case 3:
> +			/* Delete this handler. */
> +			root = dget(file->f_path.dentry->d_sb->s_root);
>  			mutex_lock(&root->d_inode->i_mutex);
>  
>  			kill_node(e);

Maybe move the case indents one tab position left

	switch (res) {
	case 1:			/* Disable handler */
		clear_bit(Enabled, ...);
		break;
	case 2:			/* Enable handler */
		set_bit(...);
		break;
	case 3:			/* Delete handler */
		etc...
	}

> @@ -661,9 +759,17 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
>  	struct dentry *root;
>  
>  	switch (res) {
> -		case 1: enabled = 0; break;
> -		case 2: enabled = 1; break;
> -		case 3: root = dget(file->f_path.dentry->d_sb->s_root);
> +		case 1:
> +			/* Disable all handlers. */
> +			enabled = 0;
> +			break;
> +		case 2:
> +			/* Enable all handlers. */
> +			enabled = 1;
> +			break;
> +		case 3:
> +			/* Delete all handlers. */
> +			root = dget(file->f_path.dentry->d_sb->s_root);
>  			mutex_lock(&root->d_inode->i_mutex);
>  
>  			while (!list_empty(&entries))

here too.



  parent reply	other threads:[~2014-10-20 23:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-19 23:03 [PATCH 1/2] binfmt_misc: add comments & debug logs Mike Frysinger
2014-10-19 23:03 ` [PATCH 2/2] binfmt_misc: clean up code style a bit Mike Frysinger
2014-10-20  0:41 ` [PATCH 1/2] binfmt_misc: add comments & debug logs Joe Perches
2014-10-20 22:37   ` Mike Frysinger
2014-10-20 22:45 ` [PATCH 1/2 v2] " Mike Frysinger
2014-10-20 22:46   ` [PATCH 2/2 v2] binfmt_misc: clean up code style a bit Mike Frysinger
2014-10-20 22:59   ` Joe Perches [this message]
2014-10-20 23:54     ` [PATCH 1/2 v2] binfmt_misc: add comments & debug logs Mike Frysinger
2014-10-28 22:58       ` Andrew Morton
2014-10-28 23:25         ` Mike Frysinger

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=1413845996.5407.2.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vapier@gentoo.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).