Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2101665imj; Fri, 8 Feb 2019 12:34:43 -0800 (PST) X-Google-Smtp-Source: AHgI3IZL51kIx5Ap7lrUBtim/mCjxOGiiHsKRabmREtnaCqwLKHqQUqHtIF3h6KbhWFolwdAIQhy X-Received: by 2002:a17:902:8d8d:: with SMTP id v13mr5398733plo.121.1549658083098; Fri, 08 Feb 2019 12:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549658083; cv=none; d=google.com; s=arc-20160816; b=TGE7rzQJ1eYPWnqSkLZBPI1NnQ3fQeC3olSnxSsLouZJNWIAGuuzChNJdfU8bwg5fi lLMofDptX5u2ZafiWPC8tiVxokJIsuXeKqNJPEtzQuw4GHxIfkWZcQvCWK4pz8ruM8/7 hduerUvyZ/zteKLek/vAjgtX+upzm8qDUEYpWLjpLSuYJ93gqgRQyRWxEvsAU4TRBOMD LHSM2/OFRAmRqH1pee9bejJmhH+LPZ0V6aPzpfgxzaCgMMJKmOX0CakphgAPvG23U19p HKGv76ptUqr/m1AOdJRVG+qKL6JkQWRAsy8VV0tGvzFGLqqpvXoR59PEQtTsEqcmLCA6 LsVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4UFznljXd4IyrVSxwbopYcGR+HEQgH4TTL29XSymlWw=; b=kkiLMuYTJaZbC0RRp1NVA49wobrp10I9GVQX6NKNvKwS68cfbI55ispsv7ASXvR2d7 h/M9xZ8Ey4TZP/LmhIyDZ+g4NYWn7U5jw55/EeYgKx2GggjXAHlHxocbq6829njq98bl XRn8perAHGjtXST4xri/ZamhtIAJe9fNaGpvCVS8vbuuKMSk76Q0Gwl2SAsJjwzqIjtL 9sMpRnqlRkbIWyPPkHviHj2jZhlIGmTgg5Pw7tRTTzEpkM+3WyjyQ1nNReWaG0Mg46Pg /sVutOjSIIgzj2P+H94eN4mMsKuG9ZZPrImD/ncfTG3SZHaT2K9yR4P3H97KN/XfYr0t aX4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=FEfpVoMj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f39si3177840plb.369.2019.02.08.12.34.26; Fri, 08 Feb 2019 12:34:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=FEfpVoMj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727537AbfBHUaf (ORCPT + 99 others); Fri, 8 Feb 2019 15:30:35 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:38923 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726679AbfBHUaZ (ORCPT ); Fri, 8 Feb 2019 15:30:25 -0500 Received: by mail-ed1-f65.google.com with SMTP id b14so3899263edt.6 for ; Fri, 08 Feb 2019 12:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4UFznljXd4IyrVSxwbopYcGR+HEQgH4TTL29XSymlWw=; b=FEfpVoMjhsBIu9wGzcoHFMKCMQ2hdNr32nIKe1eEz7PmVsCpXelZQe05zRXiqbE60Q 7ojUBd3WsN7HmVl9x3q823CtYheh9y0op3XOz8RWW82esxnGLCtRKBG1TwhXAyYaR4i7 Q2+eReUPrEcfWripeN1VM3dvwgRvX2CFTvzts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4UFznljXd4IyrVSxwbopYcGR+HEQgH4TTL29XSymlWw=; b=bsVV7P9xyC/VgV4+YcHNfUCxwhp6hVRG46cv8TDCMhkYbx/Cc6DaV0SifuuooWSz6e Kh6A55rrR8oo1N4+z4CpWrfKldcAkj9xTvJb4w7vs8tJYAqLGSua3ULPM38FEM71i3fT 89s44pRycw1SPrzJe0lg1QA0HtYuSwm6IDMdQWC0nJ2fEQlV3UL9B7iKLHG6CB+DaRVn fJSW4VUe8hH8wg+fXMbz4WtHJKbqiu5bcZVZMgepjMcWTRbhSfjKWfOMWboh/FNpBM4u jAi0UW4h3wwEAdARFWL5sA/jPod4d3wjydeB4r2uXdzZ29R8b9H8+q9E9FFPJ5Q98AAA PCRg== X-Gm-Message-State: AHQUAuYm2aicfgPOB5EYfF8DJvpJpSHA33qzcyzMHnmKL1gowN8Wyu7V x2DlBEhB/1a37nhgtIluLa3LhQ== X-Received: by 2002:a17:906:5053:: with SMTP id e19mr17478286ejk.9.1549657823568; Fri, 08 Feb 2019 12:30:23 -0800 (PST) Received: from prevas-ravi.waoo.dk (ip-5-186-119-174.cgn.fibianet.dk. [5.186.119.174]) by smtp.gmail.com with ESMTPSA id p7sm680095ejb.15.2019.02.08.12.30.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Feb 2019 12:30:23 -0800 (PST) From: Rasmus Villemoes To: Andrew Morton Cc: Masahiro Yamada , Nick Desaulniers , Kees Cook , Luc Van Oostenryck , linux-kernel@vger.kernel.org, Rasmus Villemoes , Alexander Viro Subject: [PATCH v2 3/3] linux/fs.h: move member alignment check next to definition of struct filename Date: Fri, 8 Feb 2019 21:30:15 +0100 Message-Id: <20190208203015.29702-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190208203015.29702-1-linux@rasmusvillemoes.dk> References: <20190203192401.29170-1-linux@rasmusvillemoes.dk> <20190208203015.29702-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of doing this compile-time check in some slightly arbitrary user of struct filename, put it next to the definition. Signed-off-by: Rasmus Villemoes --- v2: added, mostly as an example of use of static_assert(), to check that the compiler actually groks it. Feel free to NAK it as useless churn. fs/namei.c | 2 -- include/linux/fs.h | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 914178cdbe94..d604f6b3bcc3 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -39,7 +39,6 @@ #include #include #include -#include #include "internal.h" #include "mount.h" @@ -131,7 +130,6 @@ getname_flags(const char __user *filename, int flags, int *empty) struct filename *result; char *kname; int len; - BUILD_BUG_ON(offsetof(struct filename, iname) % sizeof(long) != 0); result = audit_reusename(filename); if (result) diff --git a/include/linux/fs.h b/include/linux/fs.h index 29d8e2cfed0e..8dce6932e620 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -2487,6 +2489,7 @@ struct filename { struct audit_names *aname; const char iname[]; }; +static_assert(offsetof(struct filename, iname) % sizeof(long) == 0); extern long vfs_truncate(const struct path *, loff_t); extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, -- 2.20.1