Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1656574

Re: [PATCH v4] add the option of fortified string.h functions

Path csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Daniel Micay <danielmicay@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v4] add the option of fortified string.h functions
Date Fri, 02 Jun 2017 23:40:01 +0200
Message-ID <tO2sx-6xE-5@gated-at.bofh.it> (permalink)
References <tLkch-4g5-5@gated-at.bofh.it> <tO1Zw-6nR-23@gated-at.bofh.it>
X-Original-To Andrew Morton <akpm@linux-foundation.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=7sM4RU0blMiav5rUQvOxoyvB0vnbOaBBE8hCMm53y1w=; b=JwG9obQrM0f20U624s0VAGlt1zq+P7fCeOB3fxFKYceBjWfS0hwj6UDTLVRdVvGQIH j9Vji32XugrTRcg4VtMCra3BGQBJ9NgjSXc3bY70z4Vrtl2FnzlBuCdWYD7iT7tPQ4sN KZFJc1Xj13TV6/IRkyakel4rbEkTc1xHckjfUeZtTl8IabzG12taOa9ToURjLMAk9lSk WKtpLcKwFXVxwtXeQz9BNp7ZUhTVAU8pqu8C1UVC3EZ9y4shnG4FedQ4j0ztB3vUkHbc 7UDzmO28DdP572zSLWEhMHTfzk0JRi14wSQ0tqL20OXOFQql9qNDkirmpAuoz6DH1/E9 Ua9g==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=7sM4RU0blMiav5rUQvOxoyvB0vnbOaBBE8hCMm53y1w=; b=iVr7s3kyPJUz46mplHRtSiTHgoEmfp+y0C6iFv3wSc8b1/cdFnuqa2b82GtxQ0LOwN 2UU+e2Lwe+SeH3gxeKFGo/AjoX03pPVdYkEZ2C88W5V9vRVF5f4s/HRbTzwvGAD3QFjx pQGvCq0weBJmD78J6w9ZNb8gDFjTtGwnHTyGviJuaTcYRhoIrtsl8fB/xWzvfy8jZA2p 1U8FnPuPYzUVbrTHSvyApBdcLS0AhA3G14pxXYu+bvQ5cFqBk6vfFLjSmT0kJYwoMiMH b+6YKA9SX0eZDpOMlWivI1FEa6jtkcDCgtZ17bNdgVTcOX8omXJOfFc6zEL1vdjl9VLk Knxw==
X-Gm-Message-State AODbwcBkBwtZBeYSdkjRzNGwH92lxkgOvL6SZAThhvMHEMiLUbwoJ7vw 8WXEwnNRp1JjGQ==
X-Received by 10.36.23.22 with SMTP id 22mr1566088ith.78.1496439123392; Fri, 02 Jun 2017 14:32:03 -0700 (PDT)
Content-Type text/plain; charset="UTF-8"
X-Mailer Evolution 3.24.2
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 59
Organization linux.* mail to news gateway
X-Original-Cc linux-mm@kvack.org, Kees Cook <keescook@chromium.org>, kernel-hardening@lists.openwall.com, linux-kernel <linux-kernel@vger.kernel.org>, Mark Rutland <mark.rutland@arm.com>, Daniel Axtens <dja@axtens.net>, Moni Shoua <monis@mellanox.com>, Doug Ledford <dledford@redhat.com>, Sean Hefty <sean.hefty@intel.com>, Hal Rosenstock <hal.rosenstock@gmail.com>, linux-rdma@vger.kernel.org
X-Original-Date Fri, 02 Jun 2017 17:32:01 -0400
X-Original-Message-ID <1496439121.13303.1.camel@gmail.com>
X-Original-References <20170526095404.20439-1-danielmicay@gmail.com> <20170602140743.274b9babba6118bfd12c7a26@linux-foundation.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1656574

Show key headers only | View raw


On Fri, 2017-06-02 at 14:07 -0700, Andrew Morton wrote:
> On Fri, 26 May 2017 05:54:04 -0400 Daniel Micay <danielmicay@gmail.com
> > wrote:
> 
> > This adds support for compiling with a rough equivalent to the glibc
> > _FORTIFY_SOURCE=1 feature, providing compile-time and runtime buffer
> > overflow checks for string.h functions when the compiler determines
> > the
> > size of the source or destination buffer at compile-time. Unlike
> > glibc,
> > it covers buffer reads in addition to writes.
> 
> Did we find a bug in drivers/infiniband/sw/rxe/rxe_resp.c?
> 
> i386 allmodconfig:
> 
> In file included from ./include/linux/bitmap.h:8:0,
>                  from ./include/linux/cpumask.h:11,
>                  from ./include/linux/mm_types_task.h:13,
>                  from ./include/linux/mm_types.h:4,
>                  from ./include/linux/kmemcheck.h:4,
>                  from ./include/linux/skbuff.h:18,
>                  from drivers/infiniband/sw/rxe/rxe_resp.c:34:
> In function 'memcpy',
>     inlined from 'send_atomic_ack.constprop' at
> drivers/infiniband/sw/rxe/rxe_resp.c:998:2,
>     inlined from 'acknowledge' at
> drivers/infiniband/sw/rxe/rxe_resp.c:1026:3,
>     inlined from 'rxe_responder' at
> drivers/infiniband/sw/rxe/rxe_resp.c:1286:10:
> ./include/linux/string.h:309:4: error: call to '__read_overflow2'
> declared with attribute error: detected read beyond size of object
> passed as 2nd parameter
>     __read_overflow2();
> 
> 
> If so, can you please interpret this for the infiniband developers?

It copies sizeof(skb->cb) bytes with memcpy which is 48 bytes since cb
is a 48 byte char array in `struct sk_buff`. The source buffer is a
`struct rxe_pkt_info`:

struct rxe_pkt_info {
	struct rxe_dev		*rxe;		/* device that owns packet */
	struct rxe_qp		*qp;		/* qp that owns packet */
	struct rxe_send_wqe	*wqe;		/* send wqe */
	u8			*hdr;		/* points to bth */
	u32			mask;		/* useful info about pkt */
	u32			psn;		/* bth psn of packet */
	u16			pkey_index;	/* partition of pkt */
	u16			paylen;		/* length of bth - icrc */
	u8			port_num;	/* port pkt received on */
	u8			opcode;		/* bth opcode of packet */
	u8			offset;		/* bth offset from pkt->hdr */
};

That looks like 32 bytes (1 byte of padding) on 32-bit and 48 bytes on
64-bit (1 byte of padding), so on 32-bit there's a read overflow of 16
bytes from the stack here.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4] add the option of fortified string.h functions Daniel Micay <danielmicay@gmail.com> - 2017-05-26 12:00 +0200
  Re: [PATCH v4] add the option of fortified string.h functions Andrew Morton <akpm@linux-foundation.org> - 2017-06-02 23:10 +0200
    Re: [PATCH v4] add the option of fortified string.h functions Daniel Micay <danielmicay@gmail.com> - 2017-06-02 23:40 +0200
      Re: [PATCH v4] add the option of fortified string.h functions Kees Cook <keescook@chromium.org> - 2017-06-03 07:10 +0200

csiph-web