Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp57535lqj; Wed, 10 Apr 2024 04:04:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfR3Wen7ZsvbG/5KeG7F5ZK8plAXmAAG9ymng8E9aPUx15zqbsedPMeUsK27v20okbVpkWdqZpRPwZ8CKXII1leNt8NDhWt+1f/YccrA== X-Google-Smtp-Source: AGHT+IE067/psZeSGfjDjk5eVg008TUOZJclqRKwPr+JPyfLmanR4nc5AauHU1yiHDY+s0U/NbDP X-Received: by 2002:ad4:5d6a:0:b0:699:9a1:c624 with SMTP id fn10-20020ad45d6a000000b0069909a1c624mr2494456qvb.8.1712747057114; Wed, 10 Apr 2024 04:04:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712747057; cv=pass; d=google.com; s=arc-20160816; b=HRSSVg5293qIfMPgq4fpiTpKY/Rf5WvpfGiOPZYxO02CtbfzLWn8Xhl92HgpDPYWbG bBImBvsq5T7fEbZxeaauKx9KMhtkbBQT2zYt8SU/8tw/H2iQeJHRLHGdqlUuDn7SKHH9 YTtgopwY8QSrQ0qLATDIBgpizfgvLcIFtrRZdkF4U+zPEniq7r4/oTf70R4AqVg7pd47 FB4xuMz9o60iXjP5Be0GKgFSeCuLIzAvbe5wnKQNm+VnoDO7sB3i7i52yT6690G579CH 5ITbtkvbwvEOrGC8r2TTH/wHOtxfEvMYvsBm6jOTPmxduVMMgctc9BnF9Vyz2v2qcYku rtnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=2ytwgH6RibXKi7DC6vXSskvykkl9akErEDm8TP+gpUo=; fh=wqxRPldvYD4pfEAWqEZiPn5LLm8SEyZg4aqfO3sQLcc=; b=Uy3jKcGtSTybHHQa16WTPO2r0pJ+01imLM/D/5tOieT5wkM/3K1GSkBc5DIH4tY5d/ E+6bvbtjfBZgGhEOy20LFw0BJ3LdPXwIQr+hskEfWudyiTLSmyodSvoiwEYArYzv6qos zjvGfmQVuCMl8JaKg6p0FyxKIW58xryS2sbuugF5a507+xCwjD7eOe8FAZayYxDN1o45 05XFoMxIJGFDu8gzeFGlzt68IulbKMFY/PxUX9XE5oAR3MV9rp57NO1pNZD049xOvjDs S/ACA6/l+/4AKVLDJR+di4Fj5MQGBq8NypvtGth0AYxTFowCDdERx1F55TEsO04uUXFt u2Iw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=oI5fT0Ki; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=oI5fT0Ki; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-138378-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138378-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id cw3-20020ad44dc3000000b00699012dd6desi12291980qvb.588.2024.04.10.04.04.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 04:04:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138378-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=oI5fT0Ki; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=oI5fT0Ki; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-138378-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138378-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BDD3F1C21163 for ; Wed, 10 Apr 2024 11:04:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4EE79159587; Wed, 10 Apr 2024 11:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="oI5fT0Ki"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="QrQwdHbq"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="oI5fT0Ki"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="QrQwdHbq" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EDC72BAEC for ; Wed, 10 Apr 2024 11:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712747050; cv=none; b=i1e5xjx+zfD1xE0l7gnaUIKdFnf7kns6XwbiZ8n0HaK9zDQAnozdNRmYXaOpFPDkbZ3tXjCdxWMvI2qFDYLRxXr8LxVa5sofFFhOXBPgdawaCNr7gc5eVmnZp+ND/ABD8u4TJzyvZ9DV/lG+OUH1n2E4bVnznun/ftBtnMawsE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712747050; c=relaxed/simple; bh=gAOZJS6zjno/CHx7NPL8N2ymCbZ8t/qkxY2Sv1xHojs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=gGx/2/ohe/FYjMeJL1uveDEJ5O/KRF5PmbgJ3iwMSScnKep8VN+b79jxL+U0TXBnSqItlBQa4srqUFQFWKXJO4O4O6fTnSWnpl4ynlEXbee9/SzKs8VAXZ/oSm4Cp4nDYsK0hcNNAclLEGE26F7HuzLXJ7PqQUom/uUiYqobpLk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=oI5fT0Ki; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=QrQwdHbq; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=oI5fT0Ki; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=QrQwdHbq; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7A2F734F6E; Wed, 10 Apr 2024 11:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1712747046; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2ytwgH6RibXKi7DC6vXSskvykkl9akErEDm8TP+gpUo=; b=oI5fT0Ki45gJFxazVCoW32Ge1oSVQQLLC5NIUYwyXePn0Z7EbJVIGeNr/YTLHEvNwtZ4Wz 9MxhGQON/QKK3/lJ0fKG07ev+2/Yuzp+DyApsydD+YrwH/eC21fRSUXDL+h+eaZgtwLNJV e57KeayftS12dIFE8ugghBGV0A7/At8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1712747046; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2ytwgH6RibXKi7DC6vXSskvykkl9akErEDm8TP+gpUo=; b=QrQwdHbqtjIcLKEvdF+BkyRq+toJCAZgheTl5k9D2CRe4XBfh6JaeKBURAgj71VtesHMbH BmMDaaIE2rf0PKBQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1712747046; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2ytwgH6RibXKi7DC6vXSskvykkl9akErEDm8TP+gpUo=; b=oI5fT0Ki45gJFxazVCoW32Ge1oSVQQLLC5NIUYwyXePn0Z7EbJVIGeNr/YTLHEvNwtZ4Wz 9MxhGQON/QKK3/lJ0fKG07ev+2/Yuzp+DyApsydD+YrwH/eC21fRSUXDL+h+eaZgtwLNJV e57KeayftS12dIFE8ugghBGV0A7/At8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1712747046; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2ytwgH6RibXKi7DC6vXSskvykkl9akErEDm8TP+gpUo=; b=QrQwdHbqtjIcLKEvdF+BkyRq+toJCAZgheTl5k9D2CRe4XBfh6JaeKBURAgj71VtesHMbH BmMDaaIE2rf0PKBQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 6C4491390D; Wed, 10 Apr 2024 11:04:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id pqbtGSZyFmY9dQAAn2gu4w (envelope-from ); Wed, 10 Apr 2024 11:04:06 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 10920A06D8; Wed, 10 Apr 2024 13:04:06 +0200 (CEST) Date: Wed, 10 Apr 2024 13:04:06 +0200 From: Jan Kara To: Roman Smirnov Cc: Jan Kara , linux-kernel@vger.kernel.org, Sergey Shtylyov , lvc-project@linuxtesting.org, Jan Kara Subject: Re: [PATCH v2] udf: udftime: prevent overflow in udf_disk_stamp_to_time() Message-ID: <20240410110406.ax4mpguev7jiszyh@quack3> References: <20240327132755.13945-1-r.smirnov@omp.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240327132755.13945-1-r.smirnov@omp.ru> X-Spam-Flag: NO X-Spam-Score: -3.71 X-Spam-Level: X-Spamd-Result: default: False [-3.71 / 50.00]; BAYES_HAM(-2.91)[99.63%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; MISSING_XM_UA(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_LAST(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap2.dmz-prg2.suse.org:helo,imap2.dmz-prg2.suse.org:rdns,suse.cz:email,suse.com:email] On Wed 27-03-24 16:27:55, Roman Smirnov wrote: > An overflow can occur in a situation where src.centiseconds > takes the value of 255. This situation is unlikely, but there > is no validation check anywere in the code. > > Found by Linux Verification Center (linuxtesting.org) with Svace. > > Suggested-by: Jan Kara > Signed-off-by: Roman Smirnov Thanks! I've added the patch to my tree. Honza > --- > fs/udf/udftime.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c > index 758163af39c2..3113785af3cf 100644 > --- a/fs/udf/udftime.c > +++ b/fs/udf/udftime.c > @@ -46,13 +46,18 @@ udf_disk_stamp_to_time(struct timespec64 *dest, struct timestamp src) > dest->tv_sec = mktime64(year, src.month, src.day, src.hour, src.minute, > src.second); > dest->tv_sec -= offset * 60; > - dest->tv_nsec = 1000 * (src.centiseconds * 10000 + > - src.hundredsOfMicroseconds * 100 + src.microseconds); > + > /* > * Sanitize nanosecond field since reportedly some filesystems are > * recorded with bogus sub-second values. > */ > - dest->tv_nsec %= NSEC_PER_SEC; > + if (src.centiseconds < 100 && src.hundredsOfMicroseconds < 100 && > + src.microseconds < 100) { > + dest->tv_nsec = 1000 * (src.centiseconds * 10000 + > + src.hundredsOfMicroseconds * 100 + src.microseconds); > + } else { > + desk->tv_nsec = 0; > + } > } > > void > -- > 2.34.1 > -- Jan Kara SUSE Labs, CR