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


Groups > linux.kernel > #1637753

[PATCH] ocfs2: Use ERR_CAST() to avoid cross-structure cast

Path csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod
From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject [PATCH] ocfs2: Use ERR_CAST() to avoid cross-structure cast
Date Tue, 09 May 2017 00:00:02 +0200
Message-ID <tEYRc-ZP-5@gated-at.bofh.it> (permalink)
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=KLv9Qa98O7FPA71IgdYb4XaloENPHWbuwzrTnq54GkA=; b=obPXLjOAk+9s0J/zJRyHW4KgiPmo6uYhtljhDeqH+OG1zU3dwUFQ2ESZhYrwrKEZFH sccYc7oZDLhZJ36tm88SCLyo5EQ++ujG08bALNnjaumkFGDG1S5KznL35RNHYnmstEFi iFG2kiSihkGOdOm0J+Lj5lo62lSK73No9XSPo=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=KLv9Qa98O7FPA71IgdYb4XaloENPHWbuwzrTnq54GkA=; b=pTiETResuF1bvvCV+qY0tJi2sFxe0P/Xlnq22gDnXrOqr0SPOQkzw8KbLugQ6WsW2a lYQ7OGpyH+YwJzcjyVVx8FobK0SyRsOnGmZMahcsM/xKOsfU8qQlaVSL4iJ9F+t6agJz r3peKcFHO71SilsUI0eBQ2e4CFivoPcViv3suWr/D5UU55Gb20a5L9n63c9kewGo4bpU DmNt3514+LxTx8S9AHnY83E3BRgqhOu2++/o79HBo9Y1/oDkWzeIX35DsfOAtSbwYKwY FxJ1MrUm+rMNClbzbUEyKYhHuCyxPX6Y+7bv3mRWYRcyeAkIGIU2IxnQQg94sUGLtIuC fPQw==
X-Gm-Message-State AN3rC/5tzTyivZOcp9vQYMxK2zA9z4bdA2hz2LOX4s9miQD9Xcv+roaR tn6New3N8LZlZntKlEVCgQ==
X-Received by 10.99.125.13 with SMTP id y13mr21212816pgc.234.1494280543516; Mon, 08 May 2017 14:55:43 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
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 32
Organization linux.* mail to news gateway
X-Original-Cc Mark Fasheh <mfasheh@versity.com>, Joel Becker <jlbec@evilplan.org>, ocfs2-devel@oss.oracle.com
X-Original-Date Mon, 8 May 2017 14:55:42 -0700
X-Original-Message-ID <20170508215542.GA13401@beast>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1637753

Show key headers only | View raw


When trying to propegate an error result, the error return path attempts
to retain the error, but does this with an open cast across very different
types, which the upcoming structure layout randomization plugin flags as
being potentially dangerous in the face of randomization. This is a false
positive, but what this code actually wants to do is use ERR_CAST() to
retain the error value.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 fs/ocfs2/export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c
index 827fc9809bc2..9f88188060db 100644
--- a/fs/ocfs2/export.c
+++ b/fs/ocfs2/export.c
@@ -119,7 +119,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb,
 
 	if (IS_ERR(inode)) {
 		mlog_errno(PTR_ERR(inode));
-		result = (void *)inode;
+		result = ERR_CAST(inode);
 		goto bail;
 	}
 
-- 
2.7.4


-- 
Kees Cook
Pixel Security

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


Thread

[PATCH] ocfs2: Use ERR_CAST() to avoid cross-structure cast Kees Cook <keescook@chromium.org> - 2017-05-09 00:00 +0200

csiph-web