Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1524181img; Tue, 19 Mar 2019 09:24:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrBR8e06woC+zL7ju+QkbT2xMm3UlUGHHRPFBWhuUaSu9qIlnxGrvbSC40milnsxY72kPy X-Received: by 2002:a65:6154:: with SMTP id o20mr2593360pgv.205.1553012690743; Tue, 19 Mar 2019 09:24:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553012690; cv=none; d=google.com; s=arc-20160816; b=PJPzc0p9cGo/XhyQ0aq3BhLdkOw3M9rArnY1VBpWs/KJ7sH0REo6p5w/jQU4uwnQWv jG68xN3Ct/LWInJkh8gSItfxSA8BqKfs2jj54MfjRMa/negzPStV6X4nnxMNLGPAh9cu oBD1wE+8dPNVCu3Y8jS2JSTC6s8l6eHsX7YJf8iGJpyRO1BCf9RZR6ctwwmOaMdZoofN MhacNmyk6FJtRTIXOpCOzDjuVK+y3MFTh1nMy6+sJSzgp0Odi1D/Jf60upTj4PtFUz7n g5sCTAd0ZZYcGNK1i736VyxLx3PIJs1LsmFOXkQRnHADckOXEPYMTQeIvhnO+mAsHpFe Q1rA== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization; bh=rv9ImNojPNpnxcP/daJfasHuwj8wmdDXjiIoL3ay7nI=; b=bJbgB9ttPFasE/i5fxqbbtLoCFHzr6Y4B3eCCYjT74g08g8nJrjYXiqTMjFkZwXiNR 0T0HtleqSexrzRxd3H0mjrIpgRS/3CLarIJTp3RAoB1VtjjN7Ldar+ICxF1lKMdzfL0L Css1Y9b4AFtvbkKdemN7iB//4jo+yMmSg/aOJjvjRwywkAyvSMzlzdNVzUMewxHE4V8H hFuOdzlmsi1iVueMSCPA9cYz0DRtWGVIufxupROAVdnelpHhJ/e054EVfGOczlwh8xfe eKbTZJJfIpP+ey4Xg5i/IkCWCgMZHl6IS4/gve+rWXocEc+ozsJxunFLitT2d2lThORR 6eDw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si4464237pll.397.2019.03.19.09.24.34; Tue, 19 Mar 2019 09:24:50 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727791AbfCSQXl (ORCPT + 99 others); Tue, 19 Mar 2019 12:23:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52898 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727488AbfCSQXk (ORCPT ); Tue, 19 Mar 2019 12:23:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 827FE821E2; Tue, 19 Mar 2019 16:23:40 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-47.rdu2.redhat.com [10.10.120.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 68D57100194A; Tue, 19 Mar 2019 16:23:39 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [RFC PATCH 2/4] vfs: Make fs_parse() handle fs_param_is_fd-type params better From: David Howells To: miklos@szeredi.hu, viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, anprice@redhat.com Date: Tue, 19 Mar 2019 16:23:38 +0000 Message-ID: <155301261872.7556.14287203880762974502.stgit@warthog.procyon.org.uk> In-Reply-To: <155301260319.7556.1326405089184672936.stgit@warthog.procyon.org.uk> References: <155301260319.7556.1326405089184672936.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 19 Mar 2019 16:23:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make fs_parse() handle fs_param_is_fd-type parameters that are passed a string by converting it to an integer (in addition to handling direct fd specification). Also range check the integer. Signed-off-by: David Howells --- fs/fs_parser.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/fs/fs_parser.c b/fs/fs_parser.c index be86703ec371..bd59e1725c50 100644 --- a/fs/fs_parser.c +++ b/fs/fs_parser.c @@ -208,9 +208,20 @@ int fs_parse(struct fs_context *fc, goto okay; case fs_param_is_fd: { - if (param->type != fs_value_is_file) + switch (param->type) { + case fs_value_is_string: + ret = kstrtouint(param->string, 0, &result->uint_32); + break; + case fs_value_is_file: + result->uint_32 = param->dirfd; + ret = 0; + default: goto bad_value; - goto okay; + } + + if (result->uint_32 > INT_MAX) + goto bad_value; + goto maybe_okay; } case fs_param_is_blockdev: