Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E65B4E0B9F; Thu, 17 Sep 2026 17:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789666575; cv=none; b=SEdg9Ae02uO89dvCyzwtifkx7UgRol4mqLPNkRCzJOFby6Y243yN7vt1/fZtwQlCCpIQ5o2FL87QIeKOMoyC6nYC+Z79iSjk41ByeIS3C/v0UyqEVpi+BYvKxS32u+05cHMLBwLHkByJqZ6IJN51gzhOOFEwHFQP8Qzj1lx/8jg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789666575; c=relaxed/simple; bh=S1UWJR2JrxpE31eMT8i8alin9MBiJcP42eza3fbBQF4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EbK90bbDQK4wx9guITbxO047QRSN/v1Ixhhqly3qvyTT7z7kIZkVYwzwJhXEquflA9/a8XUIth5M2+4wh073JuMolw5c4bq1ul4Ac1y80aKs1emTHU2ATPa3dNWvOt8EGHK6o6AiLAt45jjIIrGuNo4yepB1YGqqSoq45n6ws4Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=W8ERlSRs; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="W8ERlSRs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 089081F00893; Thu, 17 Sep 2026 17:36:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789666574; bh=uryiBsSSZDOpMbXHWMNFZMPyjk0J1ktTKATLiTY4vd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=W8ERlSRsckRpirwi8CkfC2xLpjmF0tcq+fqHkbhL46Tq9Re7p2JngRh4O4rcztZF6 t48TWLCvb0eUKEBBzlMeLy9bWumHiwhdYxPZSB9gAf34jHh0kzDjKumGDEgE0XMyWe qQ863Fc81g4nP1eN7dyBuaYypo+PMBeHp800q/xI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Namjae Jeon , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM Subject: [PATCH 6.18 1083/1250] smb: client: fix file type corruption in posix_reparse_to_fattr() Date: Thu, 17 Sep 2026 16:14:38 +0100 Message-ID: <20260917151621.506295886@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paulo Alcantara commit 65d5dbdc089be42fc48a6f77bc6b648307f34b17 upstream. Setting the file type in cf_mode without clearing the existing S_IFMT bits first is wrong as it corrupts the file type when cf_mode already has type bits set (e.g. S_IFREG | S_IFCHR == S_IFLNK). Use a local ftype variable to collect the new file type and apply it after validation succeeds, clearing S_IFMT and setting the new type in a single assignment. This avoids stripping cf_mode on malformed reparse points where the function returns false early. Closes: https://sashiko.dev/#/patchset/20260906172005.627163-1-pc%40manguebit.org Reviewed-by: Namjae Jeon Signed-off-by: Paulo Alcantara Cc: Ronnie Sahlberg Cc: Shyam Prasad N Cc: Tom Talpey Cc: Bharath SM Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/reparse.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/fs/smb/client/reparse.c +++ b/fs/smb/client/reparse.c @@ -1177,6 +1177,7 @@ static bool posix_reparse_to_fattr(struc struct cifs_open_info_data *data) { struct reparse_nfs_data_buffer *buf = (struct reparse_nfs_data_buffer *)data->reparse.buf; + umode_t ftype; if (buf == NULL) return true; @@ -1192,7 +1193,7 @@ static bool posix_reparse_to_fattr(struc WARN_ON_ONCE(1); return false; } - fattr->cf_mode |= S_IFCHR; + ftype = S_IFCHR; fattr->cf_rdev = reparse_mkdev(buf->DataBuffer); break; case NFS_SPECFILE_BLK: @@ -1200,22 +1201,23 @@ static bool posix_reparse_to_fattr(struc WARN_ON_ONCE(1); return false; } - fattr->cf_mode |= S_IFBLK; + ftype = S_IFBLK; fattr->cf_rdev = reparse_mkdev(buf->DataBuffer); break; case NFS_SPECFILE_FIFO: - fattr->cf_mode |= S_IFIFO; + ftype = S_IFIFO; break; case NFS_SPECFILE_SOCK: - fattr->cf_mode |= S_IFSOCK; + ftype = S_IFSOCK; break; case NFS_SPECFILE_LNK: - fattr->cf_mode |= S_IFLNK; + ftype = S_IFLNK; break; default: WARN_ON_ONCE(1); return false; } + fattr->cf_mode = (fattr->cf_mode & ~S_IFMT) | ftype; return true; }