From patchwork Thu Nov 28 15:59:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3652D138C for ; Thu, 28 Nov 2019 15:59:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 164DB21787 for ; Thu, 28 Nov 2019 15:59:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="gp4fkfbH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbfK1P7t (ORCPT ); Thu, 28 Nov 2019 10:59:49 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:51524 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726648AbfK1P7t (ORCPT ); Thu, 28 Nov 2019 10:59:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956788; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=p9Wylpk2ZhwaY6AHfisQs9UzMFrxtqG9nnsoA/OlXV8=; b=gp4fkfbH1dN8P1neLt2EM9feSvPOop2vspRP791DtjtI9Nx0IdbwgkjIVtilqY7WEkVVN9 pKn2OcdUJnFwB/xH5O9Nv7zDZELIogTZYXx5B4M3uIziac2DBRzIGVXq6V3JlIDbUUQzRh miRkGOTHrpsRWkRK4ZsxhrOzfZRXMO4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-tehmmQLwMhWpaQ2wUs0XwA-1; Thu, 28 Nov 2019 10:59:45 -0500 Received: by mail-wr1-f72.google.com with SMTP id q12so14088192wrr.3 for ; Thu, 28 Nov 2019 07:59:45 -0800 (PST) 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=rUMGD7+UDhmSgUYjf0umsMgw2+YkPVZwq146yGXQ1AQ=; b=S7OK6twXoGcV3b0mQgPTcepLJMwWKimhL3bJvuU0r/TOwtF2/paVlO8RBGe8Ry3p6q U74UznKyUrI3y7kiSDjwcy0fsV7FrG/dqRu3rIjx92V4IsxCU4rsSlisSvkQBhpknIPA xb/a7xOclhmFv99RHXT0nMrnFj/ynFhXtDLIYWw/lxVGRnmQtsMLD3AMv8U+zvJsebwt kuvLeshpe7mkbRv3OPuKE8qS+SgFJMPNE0H6b8JJ9LplECtIvbGefo4RGBmAu2YBsQNi RjXLtop/50JU8rK29Oihuub2YpGnJkjcnMEnrDUup2yQdUkY4tO4qk0dORkLxwoaVYhM ZIvg== X-Gm-Message-State: APjAAAXniSQEcIgNgS6ZH4Kf12+UCkbDhRevhL3k3AsiTSSK+pn7cJ4K 111+VqiYh8OYeomSqxifs4F/WWWjaQMmMfrccAl4WE6VdlFYRItThin45ppej/ZHEjnBucFUfZa OSADv64ZaSNAyhol/3S8J64qI8A== X-Received: by 2002:a05:6000:103:: with SMTP id o3mr17474173wrx.80.1574956784379; Thu, 28 Nov 2019 07:59:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyJu7/0r2fDEvCZ7kcUxvde1QwqRokBI6zhEggF6ATPtanqmxQ9P7SyO0YaGm0IIgxMIXlqBg== X-Received: by 2002:a05:6000:103:: with SMTP id o3mr17474151wrx.80.1574956784154; Thu, 28 Nov 2019 07:59:44 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:43 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Avi Kivity , Giuseppe Scrivano , stable@vger.kernel.org Subject: [PATCH 01/12] aio: fix async fsync creds Date: Thu, 28 Nov 2019 16:59:29 +0100 Message-Id: <20191128155940.17530-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: tehmmQLwMhWpaQ2wUs0XwA-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Avi Kivity reports that on fuse filesystems running in a user namespace asyncronous fsync fails with EOVERFLOW. The reason is that f_ops->fsync() is called with the creds of the kthread performing aio work instead of the creds of the process originally submitting IOCB_CMD_FSYNC. Fuse sends the creds of the caller in the request header and it needs to translate the uid and gid into the server's user namespace. Since the kthread is running in init_user_ns, the translation will fail and the operation returns an error. It can be argued that fsync doesn't actually need any creds, but just zeroing out those fields in the header (as with requests that currently don't take creds) is a backward compatibility risk. Instead of working around this issue in fuse, solve the core of the problem by calling the filesystem with the proper creds. Reported-by: Avi Kivity Tested-by: Giuseppe Scrivano Fixes: c9582eb0ff7d ("fuse: Fail all requests with invalid uids or gids") Cc: stable@vger.kernel.org # 4.18+ Signed-off-by: Miklos Szeredi --- fs/aio.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/aio.c b/fs/aio.c index 0d9a559d488c..37828773e2fe 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -176,6 +176,7 @@ struct fsync_iocb { struct file *file; struct work_struct work; bool datasync; + struct cred *creds; }; struct poll_iocb { @@ -1589,8 +1590,11 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb, static void aio_fsync_work(struct work_struct *work) { struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, fsync.work); + const struct cred *old_cred = override_creds(iocb->fsync.creds); iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); + revert_creds(old_cred); + put_cred(iocb->fsync.creds); iocb_put(iocb); } @@ -1604,6 +1608,10 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, if (unlikely(!req->file->f_op->fsync)) return -EINVAL; + req->creds = prepare_creds(); + if (!req->creds) + return -ENOMEM; + req->datasync = datasync; INIT_WORK(&req->work, aio_fsync_work); schedule_work(&req->work); From patchwork Thu Nov 28 15:59:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266319 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC59A13A4 for ; Thu, 28 Nov 2019 15:59:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DAD1217AB for ; Thu, 28 Nov 2019 15:59:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="cBWqJ+Vq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726699AbfK1P7t (ORCPT ); Thu, 28 Nov 2019 10:59:49 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:35322 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726401AbfK1P7t (ORCPT ); Thu, 28 Nov 2019 10:59:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/QBHEanAnhJnmZ8pttrzUKSxHgn6TIpT2MQ/5Lg7YF8=; b=cBWqJ+Vqa06b+ZfVeexGsS/kYoLmpMZ4Z2dR2mLq/KJ8aodF6MofJqbnTvNau7wfvUBW2x tEPnqyjpEbCVDZYtS53+q6ZuANmY8Y82yOMxV0/+V9+9uvWWb919q5fMi65MJGlQf2eZSK de8n5x0n2sHTQx2XIHjEensIF4QAVH0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-80-GLIw6fsbPuamBIJOqSTm3g-1; Thu, 28 Nov 2019 10:59:46 -0500 Received: by mail-wr1-f71.google.com with SMTP id t3so1316549wrm.23 for ; Thu, 28 Nov 2019 07:59:46 -0800 (PST) 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=vPUbXlh0ygv/oQuHSRuwxKMQNHDHgL0AUVPr6KUwCtg=; b=OxcM31rVgNMVy2EJcfNpGWeQS5pxVzEjMjrrr8kXUTZnm27IBxhJP+3dtRrkv/Mu1K KuYbn4wfrlIzHTQWvUJhmpEwrmuuIarVISULW6wthKZs4cGbkmL12reJYiqi0X1kQTzy imzX4qOt7ZVZap/7BX+bOMAKIeBP5vZOpsP8nVR9PyYuAC8dcaFl0k1rVHEmgdSUA4B4 pFyeF1zEDLSeNThAjf2QCHzuoFSiYi2Tf+izO8yYNRwvm9PsZOtJv34wPwUpCHnKWy3D xJhs0PWgjtOTOq6Qq6Yp6Fpz3PwgwNayWHBEteBT/eISiPquvHLTImAbdmrRFBbqssy4 MvEA== X-Gm-Message-State: APjAAAVhouf0JYH71diylXwzyVU2atfZy+8rFxJYqwzc4KwcOU1HZpvU jbeqXJYh1Tgy1iQx25xrhEjvzkgLM/JkeBTMvuK4yTOoaSDfKyFyqIdrLmlQQHCvShZ+RibeeUF Sm9Q2I6naPtZVafhvCO1Kd30Arw== X-Received: by 2002:adf:e886:: with SMTP id d6mr43622025wrm.112.1574956785559; Thu, 28 Nov 2019 07:59:45 -0800 (PST) X-Google-Smtp-Source: APXvYqxCKrJiKteJ6JBXNs8YdU7/3P20wLIqyfhgjHIPW/eJswuIAtIwMpeBzbvXZ0lHsWjx+IxpIg== X-Received: by 2002:adf:e886:: with SMTP id d6mr43622013wrm.112.1574956785377; Thu, 28 Nov 2019 07:59:45 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:44 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Andrew Price , David Howells , stable@vger.kernel.org Subject: [PATCH 02/12] fs_parse: fix fs_param_v_optional handling Date: Thu, 28 Nov 2019 16:59:30 +0100 Message-Id: <20191128155940.17530-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: GLIw6fsbPuamBIJOqSTm3g-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org String options always have parameters, hence the check for optional parameter will never trigger. Check for param type being a flag first (flag is the only type that does not have a parameter) and report "Missing value" if the parameter is mandatory. Tested with gfs2's "quota" option, which is currently the only user of fs_param_v_optional. Signed-off-by: Miklos Szeredi Cc: Andrew Price Cc: David Howells Fixes: 31d921c7fb96 ("vfs: Add configuration parser helpers") Cc: # v5.4 Reviewed-by: Andrew Price --- fs/fs_parser.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/fs_parser.c b/fs/fs_parser.c index d1930adce68d..5d8833d71b37 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -127,13 +127,15 @@ int fs_parse(struct fs_context *fc, case fs_param_is_u64: case fs_param_is_enum: case fs_param_is_string: - if (param->type != fs_value_is_string) - goto bad_value; - if (!result->has_value) { + if (param->type == fs_value_is_flag) { if (p->flags & fs_param_v_optional) goto okay; - goto bad_value; + + return invalf(fc, "%s: Missing value for '%s'", + desc->name, param->key); } + if (param->type != fs_value_is_string) + goto bad_value; /* Fall through */ default: break; From patchwork Thu Nov 28 15:59:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266327 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D16EE13A4 for ; Thu, 28 Nov 2019 15:59:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1ACD21787 for ; Thu, 28 Nov 2019 15:59:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WX8cGlyH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726859AbfK1P74 (ORCPT ); Thu, 28 Nov 2019 10:59:56 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:28446 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726712AbfK1P7w (ORCPT ); Thu, 28 Nov 2019 10:59:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YgNx2QlaW/nPKw0a9jvrS7+oX5fUKLAjBptvibbWb3E=; b=WX8cGlyHIlBfdwtKHzbXFx6spabopGD4Y2RfG4+2t3flLD4KrzU7rpLK3CYytWlDoCwypE wx2YQ9HAXGfDlQRCr1vIoBloLJACTeB6XIRmVzxo4+ZsqqQd47fSCqr2YfnBLwP/h3SV/l +/xZa9MqvNj2LgGHICmF6Jy52S0AaPA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-Wz3W57ORNE-AMGqsMMMd_w-1; Thu, 28 Nov 2019 10:59:47 -0500 Received: by mail-wr1-f72.google.com with SMTP id l20so4220078wrc.13 for ; Thu, 28 Nov 2019 07:59:47 -0800 (PST) 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=ksbYxCBjZpn48B7inJ6BGWvn4QhG0WnW3THy3fEooIE=; b=Nvevd+0rjtbUNnCPBoIkPo7I4SBzvkGzVXSJ9zkyRCgS/4jRiG91K1U7kBeHuYw4gq OKBEd/oiegRbVy8RILja+lvahEtfCVmmcppn+HBkMGrxhSXb1IvOa67tYbrCVmVFM8C4 qhmqjqV+SXqLBeFydIO/OSdQcBn+Md6LnYcddK9YlwwL1lLStsBjfV4R41kIBe0SyS6E t43nsfpuSJqEFF4eA1Fpz8qmFNrjlmLT4jZITClHCQv9jVW7slTSprbza/PSGjQsr4GC LlQMsy/5iB+XCJ4HaFTOPsl5xUQbM7T0BBGevQNYU0K1HydOz3Kbx3v5aX2SNWQryMy0 qqkg== X-Gm-Message-State: APjAAAWVGwhWJJjM0cBrpBIwn6Yj2qsblTwV8UUXNzEkqw7sljzE1DYB PunhU/VXe7IkrVi4jkDpU93+lNlp/RtCRfc4U8ALCx606AdOqOn7oHpPBNMOuPralvKXwxIga/M v3lkeRGWCJ+fpr58dqIx8vEvAOA== X-Received: by 2002:adf:8297:: with SMTP id 23mr3217893wrc.379.1574956786670; Thu, 28 Nov 2019 07:59:46 -0800 (PST) X-Google-Smtp-Source: APXvYqzbftcMeSmUBYfgr5BqYQGaoMoGlSEyP5kOfnqs1J0+gPrussxlInpDoGMQ0BxEQQI1OiedqA== X-Received: by 2002:adf:8297:: with SMTP id 23mr3217876wrc.379.1574956786487; Thu, 28 Nov 2019 07:59:46 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:45 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 03/12] vfs: verify param type in vfs_parse_sb_flag() Date: Thu, 28 Nov 2019 16:59:31 +0100 Message-Id: <20191128155940.17530-4-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: Wz3W57ORNE-AMGqsMMMd_w-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org vfs_parse_sb_flag() accepted any kind of param with a matching key, not just a flag. This is wrong, only allow flag type and return -EINVAL otherwise. Signed-off-by: Miklos Szeredi --- fs/fs_context.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 138b5b4d621d..66fd7d753e91 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -81,30 +81,29 @@ static const char *const forbidden_sb_flag[] = { /* * Check for a common mount option that manipulates s_flags. */ -static int vfs_parse_sb_flag(struct fs_context *fc, const char *key) +static int vfs_parse_sb_flag(struct fs_context *fc, struct fs_parameter *param) { - unsigned int token; + const char *key = param->key; + unsigned int set, clear; unsigned int i; for (i = 0; i < ARRAY_SIZE(forbidden_sb_flag); i++) if (strcmp(key, forbidden_sb_flag[i]) == 0) return -EINVAL; - token = lookup_constant(common_set_sb_flag, key, 0); - if (token) { - fc->sb_flags |= token; - fc->sb_flags_mask |= token; - return 0; - } + set = lookup_constant(common_set_sb_flag, key, 0); + clear = lookup_constant(common_clear_sb_flag, key, 0); + if (!set && !clear) + return -ENOPARAM; - token = lookup_constant(common_clear_sb_flag, key, 0); - if (token) { - fc->sb_flags &= ~token; - fc->sb_flags_mask |= token; - return 0; - } + if (param->type != fs_value_is_flag) + return invalf(fc, "%s: Unexpected value for '%s'", + fc->fs_type->name, param->key); - return -ENOPARAM; + fc->sb_flags |= set; + fc->sb_flags &= ~clear; + fc->sb_flags_mask |= set | clear; + return 0; } /** @@ -130,7 +129,7 @@ int vfs_parse_fs_param(struct fs_context *fc, struct fs_parameter *param) if (!param->key) return invalf(fc, "Unnamed parameter\n"); - ret = vfs_parse_sb_flag(fc, param->key); + ret = vfs_parse_sb_flag(fc, param); if (ret != -ENOPARAM) return ret; From patchwork Thu Nov 28 15:59:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266329 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 440A0112B for ; Thu, 28 Nov 2019 15:59:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 25704217AB for ; Thu, 28 Nov 2019 15:59:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LZx2U7KT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbfK1P75 (ORCPT ); Thu, 28 Nov 2019 10:59:57 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:38604 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726729AbfK1P7y (ORCPT ); Thu, 28 Nov 2019 10:59:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=89FU53QP+FVdCHuWN3syk61UhVN7dJid03CYqivJN7g=; b=LZx2U7KTBUUCsHYgKxhLAIRXqeyyl1wxnMxIkhw2MgBAIeE+LNG0i8JpkxkHy2Sp/ObKHc wah1Fdq8Fovwf5+6sNso6V0Dk/7ssec1JizKHaA6Z4JZuJBNklkgU0Usagob+GV7+nfU0M K+wwg5GhvYOw5Eh02le8n1MiKaVp7rQ= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-429-wH_SnTZfPnGEZNOAUgd1Vw-1; Thu, 28 Nov 2019 10:59:49 -0500 Received: by mail-wm1-f71.google.com with SMTP id v8so3709101wml.4 for ; Thu, 28 Nov 2019 07:59:48 -0800 (PST) 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=We7AjSpHB0jAIiAGPVmWNU/mWAeg9C5/h8gzjyUehfM=; b=rJv46ixGe2abyWqzWhwxtEERgLUOiuR9dxJ4IbbL0XjpGXyGLrp1xbNsfWxwtTem2U VLZu5vd9TB7ZgV8WwE5CmQQpRVji8tHIwkutH0xFiRm4zp+Ywk8vS9+Jv3iZAxmA8Syf LPTLsnCUDTFTLiFtvOqqFzFtqMPB4NfbgI9ZtM4+VztleD+nwMs8tURUmRlbCnCRv55a 02bmPYws7z4W8Vh8h1UV1L0D6TJikK3nD824dPA/IokehFDchKJtD9mZVgaAgcfy1hu7 Oueo1Hz1TgHQbzjnO/UzqW/liU3uDW/MLSMk/PcACWD6gHKsUfhL+TTZEoivjkTovlUA nwZg== X-Gm-Message-State: APjAAAU5Ah4Q3oxz6Q7zVzH1ZFLpY3YlJUksPjpqc9VMoNIZeOI4KaGq 76cj6Z0jPk1nIDmu+lI1N0Ap0nCh9wZUgRqyiJU9Q6H4Zoz/juw3ganx8MgPHEUK0Di7vkSk++X JWxlsBD6jnhmfdzWUrI9Jm423xQ== X-Received: by 2002:a05:6000:104:: with SMTP id o4mr18321003wrx.309.1574956788030; Thu, 28 Nov 2019 07:59:48 -0800 (PST) X-Google-Smtp-Source: APXvYqxZlM1qNOSuQ0BjA6Dge73Z5zincJX0ZfyB62XBUZ05W3bav2LiNzP/KI8T9gSRKH3uWCXhlA== X-Received: by 2002:a05:6000:104:: with SMTP id o4mr18320980wrx.309.1574956787755; Thu, 28 Nov 2019 07:59:47 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:47 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org, David Howells , Michael Kerrisk Subject: [PATCH 04/12] uapi: deprecate STATX_ALL Date: Thu, 28 Nov 2019 16:59:32 +0100 Message-Id: <20191128155940.17530-5-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: wH_SnTZfPnGEZNOAUgd1Vw-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Constants of the *_ALL type can be actively harmful due to the fact that developers will usually fail to consider the possible effects of future changes to the definition. Deprecate STATX_ALL in the uapi, while no damage has been done yet. We could keep something like this around in the kernel, but there's actually no point, since all filesystems should be explicitly checking flags that they support and not rely on the VFS masking unknown ones out: a flag could be known to the VFS, yet not known to the filesystem. Signed-off-by: Miklos Szeredi Cc: David Howells Cc: Michael Kerrisk --- fs/stat.c | 1 - include/uapi/linux/stat.h | 11 ++++++++++- samples/vfs/test-statx.c | 2 +- tools/include/uapi/linux/stat.h | 11 ++++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index c38e4c2e1221..7899d15722a0 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -68,7 +68,6 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, memset(stat, 0, sizeof(*stat)); stat->result_mask |= STATX_BASIC_STATS; - request_mask &= STATX_ALL; query_flags &= KSTAT_QUERY_FLAGS; /* allow the fs to override these if it really wants to */ diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 7b35e98d3c58..ed456ac0f90d 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -148,9 +148,18 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ + #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ +#ifndef __KERNEL__ +/* + * This is deprecated, and shall remain the same value in the future. To avoid + * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME) + * instead. + */ +#define STATX_ALL 0x00000fffU +#endif + /* * Attributes to be found in stx_attributes and masked in stx_attributes_mask. * diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c index a3d68159fb51..76c577ea4fd8 100644 --- a/samples/vfs/test-statx.c +++ b/samples/vfs/test-statx.c @@ -216,7 +216,7 @@ int main(int argc, char **argv) struct statx stx; int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW; - unsigned int mask = STATX_ALL; + unsigned int mask = STATX_BASIC_STATS | STATX_BTIME; for (argv++; *argv; argv++) { if (strcmp(*argv, "-F") == 0) { diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h index 7b35e98d3c58..ed456ac0f90d 100644 --- a/tools/include/uapi/linux/stat.h +++ b/tools/include/uapi/linux/stat.h @@ -148,9 +148,18 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ + #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ +#ifndef __KERNEL__ +/* + * This is deprecated, and shall remain the same value in the future. To avoid + * confusion please use the equivalent (STATX_BASIC_STATS | STATX_BTIME) + * instead. + */ +#define STATX_ALL 0x00000fffU +#endif + /* * Attributes to be found in stx_attributes and masked in stx_attributes_mask. * From patchwork Thu Nov 28 15:59:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AD29112B for ; Thu, 28 Nov 2019 15:59:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7B49E217D7 for ; Thu, 28 Nov 2019 15:59:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VIHLCA+9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726702AbfK1P7x (ORCPT ); Thu, 28 Nov 2019 10:59:53 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:57970 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726729AbfK1P7w (ORCPT ); Thu, 28 Nov 2019 10:59:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YjAad0xTPYZMQK4+SFhaX2rD4NfE+U8u/1/zOVVncQQ=; b=VIHLCA+9oVXkZrTZpw1T67kG2X8eyeWKA4gBTx1F6slGeeHbjNxaTdHnsuGQ1GOXlzPRBc yJnIJAFVcICknA5IkPha/ederN7AFMGCHsaIrAcCM/qCIZaxj3Cy5jeMjmpnyhwq00zrKD b0i96a3mQLZHZPFv6lBheqgAVT9KJ/U= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-p0Z6hHR9Nc-4ic_oV9vpCQ-1; Thu, 28 Nov 2019 10:59:50 -0500 Received: by mail-wr1-f71.google.com with SMTP id h30so463148wrh.5 for ; Thu, 28 Nov 2019 07:59:50 -0800 (PST) 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=DR6cgU4eXMRJbinjgGr1odh7ZKMuSb0Fdk7Mm6wgT3U=; b=bczB7we/VCaIEqOSrpDCOhUhh4PenMjgyiNxbAIZKaas4SZczOhoLd4IotWTNP2WJX Mdy50gHWiVh6AdrOYXI6U8h6E66FRT93QMqmjf+IEATAojWc0EvWmprUejztyuTdAZGv w85ycEeFVbExUIYFRj8D9/nO8Upfe+sLRs4Q0ooZ8MfspquWr5YQokd1o+TPNYJa2NVJ Fqeo2bie185kZ3QP0me5Kjatm1yUCHgenu4Da5BEwF1JM9aHzBGVOjBk9lwJa+FP/o2e v62ZmquzWWDN0BZ9ns/f3qKnQF8gScn3MbF3VHcsiCd3EkTrehOqUC3IbV8rnxxjxkQD d3oQ== X-Gm-Message-State: APjAAAU/zLB84UkYYGKpv+q7KfsJIqyHmZE6zFhVUYc0GvCJE7/OEm5H DMfT2gG+bPJ1KE2h+9JegdFOTDwNsO/OSmLN+/IH74Qu+4LJ5eOSmTvLIaTqEMsoadkL/LlMKoH nrpEvbP32+gu9hgoGsFTwNVmjig== X-Received: by 2002:a05:600c:21c6:: with SMTP id x6mr9865933wmj.156.1574956789154; Thu, 28 Nov 2019 07:59:49 -0800 (PST) X-Google-Smtp-Source: APXvYqw9Ja5EmD8kfcoo8o1Dw+rBaxWXK7/AviWnaeBcvYyKsi/5kRC/jyE1eh1lVl5NtFHEYBdn+Q== X-Received: by 2002:a05:600c:21c6:: with SMTP id x6mr9865922wmj.156.1574956788935; Thu, 28 Nov 2019 07:59:48 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:48 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org, David Howells Subject: [PATCH 05/12] statx: don't clear STATX_ATIME on SB_RDONLY Date: Thu, 28 Nov 2019 16:59:33 +0100 Message-Id: <20191128155940.17530-6-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: p0Z6hHR9Nc-4ic_oV9vpCQ-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org IS_NOATIME(inode) is defined as __IS_FLG(inode, SB_RDONLY|SB_NOATIME), so generic_fillattr() will clear STATX_ATIME from the result_mask if the super block is marked read only. This was probably not the intention, so fix to only clear STATX_ATIME if the fs doesn't support atime at all. Signed-off-by: Miklos Szeredi Acked-by: David Howells --- fs/stat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/stat.c b/fs/stat.c index 7899d15722a0..fc49f705a83c 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -71,7 +71,8 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, query_flags &= KSTAT_QUERY_FLAGS; /* allow the fs to override these if it really wants to */ - if (IS_NOATIME(inode)) + /* SB_NOATIME means filesystem supplies dummy atime value */ + if (inode->i_sb->s_flags & SB_NOATIME) stat->result_mask &= ~STATX_ATIME; if (IS_AUTOMOUNT(inode)) stat->attributes |= STATX_ATTR_AUTOMOUNT; From patchwork Thu Nov 28 15:59:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266325 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67B4D138C for ; Thu, 28 Nov 2019 15:59:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 46D5D2178F for ; Thu, 28 Nov 2019 15:59:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SCOQkmKt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726856AbfK1P7z (ORCPT ); Thu, 28 Nov 2019 10:59:55 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:31235 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726835AbfK1P7y (ORCPT ); Thu, 28 Nov 2019 10:59:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=++SFQmyMsWq4exmbdoSpQ2cr72U0QKtKCLX6290nr5k=; b=SCOQkmKti1yqzW9VzRLqKLDzaHBYHQmui4g1ff3uAlD7+T+ZnCHFaOynTVcS8w7sLcMt7U nY+nlFt+lK8lMn75AilAN8kZd3GjH1afbizYHDZgUoULzR9BPF2k/L0A+UgS6CP5Qtrg3M n4t5aRyO/ButMbv7I+9FWnAloLqwjuA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79-tZeNVJVOPcOQ4X-6stlOwA-1; Thu, 28 Nov 2019 10:59:51 -0500 Received: by mail-wr1-f72.google.com with SMTP id k15so13976866wrp.22 for ; Thu, 28 Nov 2019 07:59:51 -0800 (PST) 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=WV43MHYixZY7eKNI8jC3xjsYFEcLSUPr+KYHrksoiEI=; b=FuzLXfFVlt5rX5YZuPnKw/ZqDEkPuYsaYCdcXWRcwqtqqAdpmsS/jyBWo6ycSXfy3R NiFd1IzCJjt7yZvpM9MbOxK/Vi+NeF1j8uyenzNxhsT6FVARFAwwnbtnZuKxKPjv74yR 5fvR4AMSv45l6f3rfs2S/7gWMbALNVqO74su9O3HwJVyuoWasoFBQXdtQFaD+tC/N0ZT xpNtHHjrILzwov1a3n/LaRpXcCoOsRR9UAW/BENKPBAkq5gQY5N8I3Va+UsKXoQBoICc 76RPcDo3MJ3nrsICT3rN3crulJHpva9bOwPygcsY3a0M41trg1JFdMkZknSh0LKVaTn8 IGsg== X-Gm-Message-State: APjAAAWmXMAjl/5t3majy+xTcMbWUgUE8ImzuEn4hgZheEuX0iSIUEmC yW7tBG/UCa35TxTki/8R/ei0qg29Y3MjZRVcp/g3ZQ2dt034gYVL6okefXQmf+LKdJp7DaAcjV+ YxpCIAr3cmxmIvsPIBSg/wMHcTQ== X-Received: by 2002:adf:ea42:: with SMTP id j2mr12177102wrn.270.1574956790350; Thu, 28 Nov 2019 07:59:50 -0800 (PST) X-Google-Smtp-Source: APXvYqwp5bvhWAOaiRuMR96ArIY/Y981BLL4CkQKEnXAsc167f7gqMcg3rP2HUwxNCAGZc8eO4RAaA== X-Received: by 2002:adf:ea42:: with SMTP id j2mr12177091wrn.270.1574956790118; Thu, 28 Nov 2019 07:59:50 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:49 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 06/12] utimensat: AT_EMPTY_PATH support Date: Thu, 28 Nov 2019 16:59:34 +0100 Message-Id: <20191128155940.17530-7-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: tZeNVJVOPcOQ4X-6stlOwA-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This makes it possible to use utimensat on an O_PATH file (including symlinks). It supersedes the nonstandard utimensat(fd, NULL, ...) form. Signed-off-by: Miklos Szeredi --- fs/utimes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/utimes.c b/fs/utimes.c index 1ba3f7883870..c07cb0dddbb6 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -95,13 +95,13 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, goto out; } - if (flags & ~AT_SYMLINK_NOFOLLOW) + if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_EMPTY_PATH)) goto out; if (filename == NULL && dfd != AT_FDCWD) { struct fd f; - if (flags & AT_SYMLINK_NOFOLLOW) + if (flags) goto out; f = fdget(dfd); @@ -117,6 +117,8 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, if (!(flags & AT_SYMLINK_NOFOLLOW)) lookup_flags |= LOOKUP_FOLLOW; + if (flags & AT_EMPTY_PATH) + lookup_flags |= LOOKUP_EMPTY; retry: error = user_path_at(dfd, filename, lookup_flags, &path); if (error) From patchwork Thu Nov 28 15:59:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266331 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA3F113A4 for ; Thu, 28 Nov 2019 15:59:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA7B12178F for ; Thu, 28 Nov 2019 15:59:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YiiZ2ahr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbfK1P75 (ORCPT ); Thu, 28 Nov 2019 10:59:57 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:35972 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726858AbfK1P74 (ORCPT ); Thu, 28 Nov 2019 10:59:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956795; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wNUceLOrPg3Ojt0+jzV1YE7ipnujQFhaT5nWXOsQUC8=; b=YiiZ2ahruH3Qrumm6OkN+xYBbpJW6ckXdmuXyxKwVBzarA2CoN2mx5v4gTPQUjzRcl3Rai 34nEFFUMHsGRPUWlTHeSNJXZMGj/CyZz/wSKH94JOzQ3jeWPY9IMOxH/YSZkUhJN0gMd7p 8eX6FNGZBgfm+YHHFSIxtjLkr9bJpTY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-6LABOQRdPdOjV5JHgGlyOA-1; Thu, 28 Nov 2019 10:59:52 -0500 Received: by mail-wr1-f71.google.com with SMTP id c12so12751347wrq.7 for ; Thu, 28 Nov 2019 07:59:52 -0800 (PST) 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=6FebG/9swWxaWpyYUPZp3GybSxxVwd4FC4Ek6DX6CHk=; b=GugPghNFPuaWha1NTKcWXy6E/XF9lVNrASp0n7WMK9ALvBrcm2RUZs3NiGDyCiy7AD G2CY3xqi5CHFzNo7M4EBfjv8fajkhzaEOa2GmQBBre1mK9iWlQLq+Jd/tU+zZsra2sXx St4VH4U2/4M4QYyrpCNVKgV6mlWVQVX2KHHFmrVRt1KQPRCVWmKNoQtsQPRioRcb39We vEUXX/mXEz4pfSu7ApthMeAqAosbPaeWZWfe6ecyWT9MsoIcecJvEOwoxEb8NmnDDrYZ /IUCBZ/LEirsYfFGyi+yEjVLCeSp+ETNtnBUL/lIX0K1UDo+Kdxu23G0bhNsekRRrAqB Vg3w== X-Gm-Message-State: APjAAAU5zUA46uijr743WZ6nUMn3y59pz+lmH/ntduL/15CXJ76bapzr 3+J8SZIcUqKBG5P5/Q1PrQrkrmxR4DsAqPhkwaKfQ4igBy41Cb4da6OpX1D7+qWq7IqRL+zLMDX 8zIx1b9oyfQeYcEyYZZafKoa8Uw== X-Received: by 2002:a05:6000:149:: with SMTP id r9mr9469817wrx.147.1574956791688; Thu, 28 Nov 2019 07:59:51 -0800 (PST) X-Google-Smtp-Source: APXvYqzIdXC8BX5EGsOQHtObeNRf8i4Cuwph0s8VBTuzdjw7D1anaxGwXrq6M3ONrwiABcsmwrnDJQ== X-Received: by 2002:a05:6000:149:: with SMTP id r9mr9469808wrx.147.1574956791513; Thu, 28 Nov 2019 07:59:51 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:50 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 07/12] f*xattr: allow O_PATH descriptors Date: Thu, 28 Nov 2019 16:59:35 +0100 Message-Id: <20191128155940.17530-8-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: 6LABOQRdPdOjV5JHgGlyOA-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This allows xattr ops on symlink/special files referenced by an O_PATH descriptor without having to play games with /proc/self/fd/NN (which doesn't work for symlinks anyway). This capability is the same as would be given by introducing ...at() variants with an AT_EMPTY_PATH argument. Looking at getattr/setattr type syscalls, this is allowed for fstatat() and fchownat(), but not for fchmodat() and utimensat(). What's the logic? While this carries a minute risk of someone relying on the property of xattr syscalls rejecting O_PATH descriptors, it saves the trouble of introducing another set of syscalls. Only file->f_path and file->f_inode are accessed in these functions. Current versions return EBADF, hence easy to detect the presense of this feature and fall back in case it's missing. Signed-off-by: Miklos Szeredi --- fs/xattr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/xattr.c b/fs/xattr.c index 90dd78f0eb27..fd1335b86e60 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -495,7 +495,7 @@ SYSCALL_DEFINE5(lsetxattr, const char __user *, pathname, SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, const void __user *,value, size_t, size, int, flags) { - struct fd f = fdget(fd); + struct fd f = fdget_raw(fd); int error = -EBADF; if (!f.file) @@ -587,7 +587,7 @@ SYSCALL_DEFINE4(lgetxattr, const char __user *, pathname, SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, void __user *, value, size_t, size) { - struct fd f = fdget(fd); + struct fd f = fdget_raw(fd); ssize_t error = -EBADF; if (!f.file) @@ -662,7 +662,7 @@ SYSCALL_DEFINE3(llistxattr, const char __user *, pathname, char __user *, list, SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) { - struct fd f = fdget(fd); + struct fd f = fdget_raw(fd); ssize_t error = -EBADF; if (!f.file) @@ -727,7 +727,7 @@ SYSCALL_DEFINE2(lremovexattr, const char __user *, pathname, SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) { - struct fd f = fdget(fd); + struct fd f = fdget_raw(fd); int error = -EBADF; if (!f.file) From patchwork Thu Nov 28 15:59:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266335 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EC5913A4 for ; Thu, 28 Nov 2019 16:00:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2F952178F for ; Thu, 28 Nov 2019 15:59:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="A8r0PvBr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726920AbfK1P77 (ORCPT ); Thu, 28 Nov 2019 10:59:59 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44051 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726858AbfK1P76 (ORCPT ); Thu, 28 Nov 2019 10:59:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956797; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QILxa7RqQYQ4IyTulj5DZou1wI9mDMu/Shz+xSIroTs=; b=A8r0PvBrVe8EhL3tilrJ1K3uMf94IXNji7pxYaQm2BcxEDyGFV3XnXsLEMbEOHu0V+ji/6 GBBkUTf3LTc+jiFxcW4DSddsQ0S7oe0kI3i3Wp+SrYXiIVG2YUoHliP2aaTwv1TlnkDeOT bHZEeSJq6eQ4D8pHOAgUqyvCFVwL0co= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-361-FcMKHSRyMM6LZBw52qj76Q-1; Thu, 28 Nov 2019 10:59:53 -0500 Received: by mail-wm1-f72.google.com with SMTP id z3so3718421wmk.1 for ; Thu, 28 Nov 2019 07:59:53 -0800 (PST) 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=+mLHdhKK+RTjZWJLR+Q9KPjFkxVfyw86WO5G8timrLo=; b=a33D/qDn5FQ3GkBj8iOO8cKoQpppqYCLB7hrz6jxKezcrACKr1eNemBm36dN3OdcOV ARnpGZRXHFljchAWdA5AdzxDKtFgN58S+ZnS6Dppd0ITsAp1vvRs9UH8D6hgCT7XGVeD Vh7kO+WBwYKemCjylxSrfNo0LkhRI+NTb6EviOg5I8OJDNh+qkA7X5NQpl6wbNK6n+Ud t8l4yvk66J6rMnXgZyRUh/JEbfZdWG0SEHCJg9juWKcFi2ogq4KAzFT25PTpKLxq8Wrk sYmKkfSvQ4jyl9SeV6vo0KBZp65XFXD+Fo0nNINTxirBMz4amrNF7+CsfBJjk4ue4XiR er3w== X-Gm-Message-State: APjAAAUx9/B5vdzFGBVcV4ghUmk0U6MQKF4zbHi1y5pkNMcwIwLXz33Z uDIl2+h5yDwWvu8A7PhNhBgtfiouRtnCbV1Dl5sdwZcGq7nF2F9AHKekY72PvYpuka6WA3VR0Qp haId0noZ0LSSs10oxScpXJ6YeSw== X-Received: by 2002:a7b:c75a:: with SMTP id w26mr10019157wmk.18.1574956792794; Thu, 28 Nov 2019 07:59:52 -0800 (PST) X-Google-Smtp-Source: APXvYqxfmGPafxnlfmoHK2fzycvAIcMrBZnABeqhb58fIBrDg5cokgJlyiyeWUs5sVPkhJkM5be0XA== X-Received: by 2002:a7b:c75a:: with SMTP id w26mr10019140wmk.18.1574956792568; Thu, 28 Nov 2019 07:59:52 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:51 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 08/12] vfs: allow unprivileged whiteout creation Date: Thu, 28 Nov 2019 16:59:36 +0100 Message-Id: <20191128155940.17530-9-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: FcMKHSRyMM6LZBw52qj76Q-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Whiteouts are special, but unlike real device nodes they should not require privileges to create. The 0 char device number should already be reserved, but make this explicit in cdev_add() to be on the safe side. Signed-off-by: Miklos Szeredi --- fs/char_dev.c | 3 +++ fs/namei.c | 17 ++++------------- include/linux/device_cgroup.h | 3 +++ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/char_dev.c b/fs/char_dev.c index 00dfe17871ac..8bf66f40e5e0 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -483,6 +483,9 @@ int cdev_add(struct cdev *p, dev_t dev, unsigned count) p->dev = dev; p->count = count; + if (WARN_ON(dev == WHITEOUT_DEV)) + return -EBUSY; + error = kobj_map(cdev_map, dev, count, NULL, exact_match, exact_lock, p); if (error) diff --git a/fs/namei.c b/fs/namei.c index 671c3c1a3425..05ca98595b62 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -3687,12 +3687,14 @@ EXPORT_SYMBOL(user_path_create); int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) { + bool is_whiteout = S_ISCHR(mode) && dev == WHITEOUT_DEV; int error = may_create(dir, dentry); if (error) return error; - if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD)) + if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD) && + !is_whiteout) return -EPERM; if (!dir->i_op->mknod) @@ -4527,9 +4529,6 @@ static int do_renameat2(int olddfd, const char __user *oldname, int newdfd, (flags & RENAME_EXCHANGE)) return -EINVAL; - if ((flags & RENAME_WHITEOUT) && !capable(CAP_MKNOD)) - return -EPERM; - if (flags & RENAME_EXCHANGE) target_flags = 0; @@ -4667,15 +4666,7 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna int vfs_whiteout(struct inode *dir, struct dentry *dentry) { - int error = may_create(dir, dentry); - if (error) - return error; - - if (!dir->i_op->mknod) - return -EPERM; - - return dir->i_op->mknod(dir, dentry, - S_IFCHR | WHITEOUT_MODE, WHITEOUT_DEV); + return vfs_mknod(dir, dentry, S_IFCHR | WHITEOUT_MODE, WHITEOUT_DEV); } EXPORT_SYMBOL(vfs_whiteout); diff --git a/include/linux/device_cgroup.h b/include/linux/device_cgroup.h index 8557efe096dc..fc989487c273 100644 --- a/include/linux/device_cgroup.h +++ b/include/linux/device_cgroup.h @@ -62,6 +62,9 @@ static inline int devcgroup_inode_mknod(int mode, dev_t dev) if (!S_ISBLK(mode) && !S_ISCHR(mode)) return 0; + if (S_ISCHR(mode) && dev == WHITEOUT_DEV) + return 0; + if (S_ISBLK(mode)) type = DEVCG_DEV_BLOCK; else From patchwork Thu Nov 28 15:59:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266333 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5011112B for ; Thu, 28 Nov 2019 15:59:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 850ED217AB for ; Thu, 28 Nov 2019 15:59:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aq2omIAb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726917AbfK1P76 (ORCPT ); Thu, 28 Nov 2019 10:59:58 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:44297 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726712AbfK1P76 (ORCPT ); Thu, 28 Nov 2019 10:59:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ck3CGcsbIlV1eLwTtb+TK98Otth3loJAT1/eFW2z+l8=; b=aq2omIAbxndSlqtOIS5pkY5VOPbCqvP0sUU5U0yxOjSA0nhv7/hcWwmz/KZRhUjPYNtGxL s2w5RuWD1ts17YA5f56edM9zoZk4/iKyK1mYog4NfCK0hKZMYmfBUX5wP4TDv6EiohHC9e wk3AFm97AgOBblG7fC/Hr3emIvq8idU= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30--q56V2ORPsalrDzBMYv67w-1; Thu, 28 Nov 2019 10:59:55 -0500 Received: by mail-wr1-f72.google.com with SMTP id q12so14088426wrr.3 for ; Thu, 28 Nov 2019 07:59:55 -0800 (PST) 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=2zb08hFIl2dEvNnYnKVL3DjSRjWIXjJoqltqFs5pNp4=; b=BcNrLzI0316BjVM+SFkVjtvp3ZD1YSjNQZEoK46kBA2C6n3brknZXVLnOkv0gqMIsj sFy8k0XEgIIeDWezI3O1Vbpm7p7lC+88R5xvL3IdIZL7Idj1YG5ZFi2PI1q7YG+0zXK0 3a2mxuygYJgMazxl4ja4fnsyxpdR0VoNgKTS3RrglBVhEOuw5p1kfpjVtbaDo0e+A1/u V2SDj+1MS1rJUTsxeJZbj1ats1fixOE0wRK0ZkafXDSHBCvS7b6C4dDbIxp3z9srVev9 M0f902eZ16xUcmWWvEEIIKrXn0yMsWjXjwN2fit6NgURzYJfVJWfjqPJqys3HfJBuvCt mywg== X-Gm-Message-State: APjAAAU1QzseR6eSf/cdzC0dyT9ZRf5I0KKVKw/jcev1fTcdjwITmAzt sU0hvHhEhcOvw9gFWQp7WvjkUl+CW7qEDCRJjN6uhzEt2zGDJy2sDpHOGCGWVWJ3mb/GPT7cRUa ORhMw9RL3fLyTyl+aQNtEyuZBHw== X-Received: by 2002:a7b:c308:: with SMTP id k8mr9843875wmj.32.1574956793893; Thu, 28 Nov 2019 07:59:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzfjPn0TXdy3nlaNUSJmNOOLqdDmN4Tipus585eAFxYi4o+vVXL14/kuCcAFuYAwwXrzmpZDg== X-Received: by 2002:a7b:c308:: with SMTP id k8mr9843857wmj.32.1574956793647; Thu, 28 Nov 2019 07:59:53 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:52 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 09/12] fs_parser: "string" with missing value is a "flag" Date: Thu, 28 Nov 2019 16:59:37 +0100 Message-Id: <20191128155940.17530-10-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: -q56V2ORPsalrDzBMYv67w-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org There's no such thing as a NULL string value, the fsconfig(2) syscall rejects that outright. So get rid of that concept from the implementation. Signed-off-by: Miklos Szeredi Signed-off-by: Al Viro --- fs/fs_context.c | 2 +- fs/fs_parser.c | 9 ++------- include/linux/fs_parser.h | 1 - 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 66fd7d753e91..7c4216156950 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -174,7 +174,7 @@ int vfs_parse_fs_string(struct fs_context *fc, const char *key, struct fs_parameter param = { .key = key, - .type = fs_value_is_string, + .type = v_size ? fs_value_is_string : fs_value_is_flag, .size = v_size, }; diff --git a/fs/fs_parser.c b/fs/fs_parser.c index 5d8833d71b37..70f95a71f5aa 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -85,7 +85,6 @@ int fs_parse(struct fs_context *fc, const struct fs_parameter_enum *e; int ret = -ENOPARAM, b; - result->has_value = !!param->string; result->negated = false; result->uint_64 = 0; @@ -95,7 +94,7 @@ int fs_parse(struct fs_context *fc, * "xxx" takes the "no"-form negative - but only if there * wasn't an value. */ - if (result->has_value) + if (param->type != fs_value_is_flag) goto unknown_parameter; if (param->key[0] != 'n' || param->key[1] != 'o' || !param->key[2]) goto unknown_parameter; @@ -146,8 +145,7 @@ int fs_parse(struct fs_context *fc, */ switch (p->type) { case fs_param_is_flag: - if (param->type != fs_value_is_flag && - (param->type != fs_value_is_string || result->has_value)) + if (param->type != fs_value_is_flag) return invalf(fc, "%s: Unexpected value for '%s'", desc->name, param->key); result->boolean = true; @@ -208,9 +206,6 @@ int fs_parse(struct fs_context *fc, case fs_param_is_fd: { switch (param->type) { case fs_value_is_string: - if (!result->has_value) - goto bad_value; - ret = kstrtouint(param->string, 0, &result->uint_32); break; case fs_value_is_file: diff --git a/include/linux/fs_parser.h b/include/linux/fs_parser.h index dee140db6240..45323203128b 100644 --- a/include/linux/fs_parser.h +++ b/include/linux/fs_parser.h @@ -72,7 +72,6 @@ struct fs_parameter_description { */ struct fs_parse_result { bool negated; /* T if param was "noxxx" */ - bool has_value; /* T if value supplied to param */ union { bool boolean; /* For spec_bool */ int int_32; /* For spec_s32/spec_enum */ From patchwork Thu Nov 28 15:59:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266341 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF1DD138C for ; Thu, 28 Nov 2019 16:00:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8E9FB2178F for ; Thu, 28 Nov 2019 16:00:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WZIhnztm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726934AbfK1QAB (ORCPT ); Thu, 28 Nov 2019 11:00:01 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:53117 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726925AbfK1QAB (ORCPT ); Thu, 28 Nov 2019 11:00:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=y39lZsVZHuhPyWXb740EF8gnxzvNlaCwgKDc+KonpnM=; b=WZIhnztmqUO3Cvo4/nkmzDvfk4d3Tj47HNeHhBpzjervLzqSa87lAUhNKUr9uohCStR6rh ZV/+yZzRd8RhUR8zjgjnM/cp2WaTjPWvF1oBW815MK+dtjLOTr/Yvj2akD5eevsjivd5nE JVDBJCB8F9KZ7KBBx74fHHyzTVm7ONU= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-286-Dn14S4JbOn-KIXLPcylT0A-1; Thu, 28 Nov 2019 10:59:56 -0500 Received: by mail-wr1-f70.google.com with SMTP id e3so13998242wrs.17 for ; Thu, 28 Nov 2019 07:59:56 -0800 (PST) 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=Ik0ZUtk1c8r6nX2SEPD8HgOLKaGSa5p4WfaTbeuYH3g=; b=CDVDQhjUnF/dkRCjHK2c3MS1WQQ71WrKhXXZSbDzJm58/MyKgeICTSMIdn4l1sCfdE oYs88Sh3ucfOI49+G4WXLXsJhBYujS0P2IyyhUO5P1aPXzHemUbwbLgmuhH+ZYF5j4ll o8F8uGA/4dB4Vc0NqNg+Kn6UFFEIFRWGTuRM0EAwaXUtWYqe6JqwF+extUfVHh6pix18 kVQi/0zKkO1N+wL8l7nU3K5VRymqvIMcUvSnaUnZ01Smzb8eBwzvVf+tL4zfk/Ce2m6s jLc4dcC/qK6EVL8Zrzqm2tmvyL7j2yCcOtOdBqWKBqwxtvpOMdCuU+lFnYhftEggRHxa gErA== X-Gm-Message-State: APjAAAUElagIN0FlDzxa5h+2+fW/KcyurCp1lEcD8bQdLd3P0yYyUMM6 5CT8BwocQ8/5KnJDvhkug2jHjdgBCYdLRb1c4OaTN0KOaK6SnrjFXuS3wo6zNs1yskWR9jhWXNh 6EJ0uqPa3kLmucYsLtHBgLMOG9Q== X-Received: by 2002:a7b:c34a:: with SMTP id l10mr10713127wmj.66.1574956795122; Thu, 28 Nov 2019 07:59:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwHQIEsj+TNUvhi4cSh1njF1NPbOENAgBMjHq1jUjHHNMvW4ZlC9nmXZP9aFRlxsPn7O0VvHw== X-Received: by 2002:a7b:c34a:: with SMTP id l10mr10713116wmj.66.1574956794963; Thu, 28 Nov 2019 07:59:54 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:54 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 10/12] vfs: don't parse forbidden flags Date: Thu, 28 Nov 2019 16:59:38 +0100 Message-Id: <20191128155940.17530-11-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: Dn14S4JbOn-KIXLPcylT0A-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Makes little sense to keep this blacklist synced with what mount(8) parses and what it doesn't. E.g. it has various forms of "*atime" options, but not "atime"... Signed-off-by: Miklos Szeredi --- fs/fs_context.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 7c4216156950..394a05bc03d5 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -55,29 +55,6 @@ static const struct constant_table common_clear_sb_flag[] = { { "silent", SB_SILENT }, }; -static const char *const forbidden_sb_flag[] = { - "bind", - "dev", - "exec", - "move", - "noatime", - "nodev", - "nodiratime", - "noexec", - "norelatime", - "nostrictatime", - "nosuid", - "private", - "rec", - "relatime", - "remount", - "shared", - "slave", - "strictatime", - "suid", - "unbindable", -}; - /* * Check for a common mount option that manipulates s_flags. */ @@ -85,11 +62,6 @@ static int vfs_parse_sb_flag(struct fs_context *fc, struct fs_parameter *param) { const char *key = param->key; unsigned int set, clear; - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(forbidden_sb_flag); i++) - if (strcmp(key, forbidden_sb_flag[i]) == 0) - return -EINVAL; set = lookup_constant(common_set_sb_flag, key, 0); clear = lookup_constant(common_clear_sb_flag, key, 0); From patchwork Thu Nov 28 15:59:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266339 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 539A36C1 for ; Thu, 28 Nov 2019 16:00:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 340A22178F for ; Thu, 28 Nov 2019 16:00:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ddjeI/EB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfK1QAB (ORCPT ); Thu, 28 Nov 2019 11:00:01 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59749 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726446AbfK1QAA (ORCPT ); Thu, 28 Nov 2019 11:00:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EFSuAdge36j90fnmh0t8BSOJjNPmO3U6ihiE7GdWtqs=; b=ddjeI/EBitvtHSWqV5ApZXja2mV0ASWWV3QZ4Pb7AHwec6ZV2XgnbGTrix2vFe8FqZCxI1 QF7HYbYFjyt+4Bdp73RRw8EYlzqt942hqu6whvdAl/PlxlHSK9V0Gedq8DFwuSOjUDbHkr CNPwlwIgDikwY5fu+BTr3zxIAQ8+Ack= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-320-3q8sdrHtNaWPKUmTnE8NuQ-1; Thu, 28 Nov 2019 10:59:57 -0500 Received: by mail-wr1-f72.google.com with SMTP id h30so463328wrh.5 for ; Thu, 28 Nov 2019 07:59:57 -0800 (PST) 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=ZNKbpX5fym9wrjLit+gZRJvW4rINU1u/kj+585xqaFc=; b=A1AnVrPcJAK6p0ecFJG8gj8avY+RTzsy828yrrcLeBR6mRpPe+8mlpMtjw47CwjcIX nJccx5aUmM4lfOwtlP4iQMXkQfQi8zGveIOVT1v74j0550pjo54MX+iKRhLuhZ458Y5u eJLvY0DM/+VliSc2yaF+0JAubeb7yYN9NIxwHEbu+osP4RKZBIuXe0F3uxWyuNOQNjje N/TMMf0Zk+b8MwTl7/QQzOQoqOH4JNCwNoXgQ8siprAZ6eXFcr2+pjIUzOnyFdtyFEC+ fgZORt45cRCHTVCwaGjZ7r4K2c4d8zIbcf3t9AsyWLsVlwKrX/LojI8YbhRaF0dAodSA UPcg== X-Gm-Message-State: APjAAAXbUYO5rX4xc187ItrvTJFZIF5I7Xkjbdaon3VB8IuZjqJa0xzp f1+lTTe0OXQgP2I08f+1yy40ORspislGEZA//B9NIX0n2VHN851Usnj8puzRnH27A7mop8sb/s3 ziJlrBRGzKlAel+0ieseZvQwhjA== X-Received: by 2002:a1c:98c5:: with SMTP id a188mr10195541wme.133.1574956796447; Thu, 28 Nov 2019 07:59:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwCtXklvMs6tt6g5DAW+6yaax/wg1SawwnK348LRXf95SC2gR/TR6LVCoKCuP0MuHU6BX0wng== X-Received: by 2002:a1c:98c5:: with SMTP id a188mr10195524wme.133.1574956796214; Thu, 28 Nov 2019 07:59:56 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:55 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 11/12] vfs: don't parse "posixacl" option Date: Thu, 28 Nov 2019 16:59:39 +0100 Message-Id: <20191128155940.17530-12-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: 3q8sdrHtNaWPKUmTnE8NuQ-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Unlike the others, this is _not_ a standard option accepted by mount(8). In fact SB_POSIXACL is an internal flag, and accepting MS_POSIXACL on the mount(2) interface is possibly a bug. The only filesystem that apparently wants to handle the "posixacl" option is 9p, but it has special handling of that option besides setting SB_POSIXACL. Signed-off-by: Miklos Szeredi --- fs/fs_context.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 394a05bc03d5..738f59b6c06a 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -42,7 +42,6 @@ static const struct constant_table common_set_sb_flag[] = { { "dirsync", SB_DIRSYNC }, { "lazytime", SB_LAZYTIME }, { "mand", SB_MANDLOCK }, - { "posixacl", SB_POSIXACL }, { "ro", SB_RDONLY }, { "sync", SB_SYNCHRONOUS }, }; From patchwork Thu Nov 28 15:59:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 11266337 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 92DE2112B for ; Thu, 28 Nov 2019 16:00:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70E572178F for ; Thu, 28 Nov 2019 16:00:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AaNAmGYz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726933AbfK1QAA (ORCPT ); Thu, 28 Nov 2019 11:00:00 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:33366 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726858AbfK1QAA (ORCPT ); Thu, 28 Nov 2019 11:00:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574956799; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=urj6BsNEctMMzgxvFwi+FtsFZfU1h6uJQgdMA5TETx4=; b=AaNAmGYzs9qHLrmxEBMTArbhG3H2XDA1U1MChEfZEx7oXZK4ehI6U5nExZw/EFg4FRZu7Z Jl5SNdb0hXsdsTDx2JKLyBcYyYKNJTIgikaAn69dO9TA6klc8lwBq3EsyubjYfxEM4P/Zi L0Lf+NA75KLzRamWRIeKTUSMmsFpU5c= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-9-5GGJ3FVMOU-dlin_1-9zfw-1; Thu, 28 Nov 2019 10:59:58 -0500 Received: by mail-wr1-f70.google.com with SMTP id q6so14030253wrv.11 for ; Thu, 28 Nov 2019 07:59:58 -0800 (PST) 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=kDRPGIuZArrnDQtF7Sm8M5stZsvFzV8+7+mvKWGeK6Y=; b=LTjNupy1QFHNBgUDzJrHadaVLpkLvEIIWxpucXZhebv6nHsQN4x9LEWF8p9U1/vXXo Q170nfKY//Q9OjJIRZW//iHlkhHVeE8QgDL77rbTCATNCX+dxaTQhAKSIGMJ9h5j0uP+ tE+kfqOVEzZjoLE5mteuh2ECJ/P5yi79Y64pVH4V7w5scYfi9YahemAAsPE6LeXXxRf/ 5Q0b1rJ7Qq62Lvu76l8L2qlU+XAOl9kCjcqk3tyj2fqftipeQwpKCqlDi8VOX5hFS5yG eWps40uoAapUodIcSAInYc1C/rI/klmaRODW6JkBKx0PVXELZXF3SHyefcHn8MzWGzmj zqbw== X-Gm-Message-State: APjAAAWz/0DZXJY+Mg3r5lGPriwdQaUVtjOEZI3iqtwD818Tvrp8yiuE C1GKVXNGbk5BcBETLSVFJZjtHdbdRZC4pB0d/C9x3wuwiHeQLY8BqQ9DJSaRtCkfa2Z5aacg0Tz 83CtD7lutVo95GOpGVy0kcOZqVw== X-Received: by 2002:a05:600c:2113:: with SMTP id u19mr1994985wml.88.1574956797418; Thu, 28 Nov 2019 07:59:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzXZjkbtQIB36xZremjJphWCxmwWuFtydsrALi/pHuJ08RrgQCnqEz593F8+uAAXIZaMpBXBQ== X-Received: by 2002:a05:600c:2113:: with SMTP id u19mr1994966wml.88.1574956797219; Thu, 28 Nov 2019 07:59:57 -0800 (PST) Received: from miu.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id 2sm23689474wrq.31.2019.11.28.07.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:59:56 -0800 (PST) From: Miklos Szeredi To: Al Viro Cc: linux-fsdevel@vger.kernel.org Subject: [PATCH 12/12] vfs: don't parse "silent" option Date: Thu, 28 Nov 2019 16:59:40 +0100 Message-Id: <20191128155940.17530-13-mszeredi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191128155940.17530-1-mszeredi@redhat.com> References: <20191128155940.17530-1-mszeredi@redhat.com> MIME-Version: 1.0 X-MC-Unique: 5GGJ3FVMOU-dlin_1-9zfw-1 X-Mimecast-Spam-Score: 0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org While this is a standard option as documented in mount(8), it is ignored by most filesystems. So reject, unless filesystem explicitly wants to handle it. The exception is unconverted filesystems, where it is unknown if the filesystem handles this or not. Any implementation, such as mount(8), that needs to parse this option without failing can simply ignore the return value from fsconfig(). Signed-off-by: Miklos Szeredi --- fs/fs_context.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 738f59b6c06a..b37ce07ee230 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -51,7 +51,6 @@ static const struct constant_table common_clear_sb_flag[] = { { "nolazytime", SB_LAZYTIME }, { "nomand", SB_MANDLOCK }, { "rw", SB_RDONLY }, - { "silent", SB_SILENT }, }; /* @@ -530,6 +529,15 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param) unsigned int size = ctx->data_size; size_t len = 0; + if (strcmp(param->key, "silent") == 0) { + if (param->type != fs_value_is_flag) + return invalf(fc, "%s: Unexpected value for '%s'", + fc->fs_type->name, param->key); + + fc->sb_flags |= SB_SILENT; + return 0; + } + if (strcmp(param->key, "source") == 0) { if (param->type != fs_value_is_string) return invalf(fc, "VFS: Legacy: Non-string source");