From patchwork Tue Mar 13 19:51:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salvatore Mesoraca X-Patchwork-Id: 10280655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D97EE60580 for ; Tue, 13 Mar 2018 19:52:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6A5B283FF for ; Tue, 13 Mar 2018 19:52:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9158283ED; Tue, 13 Mar 2018 19:52:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 08DEB284AF for ; Tue, 13 Mar 2018 19:52:15 +0000 (UTC) Received: (qmail 15750 invoked by uid 550); 13 Mar 2018 19:52:14 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 15712 invoked from network); 13 Mar 2018 19:52:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ogX+fjjyfvLqQfI0J/Br2/bnDmIyb3fQ5eOf0W1m+fk=; b=rxpwSps4hrpWgLu++W6Sbf4tct37cbh7OFJrLNrdvpKcQ7klZ7VFZ5cvERgrEyRo/a LkKGD7LcL21mmBu+g2ZmesLTTxH8CdOF7hnNmXJp19+pa4RvKWUEwtZBSgv06XiAj86h 201ZmatTed0272ZTs4kCE9JjFHduatTK4iEZnApw/UiFtOV6Iquc28oAkV/rjSh2yhfH YVstM5oKlX2fdmlEf/c9rtu73pReV4D3nT+pq0B9RFKpqa1yFf0IweGc1hNVnKgA99fX cGHVp1YdSbAxW+Zu/2C14sGUbu0IjnnfjNPyBGvaH+pU0SvexbNbCe6pGPG18vhaaj72 ECaw== 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; bh=ogX+fjjyfvLqQfI0J/Br2/bnDmIyb3fQ5eOf0W1m+fk=; b=GQw87NvYO3UnQG5vSx3KRrebI7ZTB+33yBv8wyKLdUJsyUEoPG4feE04QPgTMSoz84 R7tuiEWgNx/G8EEiSDEghEqjdxWEYdOntj6pxGgse4jm5GO38M7Axqweyix2hTBm6nMd Ey1jpEUlTI9zQuLdezaxeVYps0f9aed/OsE6upD7k9dMoxrgn42Gr2cYeZIehGBd/Sqw jG9tz3crW5spq2AHgrMWJ1OVjQaiyxdxCupecCVM14FO+1qEMEuik296AQOJUQ3mnucE CyFkCHvHqlyLVlm54o9TFzZUgssEicgrjYcxLmq8kGUGWsZq2jZALrRbruLEGTwq+Fy/ uwpw== X-Gm-Message-State: AElRT7GIYl6KlioKT4DGTQfJsD8to5qr7H6wFUBXRay7FcGnEtirD/rO riO6BQ+MSXwif6fONEtzoCQ= X-Google-Smtp-Source: AG47ELskBRFIIpECReKVt6+x3YZ4TW/n0x2D2B7BYv+ShadrwPa/yHZ8bDdYivaP3y6et1cSyJMDcA== X-Received: by 10.223.184.88 with SMTP id u24mr1548567wrf.3.1520970722137; Tue, 13 Mar 2018 12:52:02 -0700 (PDT) From: Salvatore Mesoraca To: linux-kernel@vger.kernel.org Cc: kernel-hardening@lists.openwall.com, Joel Becker , Kees Cook , Mark Fasheh , Salvatore Mesoraca Subject: [PATCH] ocfs2: drop a VLA in ocfs2_orphan_del() Date: Tue, 13 Mar 2018 20:51:50 +0100 Message-Id: <1520970710-19732-1-git-send-email-s.mesoraca16@gmail.com> X-Mailer: git-send-email 1.9.1 X-Virus-Scanned: ClamAV using ClamSMTP Avoid a VLA[1] by using a real constant expression instead of a variable. The compiler should be able to optimize the original code and avoid using an actual VLA. Anyway this change is useful because it will avoid a false positive with -Wvla, it might also help the compiler generating better code. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Salvatore Mesoraca Reviewed-by: Kees Cook --- fs/ocfs2/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index c801edd..41ef356 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -2332,8 +2332,7 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, struct buffer_head *orphan_dir_bh, bool dio) { - const int namelen = OCFS2_DIO_ORPHAN_PREFIX_LEN + OCFS2_ORPHAN_NAMELEN; - char name[namelen + 1]; + char name[OCFS2_DIO_ORPHAN_PREFIX_LEN + OCFS2_ORPHAN_NAMELEN + 1]; struct ocfs2_dinode *orphan_fe; int status = 0; struct ocfs2_dir_lookup_result lookup = { NULL, };