mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 05:11:48 +00:00
RPCSEC_GSS: fix leak in krb5 code caused by superfluous kmalloc
I was sloppy when generating a previous patch; I modified the callers of krb5_make_checksum() to allocate memory for the buffer where the result is returned, then forgot to modify krb5_make_checksum to stop allocating that memory itself. The result is a per-packet memory leak. This fixes the problem by removing the now-superfluous kmalloc(). Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
8bbde0e6d5
commit
d4a30e7e66
@ -212,7 +212,6 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
|
|||||||
char *cksumname;
|
char *cksumname;
|
||||||
struct crypto_tfm *tfm = NULL; /* XXX add to ctx? */
|
struct crypto_tfm *tfm = NULL; /* XXX add to ctx? */
|
||||||
struct scatterlist sg[1];
|
struct scatterlist sg[1];
|
||||||
u32 code = GSS_S_FAILURE;
|
|
||||||
|
|
||||||
switch (cksumtype) {
|
switch (cksumtype) {
|
||||||
case CKSUMTYPE_RSA_MD5:
|
case CKSUMTYPE_RSA_MD5:
|
||||||
@ -221,13 +220,11 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
|
|||||||
default:
|
default:
|
||||||
dprintk("RPC: krb5_make_checksum:"
|
dprintk("RPC: krb5_make_checksum:"
|
||||||
" unsupported checksum %d", cksumtype);
|
" unsupported checksum %d", cksumtype);
|
||||||
goto out;
|
return GSS_S_FAILURE;
|
||||||
}
|
}
|
||||||
if (!(tfm = crypto_alloc_tfm(cksumname, CRYPTO_TFM_REQ_MAY_SLEEP)))
|
if (!(tfm = crypto_alloc_tfm(cksumname, CRYPTO_TFM_REQ_MAY_SLEEP)))
|
||||||
goto out;
|
return GSS_S_FAILURE;
|
||||||
cksum->len = crypto_tfm_alg_digestsize(tfm);
|
cksum->len = crypto_tfm_alg_digestsize(tfm);
|
||||||
if ((cksum->data = kmalloc(cksum->len, GFP_KERNEL)) == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
crypto_digest_init(tfm);
|
crypto_digest_init(tfm);
|
||||||
sg_set_buf(sg, header, hdrlen);
|
sg_set_buf(sg, header, hdrlen);
|
||||||
@ -235,10 +232,8 @@ make_checksum(s32 cksumtype, char *header, int hdrlen, struct xdr_buf *body,
|
|||||||
process_xdr_buf(body, body_offset, body->len - body_offset,
|
process_xdr_buf(body, body_offset, body->len - body_offset,
|
||||||
checksummer, tfm);
|
checksummer, tfm);
|
||||||
crypto_digest_final(tfm, cksum->data);
|
crypto_digest_final(tfm, cksum->data);
|
||||||
code = 0;
|
|
||||||
out:
|
|
||||||
crypto_free_tfm(tfm);
|
crypto_free_tfm(tfm);
|
||||||
return code;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(make_checksum);
|
EXPORT_SYMBOL(make_checksum);
|
||||||
|
Loading…
Reference in New Issue
Block a user