Re: [PATCH] sanitize task->comm to avoid leaking escape codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/23, Kees Cook wrote:
>
> @@ -956,7 +957,15 @@ void set_task_comm(struct task_struct *tsk, char *buf)
>  	 */
>  	memset(tsk->comm, 0, TASK_COMM_LEN);
>  	wmb();

Off-topic. I'd wish I could understand this barrier. Since the lockless
reader doesn't do rmb() I don't see how this can help. OTOH, I don't
understand why it is needed, we never change ->comm[TASK_COMM_LEN-1] == '0'.

> -	strlcpy(tsk->comm, buf, sizeof(tsk->comm));
> +
> +	/* sanitize non-printable characters */
> +	for (i = 0; buf[i] && i < (sizeof(tsk->comm) - 1); i++) {
> +		if (!isprint(buf[i]))
> +			tsk->comm[i] = '?';
> +		else
> +			tsk->comm[i] = buf[i];
> +	}

Personally I think this makes sense.

> -extern char *get_task_comm(char *to, struct task_struct *tsk);
> +#define get_task_comm(buf, task) get_task_comm_size(buf, sizeof(buf), task)
> +extern char *get_task_comm_size(char *to, size_t len, struct task_struct *tsk);

Oh, but this means that get_task_comm(ptr, task) doesn't work?

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux