Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp809897pxb; Wed, 13 Apr 2022 12:58:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxq8U2KQa8P3M3CdfOrmYoTJ3fcSFFDn/MKujQ1R+wZwPkBVwp4ztsAaj5NEZPTNUcc3ZqL X-Received: by 2002:a17:907:8a05:b0:6e8:441c:358d with SMTP id sc5-20020a1709078a0500b006e8441c358dmr27289357ejc.77.1649879898092; Wed, 13 Apr 2022 12:58:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649879898; cv=none; d=google.com; s=arc-20160816; b=zbtFVLdUQ0Qskgek/GvGiKm46Hszq1zpMV1CazpdWLo+GiS/OEDftB7iHzIpv+Vunn iCS5mwEJhUA64+Y+wNrwvd7gA8I3Ykd4CA3Q9XZB4ykidGO8Z0d4i5i2OoBFsbGxAyVK IvUE8+YbvFNwG/kr+Z2ahmJdjJTZW3gjp04+ryk3t7xae+k+xHA/8iL2PT9xSh/Xv230 RPp6ZRplTD3oioAWk7VUuQ/tftVUZnRg8Sb6jPWAM4gROvBrARkHaaTYnlQrvH9iRQsa lH/KzUzmtoBHrtjetoFr60FosgS71AFYtwb41FFX1eTJoJcdw2t49GCn9P0irUbAA3DP 9aHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=snGXKT5n6XDtwCnQA9MLkATepstbNlkspFrk9ndNi6U=; b=Yk6zsSkxQ7HE87UK+Xkv8Xr8B2CD4WTQ0ANpHCb8LmZRR7rO9NmxhbytPl66jMGIYx Z9kX+tphERAlIkXBio6wY1p5aUmAfrNCciX4QyS3+6wXRynb25jMWEUMjwSUM14crLip Dhubrxq+8WgZNAJia7teqtLhVocZK8RrsimQJMdBDM1VhMNbcs6EDy9/sKj3eqhuEhK6 Dz+nZBEcO46hYDVDUO6ePlJU3ZJiAGfAAu2fApafaycf8VOtxwIllaUKBHuuZKmdqfGG HkJobvH1XvgCbk1IJaIKcV5XdxmCOA0S7eeUsC/l/w7Xfb6fLXvFu3RZqKFveypWmmnw ynNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2021-07-09 header.b=BdRk1rkD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q25-20020a50c359000000b0041d87faa98bsi2193763edb.605.2022.04.13.12.57.48; Wed, 13 Apr 2022 12:58:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@oracle.com header.s=corp-2021-07-09 header.b=BdRk1rkD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231717AbiDMLp6 (ORCPT + 99 others); Wed, 13 Apr 2022 07:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiDMLp5 (ORCPT ); Wed, 13 Apr 2022 07:45:57 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D63F25B3F5; Wed, 13 Apr 2022 04:43:32 -0700 (PDT) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23D9xvYW032238; Wed, 13 Apr 2022 11:43:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2021-07-09; bh=snGXKT5n6XDtwCnQA9MLkATepstbNlkspFrk9ndNi6U=; b=BdRk1rkD6rINJkZWx1YEFObZL3ohwLy3ETlWjYD74GLgaRxfePw6HROebBZ38+h6xO/8 Ptu3sw4vsoBLLqSjblsLcS3yUp9VtzIashOTd04ncEcijRplK3TH1mbfdvOVESj/LK3W bWkquRBU5NcDAP8OLgUXnjON/VP77pvrTe1S2BFj0D5E6cXx/IWheuWkw0BzqGxfgvw0 eaM1a+JJnqHpss1lytLXAvbG+gJLXbtO7h4fib1g3IoQB2CPLVuWGmdXIn/9uE2LmZjI STOAEaWjxJE1FjEjQ4POeQa5qZamYPoK9Z27XcY8RmxLvvrrZZA+789h5iJUhHL7FGEM BA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com with ESMTP id 3fb0jd9da7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Apr 2022 11:43:17 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 23DBfRRL010353; Wed, 13 Apr 2022 11:43:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fb0k3wau6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Apr 2022 11:43:16 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 23DBhG65016664; Wed, 13 Apr 2022 11:43:16 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.147.25.63]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3fb0k3watn-1; Wed, 13 Apr 2022 11:43:16 +0000 From: Harshit Mogalapalli Cc: harshit.m.mogalapalli@oracle.com, dan.carpenter@oracle.com, smfrench@gmail.com, Steve French , Stefan Metzmacher , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] cifs: potential buffer overflow in handling symlinks Date: Wed, 13 Apr 2022 04:42:51 -0700 Message-Id: <20220413114251.73083-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-ORIG-GUID: pmHfV1bQBRIjOkb1odkxWsvclPwJw5bw X-Proofpoint-GUID: pmHfV1bQBRIjOkb1odkxWsvclPwJw5bw X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Smatch printed a warning: arch/x86/crypto/poly1305_glue.c:198 poly1305_update_arch() error: __memcpy() 'dctx->buf' too small (16 vs u32max) It's caused because Smatch marks 'link_len' as untrusted since it comes from sscanf(). Add a check to ensure that 'link_len' is not larger than the size of the 'link_str' buffer. Fixes: c69c1b6eaea1 ("cifs: implement CIFSParseMFSymlink()") Signed-off-by: Harshit Mogalapalli --- v2: make use of CIFS_MF_SYMLINK_LINK_MAXLEN (same but cleaner). fs/cifs/link.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 852e54e..bbdf328 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -85,6 +85,9 @@ if (rc != 1) return -EINVAL; + if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN) + return -EINVAL; + rc = symlink_hash(link_len, link_str, md5_hash); if (rc) { cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __func__, rc); -- 1.8.3.1