From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 684D53C2770 for ; Tue, 26 May 2026 21:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779830958; cv=none; b=I4tmW3nSAvI206cmAzqEh3jCcyTYsP3djhWADjYHCLe9UuKLepUe9VgQKqIsBoemUaus4lrlzUpJHpuLb9g/As7bQsM3Yx40coYBbzKsYeeV2U7gsWT0V72dfDRjo9og+vUrJ5B/8ElMuFFnwKcxEf3az/5JmRemBHEX9AQ1w1E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779830958; c=relaxed/simple; bh=pFMLcN4G+qQybN7/WwcDbRDl8SQ3nzHJFFuVnaBsiYM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jaK5Wu57+G4gnSR0BnVGLL3agZcv0+A0FhZVDoLnohBkXcUDeMtEHGhYnPXgkNPLwWNnqSRveJQustoQ00mrKSfjj4KgxESnHrPdYdIpiAdHW+0zDKKFzaBBwKaqlqxw5dz+cE2JCcGpxZEiX3akTh06mJ/HnPYACML21Km8AHU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PS0cuMCU; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=KYOR92o5; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PS0cuMCU"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="KYOR92o5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1779830953; h=from:from:reply-to:subject:subject: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=lsvLacXz8Po3XimOFLS6zC3jXFc1dZ2FM3YORkPmXIs=; b=PS0cuMCUnOonV/lz3po4lM/oQbv80TafVu22m0zcSSwuUBRnKVxpuwDglgXH57uc6BVjnU JdZHUrswctXLlFxqoLpW6w5ohMQUA0FlbTTTVQfIb4sHCojeVUExj4LqPIiEnVYgGBpnOB TBPf+ZZMuDmLTF1wsRcqJxFFzLabppk= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-607-R6IIqvvSM7OwD9N9YcBqqQ-1; Tue, 26 May 2026 17:29:11 -0400 X-MC-Unique: R6IIqvvSM7OwD9N9YcBqqQ-1 X-Mimecast-MFC-AGG-ID: R6IIqvvSM7OwD9N9YcBqqQ_1779830950 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4497a0e3acaso9262777f8f.0 for ; Tue, 26 May 2026 14:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1779830950; x=1780435750; 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=lsvLacXz8Po3XimOFLS6zC3jXFc1dZ2FM3YORkPmXIs=; b=KYOR92o5fOsVXHORoK4d4lS6UZ/H2ijUyEFZ7udaTLyoRCoixe5OTOZLV3OtPl7GHR GhmwE/4WqaxLyd3zpQkREspmNqOlmfnXokARDD08rAUdf539GMxvAgTVydM6S3nM3V4b hWIQhZbEVdAQ3dzVRlxNjRFGBDWdWw8uMIqqXrGh87hN1h9vWB3GCjwJxCI4m2bCeMvQ 3DQORBqtz2XxIPmxvEAUPW+gELW4m6RK7Mkvl92uz/dMYhMUAa5xo2Rz5w+ULwv4NCWD VyiUvyL0KuSWz0fZZsJQmByiczDQ78Yiy1YZkM/LlhLuie/3c+kWe2l5Kug8ppYpxX8N Zmyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779830950; x=1780435750; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lsvLacXz8Po3XimOFLS6zC3jXFc1dZ2FM3YORkPmXIs=; b=MaR2Z3Y2vmjGci4IcGDduY7fLx3hUtOzp45KKI+Gg2SMD8JMWrNL9YmphpJ3GkkbHZ sp/Np1HSc8vWuxPtaYiLV7LD+/V7O0dzWuemonpkim9U0u59coeYswHxyGwVZeeTXBm0 GGRhqGyIzJXpldLyJV8BncXHMgQwpIWQaj4O3a/slMoGkMkkg5Xej8RcBAUa0TaoPq9e 39XvtPtMhgHdiXM4/AbYkaQ0xVqwKYUF62qBhSEY6uvkU8dwxEhAYajH80FnUBsy2yvn k6ZMbLDdGaYP33UMCunZfQtziY82yauXDaM8ERv8WkwjVyGt5kuoq/gc+RtA3uWzs6Ia dQOw== X-Forwarded-Encrypted: i=1; AFNElJ9Gi85TcbVdl5sr4khb+1nFr+EMN+FmYBtDT0267YeItHR8prqWEO5H/SNA0o2taOFVaRYUzQKtZ1Nh37Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3D8q82yeBRfGCGa56pmcftZRsUl/iTeVLglQPdjF1jisdfL2J K/esvqtyRX4mcLiyR76b9CyaoihiQVQ6w5Kp9gPLuYcfhY1/S0U9vz/RFcctx29EJXa6IiDGj9s IOTPOwdyH0M4PWBvMC63/BHTM2FByEnpMJ9m9hHBiPYG94od7MC+Qq2GVawNM4y7Uig== X-Gm-Gg: Acq92OH1gp8rCRCgphYDBCptRUhkkyigmyuKKZ2sm0F7D1ZL1FWYQuk59sALBZI54Mb dIbjW78BJzMr5uhbNpMwemwwaZtDrSCorDvP+uO3EaUL8vSaO8dudq2qZC8d8AJkK2gUAtgM0Ft WSLwj/h/gQEol8Rw0GSFCKO/i6OD1BI1Kk3HcyRm2KcKIG6+qHTSzdbV8TgpPZa0voTD7RSr4cN pQqnRxodHif6b+9r/6yv6n+K4w3NbncFvkOBii0HHRw0vUBC2QHwHBJoEOEDTC2BSeIFUEpdb// W59kVl2D3NlTjakoGfOkFB52NnLOwwpLvC2W4+uLFRmmYOEYfvzFS3R8rfkhydTm+Mm/IesOyv7 Z1mbL/+Wg1ITkg79xfBAD X-Received: by 2002:a05:6000:25e3:b0:45e:655d:6f7 with SMTP id ffacd0b85a97d-45eb38b38d1mr33262199f8f.24.1779830950128; Tue, 26 May 2026 14:29:10 -0700 (PDT) X-Received: by 2002:a05:6000:25e3:b0:45e:655d:6f7 with SMTP id ffacd0b85a97d-45eb38b38d1mr33262147f8f.24.1779830949557; Tue, 26 May 2026 14:29:09 -0700 (PDT) Received: from localhost ([2a01:e11:1007:ea0:8374:5c74:dd98:a7b2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45edb5c27e7sm1077738f8f.35.2026.05.26.14.29.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2026 14:29:08 -0700 (PDT) Date: Tue, 26 May 2026 23:29:07 +0200 From: Davide Caratti To: Jamal Hadi Salim Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, jiri@resnulli.us, victor@mojatatu.com, david.laight.linux@gmail.com, yimingqian591@gmail.com, keenanat2000@gmail.com, 2045gemini@gmail.com, rollkingzzc@gmail.com, toke@redhat.com, security@kernel.org, linux-kernel@vger.kernel.org, Rajat Gupta Subject: Re: [PATCH net v2 1/1] net/sched: fix pedit partial COW leading to page cache corruption Message-ID: References: <20260526155913.1060694-1-jhs@mojatatu.com> 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: <20260526155913.1060694-1-jhs@mojatatu.com> On Tue, May 26, 2026 at 11:59:13AM -0400, Jamal Hadi Salim wrote: > From: Rajat Gupta > > tcf_pedit_act() computes the COW range for skb_ensure_writable() > once before the key loop using tcfp_off_max_hint, but the hint does > not account for the runtime header offset added by typed keys. This > can leave part of the write region un-COW'd. > > Fix by moving skb_ensure_writable() inside the per-key loop where > the actual write offset is known, and add overflow checking on the > offset arithmetic. For negative offsets (e.g. Ethernet header edits > at ingress), use skb_cow() to COW the headroom instead. Guard > offset_valid() against INT_MIN, where negation is undefined. > > Additionally, linearize skbs with shared frags upfront to prevent > silent data corruption when pedit operates on zero-copy pages > (e.g. from sendfile). > > Fixes: 8b796475fd78 ("net/sched: act_pedit: really ensure the skb is writable") > Reported-by: Yiming Qian > Reported-by: Keenan Dong > Reported-by: Han Guidong <2045gemini@gmail.com> > Reported-by: Zhang Cen > Tested-by: Victor Nogueira > Acked-by: Jamal Hadi Salim > Signed-off-by: Rajat Gupta > --- > Changes v1->v2: > 1. Do better boundary analysis to cover cloned skbs with frags. Pointed > out by sashiko-nipa: > https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260519033950.2037-1-rajat.gupta%40oss.qualcomm.com > 2. As a result of fix #1 remove the skb_has_shared_frag() check, unnecessary. > Also Jakub has plans where the shared frags is not going to be a "thing" > 3. Make small adjustments everywhere for integer checks, suggested by D. Laight > 4. Remove all reviewers and testers since this is a large enough change. > Please retest and re-review. > 5. Remove Rajat as reporter since he is the author (which implies he is a reporter) re-ran mp_join + pedit_l4port + pedit_ip kselftests on patch v2, no issues found. Reviewed-and-tested-by: Davide Caratti Thanks! -- davide