From patchwork Mon Oct 24 11:31:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8480 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp403467wru; Mon, 24 Oct 2022 04:52:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GsGf+x9SdP2fuAgoJjBq53RtV1spy3RhmWC/V0ijEu8z/IZyURfhZkStD9B+pvehGSZ3i X-Received: by 2002:a63:ed01:0:b0:445:4345:4a21 with SMTP id d1-20020a63ed01000000b0044543454a21mr28127276pgi.404.1666612339801; Mon, 24 Oct 2022 04:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612339; cv=none; d=google.com; s=arc-20160816; b=o/AYCyyucLg8K8bhAIH690FcXBvvU51DUfo9VGsGYtCQv0Tn3NxzRhuSItGBF6I+3n f1nQjSI49NnS/5usg5aHZbS20h1J/wjq4btBuc5EoKp++bYSV/dcrr9+Rx3aLMIVPN6b VDhQcaDbi5gORXKsI3WqXEg7ZYkf52IEqukJBEgn0lIPpABQVxz0OG7zSTwE0aiEw4T0 XqCnMZU1fBWZIfZcwfjuR+BJEJyNRa2glykO5t2iovUGhy4QHef1+IpfPEHx53io0+oY nQ9vZcTHsu9Pj6e8AOgse6cFcHLnUn2PS/GojbduV5j+dURREp2ALzkkEx7QccTSAHNr 7l6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Tm717FB0OfzvRFjmRnD6aZ2+61xnbGzoQzQDqRQxaYQ=; b=t0njirli5cZgnpMDDJu5qgQlu2XbHnrTrBdawK4FBOWzUP4MSOBfEaJP3sJEW0yl/8 wlQmGB1tY85ZgwUoelbOEaY4BDWIg/Su3rSGmhFenpqiiBqPRwEpR2QocacNcGH59Es/ a6pBzp0IH7p7sriqZQpQqhSlXpcUmMXveYOr53E9WcVWGyFUh9r802EX4uWRMh/oJnPt 7hoLUvfh0UrrHNpTZXbbbJCx9gqUvZX4tT2+yu59bPzz3+3gHJNXJcOyvbOaoKvuYDst 5Hk7jbhHHHioR39RNRvxYDpI6mHvs055DUVoqq2W3FK4RNvJlg1+3k55iCEopm6VOp4T o7Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lYsOZM3j; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ob2-20020a17090b390200b002131cee8cd2si2242600pjb.10.2022.10.24.04.52.06; Mon, 24 Oct 2022 04:52:19 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=lYsOZM3j; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231836AbiJXLvl (ORCPT + 99 others); Mon, 24 Oct 2022 07:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232036AbiJXLta (ORCPT ); Mon, 24 Oct 2022 07:49:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EB256FA30; Mon, 24 Oct 2022 04:43:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D0126B81181; Mon, 24 Oct 2022 11:43:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A021C433B5; Mon, 24 Oct 2022 11:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611836; bh=/XB4y2LpgVtKSLfj2FRGEXMsobFlbWAbbPzG5tqVxqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lYsOZM3jHNAvVDZcmoE/rLep3/MynpDd3PnoPNeVrzKz39xDQZR6BiWLQYopsEnXf 6vXoPbH0XnWwnRF/3hROhMyI8mceTTNcW2NkoLf8XApkqWz4/jpL5ZMA+mSDK45fDI FdZEnnFZHf7nCouTMeglxydZCTHdoVHUKMy3aCMk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com, Khalid Masum , Steffen Klassert , Sasha Levin Subject: [PATCH 4.9 130/159] xfrm: Update ipcomp_scratches with NULL when freed Date: Mon, 24 Oct 2022 13:31:24 +0200 Message-Id: <20221024112954.247344529@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747569700752378105?= X-GMAIL-MSGID: =?utf-8?q?1747569700752378105?= From: Khalid Masum [ Upstream commit 8a04d2fc700f717104bfb95b0f6694e448a4537f ] Currently if ipcomp_alloc_scratches() fails to allocate memory ipcomp_scratches holds obsolete address. So when we try to free the percpu scratches using ipcomp_free_scratches() it tries to vfree non existent vm area. Described below: static void * __percpu *ipcomp_alloc_scratches(void) { ... scratches = alloc_percpu(void *); if (!scratches) return NULL; ipcomp_scratches does not know about this allocation failure. Therefore holding the old obsolete address. ... } So when we free, static void ipcomp_free_scratches(void) { ... scratches = ipcomp_scratches; Assigning obsolete address from ipcomp_scratches if (!scratches) return; for_each_possible_cpu(i) vfree(*per_cpu_ptr(scratches, i)); Trying to free non existent page, causing warning: trying to vfree existent vm area. ... } Fix this breakage by updating ipcomp_scrtches with NULL when scratches is freed Suggested-by: Herbert Xu Reported-by: syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com Tested-by: syzbot+5ec9bb042ddfe9644773@syzkaller.appspotmail.com Signed-off-by: Khalid Masum Acked-by: Herbert Xu Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_ipcomp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c index a00ec715aa46..32aed1d0f6ee 100644 --- a/net/xfrm/xfrm_ipcomp.c +++ b/net/xfrm/xfrm_ipcomp.c @@ -216,6 +216,7 @@ static void ipcomp_free_scratches(void) vfree(*per_cpu_ptr(scratches, i)); free_percpu(scratches); + ipcomp_scratches = NULL; } static void * __percpu *ipcomp_alloc_scratches(void)