From patchwork Mon Jul 25 00:13:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 12927669 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73341C433EF for ; Mon, 25 Jul 2022 00:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbiGYANd (ORCPT ); Sun, 24 Jul 2022 20:13:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbiGYANc (ORCPT ); Sun, 24 Jul 2022 20:13:32 -0400 Received: from smtp01.aussiebb.com.au (smtp01.aussiebb.com.au [121.200.0.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0B26BE10 for ; Sun, 24 Jul 2022 17:13:31 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id 90832100384; Mon, 25 Jul 2022 10:13:27 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp01.aussiebb.com.au Received: from smtp01.aussiebb.com.au ([127.0.0.1]) by localhost (smtp01.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1sQ4oH17qdL9; Mon, 25 Jul 2022 10:13:27 +1000 (AEST) Received: by smtp01.aussiebb.com.au (Postfix, from userid 116) id 86F731002F9; Mon, 25 Jul 2022 10:13:27 +1000 (AEST) Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp01.aussiebb.com.au (Postfix) with ESMTP id B84F21002E3; Mon, 25 Jul 2022 10:13:25 +1000 (AEST) Subject: [PATCH] cifs: fix negative option value parsing From: Ian Kent To: Steve French Cc: linux-cifs@vger.kernel.org, linux-fsdevel , Leif Sahlberg Date: Mon, 25 Jul 2022 08:13:25 +0800 Message-ID: <165870800544.18681.3152428501550287295.stgit@donald.themaw.net> User-Agent: StGit/1.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The valid values of options that are defined with fsparam_u32() should be positive. But the fs parser will return a fail for values that are negative and if the sloppy option is given success will then be returned resulting in the option being silently ignored. Also the sloppy option handling is meant to return success for invalid options not valid options with invalid values. Restricting the sloppy option override to handle failure returns for invalid options only is sufficient to resolve these problems. Signed-off-by: Ian Kent Signed-off-by: Leif Sahlberg --- fs/cifs/fs_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c index 8dc0d923ef6a..2dc5cdeee354 100644 --- a/fs/cifs/fs_context.c +++ b/fs/cifs/fs_context.c @@ -863,7 +863,7 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, if (!skip_parsing) { opt = fs_parse(fc, smb3_fs_parameters, param, &result); if (opt < 0) - return ctx->sloppy ? 1 : opt; + return (opt == -ENOPARAM && ctx->sloppy) ? 1 : opt; } switch (opt) {