Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3126683imu; Sun, 13 Jan 2019 19:22:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Y4n/XYW9Q2emvjMhOhuKks316B+nYmEuCfGDMjduNdHHClT6xGEa6wJYtvXboMSKWpthm X-Received: by 2002:a63:e711:: with SMTP id b17mr10998895pgi.363.1547436141074; Sun, 13 Jan 2019 19:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547436141; cv=none; d=google.com; s=arc-20160816; b=DxsLUmEx41vSj9U+GvbRW7/VyIGPCICWZhs2taYVbNCNiC9lLw4N1d2barvbKkOXta Cnx6wXxYNes8rOofw5Edg1gVDVe/1g1jpzNK9aMaIVRjgLAn4kgc/JzG7/cxb3ezZscl tz0Lyh+gLEJj39M+6AsI6wZFaUsBnFhwqNcZlwZayWav+fmvfA/OnwOsR/ElEu9uHAoo TKDoZm4UIeZS/2yDYivGyG5RlmPWMtRVl8mT9b2Q+FHYD52uwyQeoJSEcKVWL2m8AYx3 73Iz3kTIuUel0UPr+Ij8CA820VqwdJHSaBHIUMTiASCA1RGmnvggpCP7F7Vr2FjWrEgD Q1pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=m5HH3Q3kthweT319C7oyabONxMyTnduJKmmD4CvzqrU=; b=hlyx0l5pu+k8hvY9BLo8PB/WfPOYdfZH2copijRW36gvkNzecu1VhpQ6qmoLaPKkxW 9eDr6xChkbvWgxAfc12i/6X7XErLBT6F2bk8T9jj0x8zyJUP8ugtNnwCV5RvW2PLduLG v+JW/efIXAcFxMDgxup4tQS5x657wzNzWlTlVzBDTD94jqlbjwvo3K6ZbuLCzv5e1sS3 m9PwoaFPX3Z6PW09BrZHPXqXLYKuSMyDB1Knr2rJXqfR1e3b9n7UQMbScWjuzpuOXpn1 TmoNQ9N2waqLWPdKuSQtqEoJTKAVcjmHUfn3UVJ5AVH1/LlLy2h2v/TpXKyOyTWYRu3j Qyhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 73si25048653pfm.50.2019.01.13.19.22.05; Sun, 13 Jan 2019 19:22:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbfANDVC (ORCPT + 99 others); Sun, 13 Jan 2019 22:21:02 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:15772 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726677AbfANDVC (ORCPT ); Sun, 13 Jan 2019 22:21:02 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 66006CDF3DCD4E2774BF; Mon, 14 Jan 2019 11:20:59 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x0E3KqSx093033; Mon, 14 Jan 2019 11:20:52 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019011411205679-22095830 ; Mon, 14 Jan 2019 11:20:56 +0800 From: Wen Yang To: boris.ostrovsky@oracle.com Cc: jgross@suse.com, sstabellini@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn, Wen Yang , Dan Carpenter Subject: [PATCH] pvcalls-front: fix potential null dereference Date: Mon, 14 Jan 2019 11:20:23 +0800 Message-Id: <1547436023-5797-1-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-01-14 11:20:56, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-01-14 11:20:53, Serialize complete at 2019-01-14 11:20:53 X-MAIL: mse01.zte.com.cn x0E3KqSx093033 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org static checker warning: drivers/xen/pvcalls-front.c:373 alloc_active_ring() error: we previously assumed 'map->active.ring' could be null (see line 357) drivers/xen/pvcalls-front.c 351 static int alloc_active_ring(struct sock_mapping *map) 352 { 353 void *bytes; 354 355 map->active.ring = (struct pvcalls_data_intf *) 356 get_zeroed_page(GFP_KERNEL); 357 if (!map->active.ring) ^^^^^^^^^^^^^^^^^ Check 358 goto out; 359 360 map->active.ring->ring_order = PVCALLS_RING_ORDER; 361 bytes = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 362 PVCALLS_RING_ORDER); 363 if (!bytes) 364 goto out; 365 366 map->active.data.in = bytes; 367 map->active.data.out = bytes + 368 XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER); 369 370 return 0; 371 372 out: --> 373 free_active_ring(map); ^^^ Replace map->active.ring->ring_order with PVCALLS_RING_ORDER to avoid potential null dereference. Fixes: 9f51c05dc41a ("pvcalls-front: Avoid get_free_pages(GFP_KERNEL) under spinlock") Reported-by: Dan Carpenter Signed-off-by: Wen Yang CC: Boris Ostrovsky CC: Juergen Gross CC: Stefano Stabellini CC: Dan Carpenter CC: xen-devel@lists.xenproject.org CC: linux-kernel@vger.kernel.org --- drivers/xen/pvcalls-front.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c index 307861f..e56f9a3 100644 --- a/drivers/xen/pvcalls-front.c +++ b/drivers/xen/pvcalls-front.c @@ -344,7 +344,7 @@ int pvcalls_front_socket(struct socket *sock) static void free_active_ring(struct sock_mapping *map) { free_pages((unsigned long)map->active.data.in, - map->active.ring->ring_order); + PVCALLS_RING_ORDER); free_page((unsigned long)map->active.ring); } -- 2.9.5