From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 3CBB7211A11 for ; Wed, 22 Jan 2025 13:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737553859; cv=none; b=sS8Y4Siww4K0+1QcNW8idbbFfdOVO00/jYZC1Ielanu44H+fqq27h7FsBtqF8j5tJPVj1iN8oTAOuo5uwIYtg+82+4QotrVIkgohYbgicD1Vb0nFhx2L43/vMUOEv2DPLyQoZSrlEXl7qEBzY7NM8bdJ/tw7CMhRcx0xhdiWwmY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737553859; c=relaxed/simple; bh=bks+dcymjfuxwpQMDs5ixSXGxUexUIw8mAnKAomCojs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hmhrcQmdJFfSiedHWpimcy/nKV+1gqqJhr38MhTdLVAXnEvaE9LTNW5KeIP7vRrVCJrze1PrFntTt9Ted6ruDh8r/nYRTMCAPiTzJcuMVqlWrR551uxPJQd3flw3wf6GdMdQNKHOjPbIAWaY686vhfsO1RphKagEngZjnGtbCds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=iPqmzRd7; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iPqmzRd7" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-436202dd730so50839165e9.2 for ; Wed, 22 Jan 2025 05:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737553854; x=1738158654; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LeJQbMKgxTKE/VdTo5M9qbk3XdSIS18Xn3c/OFMKt/Y=; b=iPqmzRd7baIPYn33C3KRXTrV+pCb463BW28fABHTx8ITb24hrWxLQnJ+nviGXhxSfY zb+MNO9VEUyt/GeIcQCdh5cwTsZ6u81oMDftOkRtWp/lDnhFKYQnv8PgEe3AOO2Cys7B jCTVTMoJsesIeF8nJDx29w/IAF3PGo4v/5WUkGHEeQUdwweIup2Lo6F39lGioVi+FYaU qdkSxs1lUrSSjJg/uW2G1+TTq7j6HfgEbqcPibjxY2ZJr/rQxJ1qvAQBMz/tsTGm7XpH xuvJnxFuBVBrO9Bv2ya7BYoQ3paWVENWcHjKecPQeljXyasJkXGBSqgJTE6UYddMZAvL fpKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737553854; x=1738158654; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LeJQbMKgxTKE/VdTo5M9qbk3XdSIS18Xn3c/OFMKt/Y=; b=HhTG/gB7AP0PCN4fFrC6psTzrcS9DkYqd1aDrrNURGMvizF8qtlM+QFBgyL/+Lwnim XtQDiJPz0VwAnppVjVBcgiY8+timlErYj6VbEe8dCyDt0bKlWhNham2QeZJTo1X/xjpD 85orRtwv1NDW0F1jgIlnHTr86ed9TrZSjyp8gM/qnKKPj0zGQsWalIk5eqmZp1rC3D1n 9vcuz6ozKujc8q91dBSWm2AIXhK/IJ1YaMhw33rnf4qrI2KLyKeZiaN920enxLTWn0FH BkgFRXeQ/X93kesSOcHMHarYNZDWIQq+AvJ2/sUbGBfMNIxsuOHf2p53Y3IUPYrPFYuK g2Ng== X-Forwarded-Encrypted: i=1; AJvYcCUWaVGQbglMktLCgaB0is/YZdcOWVw+Nf4KNWD5K/Xmn510l/FTAuni0kvihe2IMWUp6PnxcHye/G6QAJ0=@vger.kernel.org X-Gm-Message-State: AOJu0Yy4u67GSz+510ksv1MAUK0bbTFrBmIqkxAdiS4ZaXXVQkx5GBBd EhhGxTDBQQwkbWYLgcUtcVE28gsTyeZDqHS4uDOy0vkdniyw94qXgXBFiLfjrLs= X-Gm-Gg: ASbGnctgV/dCGUKXZarv+O949SP3WTykbMSv+D+N2R8duMSow3k+uLxRuPL9lLQ+R90 Ww9mi930Byx62JvpxMCEdL859j/iFCXdDHJzX/t8IXOmUQXvW11nm/dbAn/7vMjNgesKGCG6hEy EgfJfheeE81EZvwZhzMQE6kZKQ75EfJbDH8NuD0uPoHgnbV9HEPCaeeMFIW7+CXehPGTDHWlKAx T+yjmOKgNj7srNe5HVoVcdgDHdZbq828koBHVjVsZSmiL0uwZyCjDBVvjwopFBdAutoF8CqIRs= X-Google-Smtp-Source: AGHT+IFV7PIhFkke0uCO2oWIdMNtHM2fB8T0QZVi6jL0x9DpK6ZPV63ZMQQxSYMhiuEQfz57I9x/1A== X-Received: by 2002:a05:600c:4e06:b0:434:e8cf:6390 with SMTP id 5b1f17b1804b1-438913c6856mr195769175e9.6.1737553854420; Wed, 22 Jan 2025 05:50:54 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b3189924sm26248475e9.3.2025.01.22.05.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 05:50:53 -0800 (PST) Date: Wed, 22 Jan 2025 16:50:45 +0300 From: Dan Carpenter To: Simon Horman , Herbert Xu Cc: Steffen Klassert , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH net] xfrm: fix integer overflow in xfrm_replay_state_esn_len() Message-ID: <32890a3f-1258-4c03-86e1-86c0e4e8e415@stanley.mountain> References: <018ecf13-e371-4b39-8946-c7510baf916b@stanley.mountain> <20250122123936.GB390877@kernel.org> <670272e2-a4b2-4bdd-95c0-26d1e7c65816@stanley.mountain> 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: <670272e2-a4b2-4bdd-95c0-26d1e7c65816@stanley.mountain> On Wed, Jan 22, 2025 at 04:16:48PM +0300, Dan Carpenter wrote: > On Wed, Jan 22, 2025 at 12:39:36PM +0000, Simon Horman wrote: > > > The one caller that I didn't modify was xfrm_sa_len(). That's a bit > > > complicated and also I'm kind of hoping that we don't handle user > > > controlled data in that function? The place where we definitely are > > > handling user data is in xfrm_alloc_replay_state_esn() and this patch > > > fixes that. > > > > Yes, that is a bit "complex". > > > > I don't have a reason to suspect xfrm_sa_len() but if we were to write > a paranoid version of it then I've written that draft below. I stole > Herbert's xfrm_kblen2klen() function[1]. Also the nlmsg_new() function > would need to be updated as well. > > https://lore.kernel.org/all/Z2KZC71JZ0QnrhfU@gondor.apana.org.au/ > > regards, > dan carpenter > > diff --git a/include/net/netlink.h b/include/net/netlink.h > index e015ffbed819..ca7a8152e6d4 100644 > --- a/include/net/netlink.h > +++ b/include/net/netlink.h > @@ -1015,6 +1015,8 @@ static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb, > */ > static inline struct sk_buff *nlmsg_new(size_t payload, gfp_t flags) > { > + if (payload > INT_MAX) > + return NULL; > return alloc_skb(nlmsg_total_size(payload), flags); > } Actually, this chunk is necessary. Let me sent that by itself. regards, dan carpenter