Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp16709imm; Fri, 25 May 2018 13:19:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqBaGTRz6R6Zf3JdV0zwjwQHrLmM70ml2ZCE2+3BOATvuvJnFbPmyGTsdJ4VyrTXRZ/SLFK X-Received: by 2002:a63:aa4c:: with SMTP id x12-v6mr2996488pgo.398.1527279547474; Fri, 25 May 2018 13:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527279547; cv=none; d=google.com; s=arc-20160816; b=ONmCwmbXVkKH5R8Prdb1T9G9Megbnd+4HWqkQVsR/lIbCPYXJ5Ap++I8fiuy/FQfYr 4dpTyD2ANaqMvo01NYaEczodLFi9LJWQ99pifcoLutSYVMrFQs/UJEpQnoyxyllzZIED mtTWTulnTmPG1x0eaxfmtdzK7cwGMOOwelyB8vrOEiy7GrOUKqlKe49VBMmQrrAw/IUP lWlwzAdrNB0KybV8qMuh5sw1woImj+vKPZeVtDk6MhDomO305XXwuiuhODwAS6FNwYVm B1sGaEDSmNYhIx64Zkow+zX81q6hgY2HSfXQbFHztJjvnsaEEBClQvPjRLVEDbnZClKf wYGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=bsnzuVExuKKa/tsoSQdWzpeXkm1F1g1TrVZu5cjKfa0=; b=VP71CjXpcPpw6TW5a647I2ocNheDFRvbO+uYTmj+bSCeNTmNSTMvreXzFZ4ie3iyMY hcxdqry3Gmvmbvx1d0SWjQWD7GskzgjBl0GdlwplG7+MRv3NT8Bn2stz/hJMAvohewac 0gFyoGUBgSDEoMvuAXOBP1n3/jP6pWb4LcbBtSlvb6+k71QKYuBDPCtOe6dxPtB2JVVw rU/E6AaxXJqIsuxd6rgo1WETNi55dOeKSwRNxlF5wPME86CRZcrNDixnFz8K0tEu2jeG qxgc4+w1hG+syAokbEt3DnpIklyctzZd3jhU7RXsdW2D/xjG8YpE01YQW4UO0ejU6OvG cR/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Wmb0Ol0a; 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 f35-v6si23765046plh.193.2018.05.25.13.18.52; Fri, 25 May 2018 13:19:07 -0700 (PDT) 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=fail header.i=@gmail.com header.s=20161025 header.b=Wmb0Ol0a; 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 S968314AbeEYUST (ORCPT + 99 others); Fri, 25 May 2018 16:18:19 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:36989 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967951AbeEYUSR (ORCPT ); Fri, 25 May 2018 16:18:17 -0400 Received: by mail-qt0-f194.google.com with SMTP id q13-v6so8084076qtp.4; Fri, 25 May 2018 13:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=bsnzuVExuKKa/tsoSQdWzpeXkm1F1g1TrVZu5cjKfa0=; b=Wmb0Ol0aKaqE9oOo1BMk2HBFMAf9O5eI10H6V6SuN7CtefJLAPnQ54n2AhEnsgGxuE Hd/827uVPIQduP+X36iMfxtZXgrSCgLnhAK4ni57/zdHdazm+XX6mXXyU7PmujHtBv7j v0x32DUY1X7UtkgFnrvI23+NuK+PvWskY+3cuUlMh0VRX02BbLlIB7n/IdEis/8zO0yW q0rhW6WdhGM8pqpn1PnomzaZLi1KBa7Ae2kqDZrM35QNCs8Uj0K+nvDt7Sii5UDQFI1g sQW2gwAbEBWrhizKJ7J/D4TnfWHeY8Icz/Gw5SCt8qLqIy1zNn6J0N53KrIajwVTnUUd jcww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=bsnzuVExuKKa/tsoSQdWzpeXkm1F1g1TrVZu5cjKfa0=; b=KlVwFiQMJ6Z/ZjSWEOUO1vjRTLf2jqZ9izgWI3+hpsAwO5fs5Uz0wtcxu2t/tMTkRo orsBdMaKkW84BBQ9s7NBt6u+KTCR5I0Hi6BwtR9NeEzO8lSgGVppUuiMmDmBfN3zPqHF tcwasqc+oe0uzVW52/eRBUl2EyYL02tyjYJn4zpoBrfcTHRDPVvd3S9r3tu0yO2e4Hbt +/EAr5tQyuqSOLtZQKdIAcnddW7mepCICEMcbdJgzgWWJAKkNwDJyw+ZOM6sQ/dlPHLA 4CbRruGLxj+6eHpJCCSRTyhdmisgSvIck9+jjpo+5j2oHM9vKXOVeNgLgsiidqeq6dCi doiw== X-Gm-Message-State: ALKqPwecte157YCh78TasFXyHmWgg9/alJqQSqDKD1ZH/77L1mbEhxGI xKz+zY0c0iWZS4ONnz8K4pkQYZw8JFU/WEIfbT4= X-Received: by 2002:ac8:64a:: with SMTP id e10-v6mr3760161qth.163.1527279496496; Fri, 25 May 2018 13:18:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:b903:0:0:0:0:0 with HTTP; Fri, 25 May 2018 13:18:16 -0700 (PDT) In-Reply-To: <20180525165222.GA7567@infradead.org> References: <20180525151421.2317292-1-arnd@arndb.de> <20180525165222.GA7567@infradead.org> From: Arnd Bergmann Date: Fri, 25 May 2018 22:18:16 +0200 X-Google-Sender-Auth: wBzdD4-aRNomWNqlceYahhm4_cs Message-ID: Subject: Re: [PATCH] xfs: mark sb_fname as nonstring To: Christoph Hellwig Cc: "Darrick J. Wong" , linux-xfs , Eric Sandeen , Martin Sebor , Brian Foster , Dave Chinner , Eric Sandeen , Dan Williams , Ross Zwisler , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 25, 2018 at 6:52 PM, Christoph Hellwig wrote: >> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c >> index 84fbf164cbc3..eb79f2bc4dcc 100644 >> --- a/fs/xfs/xfs_ioctl.c >> +++ b/fs/xfs/xfs_ioctl.c >> @@ -1819,12 +1819,12 @@ xfs_ioc_getlabel( >> BUILD_BUG_ON(sizeof(sbp->sb_fname) > FSLABEL_MAX); >> >> spin_lock(&mp->m_sb_lock); >> - strncpy(label, sbp->sb_fname, sizeof(sbp->sb_fname)); >> + strncpy(label, sbp->sb_fname, XFSLABEL_MAX); >> spin_unlock(&mp->m_sb_lock); > > Hmm, shouldn't we just do a memcpy here? I thought about that as well, but decided that strncpy()'s zero-padding is better here than padding with potentially random contents of the user space stack. > Also given that the kernel never even looks at sb_fname maybe > we can turn into an array of unsigned chars to escape those string > warnings? I don't think that makes a difference to gcc. Arnd