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]
Message-ID: <20120615163600.GA10922@linux.vnet.ibm.com>
Date:	Fri, 15 Jun 2012 22:06:01 +0530
From:	Srikar Dronamraju <srikar@...ux.vnet.ibm.com>
To:	Oleg Nesterov <oleg@...hat.com>
Cc:	Ingo Molnar <mingo@...e.hu>,
	Ananth N Mavinakayanahalli <ananth@...ibm.com>,
	Anton Arapov <anton@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 11/15] uprobes: move BUG_ON(UPROBE_SWBP_INSN_SIZE) from
 write_opcode() to install_breakpoint()


> 
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 14c71a2..b9c61bd 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -210,7 +210,6 @@ static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
>  	void *vaddr_old, *vaddr_new;
>  	struct vm_area_struct *vma;
>  	struct uprobe *uprobe;
> -	unsigned long pgoff;
>  	int ret;
>  retry:
>  	/* Read the page with vaddr into memory */
> @@ -251,11 +250,7 @@ retry:
>  	vaddr_new = kmap_atomic(new_page);
> 
>  	memcpy(vaddr_new, vaddr_old, PAGE_SIZE);
> -
> -	/* poke the new insn in, ASSUMES we don't cross page boundary */
> -	pgoff = (vaddr & ~PAGE_MASK);
> -	BUG_ON(pgoff + UPROBE_SWBP_INSN_SIZE > PAGE_SIZE);
> -	memcpy(vaddr_new + pgoff, &opcode, UPROBE_SWBP_INSN_SIZE);
> +	memcpy(vaddr_new + (vaddr & ~PAGE_MASK), &opcode, UPROBE_SWBP_INSN_SIZE);
> 
>  	kunmap_atomic(vaddr_new);
>  	kunmap_atomic(vaddr_old);
> @@ -699,6 +694,10 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
>  		if (ret)
>  			return ret;
> 
> +		/* write_opcode() assumes we don't cross page boundary */
> +		BUG_ON((uprobe->offset & ~PAGE_MASK) +
> +				UPROBE_SWBP_INSN_SIZE > PAGE_SIZE);
> +
>  		uprobe->flags |= UPROBE_COPY_INSN;
>  	}

I am now thinking if we really need a BUG_ON? I am now thinking I should
have had a check at the start in uprobe_register() and failed the request. 

Something like 
	if ((offset & ~PAGE_MASK) + UPROBE_SWBP_INSN_SIZE > PAGE_SIZE)
		return -EINVAL;
-- 
Thanks and Regards
Srikar

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ