lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 2 Nov 2015 23:40:52 +0900
From:	Namhyung Kim <namhyung@...nel.org>
To:	Tom Zanussi <tom.zanussi@...ux.intel.com>
Cc:	rostedt@...dmis.org, daniel.wagner@...-carit.de,
	masami.hiramatsu.pt@...achi.com, josh@...htriplett.org,
	andi@...stfloor.org, mathieu.desnoyers@...icios.com,
	peterz@...radead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v11 21/28] tracing: Remove restriction on string position
 in hist trigger keys

On Thu, Oct 22, 2015 at 01:14:25PM -0500, Tom Zanussi wrote:
> If we assume the maximum size for a string field, we don't have to
> worry about its position.  Since we only allow two keys in a compound
> key and having more than one string key in a given compound key
> doesn't make much sense anyway, trading a bit of extra space instead
> of introducing an arbitrary restriction makes more sense.
> 
> We also need to use the event field size for static strings when
> copying the contents, otherwise we get random garbage in the key.
> 
> Also, cast string return values to avoid warnings on 32-bit compiles.
> 
> Finally, rearrange the code without changing any functionality by
> moving the compound key updating code into a separate function.
> 
> Signed-off-by: Tom Zanussi <tom.zanussi@...ux.intel.com>
> Tested-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
> ---

[SNIP]
> @@ -508,8 +508,8 @@ static int create_key_field(struct hist_trigger_data *hist_data,
>  			goto out;
>  		}
>  
> -		if (is_string_field(field)) /* should be last key field */
> -			key_size = HIST_KEY_SIZE_MAX - key_offset;
> +		if (is_string_field(field))
> +			key_size = MAX_FILTER_STR_VAL;
>  		else
>  			key_size = field->size;
>  	}
> @@ -781,9 +781,36 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data,
>  	}
>  }
>  
> +static inline void add_to_key(char *compound_key, void *key,
> +			      struct hist_field *key_field, void *rec)
> +{
> +	size_t size = key_field->size;
> +
> +	if (key_field->flags & HIST_FIELD_STRING) {
> +		struct ftrace_event_field *field;
> +
> +		/* ensure NULL-termination */
> +		size--;

No need to do it here since the size will be updated below.

> +
> +		field = key_field->field;
> +		if (field->filter_type == FILTER_DYN_STRING)
> +			size = *(u32 *)(rec + field->offset) >> 16;
> +		else if (field->filter_type == FILTER_PTR_STRING)
> +			size = strlen(key);
> +		else if (field->filter_type == FILTER_STATIC_STRING)
> +			size = field->size;
> +
> +		if (size > key_field->size - 1)
> +			size = key_field->size - 1;

The comment above can be moved here though.

Thanks,
Namhyung


> +	}
> +
> +	memcpy(compound_key + key_field->offset, key, size);
> +}
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists